Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Send Raw ethernet packet using bpf: (13 Items)
   
Send Raw ethernet packet using bpf  
Hi

I use BPF to send raw Ethernet packet, but packets never arrive when sending packet without the TCP/IP header.

In my code I try to send to packets. A packet with a EtherCAT type where the first 12 bytes is the source and 
destination. And after this the type and the data.
The other packet I send is a ping packet.

Before running the program I started tcpdump with
tcpdump -iwm0 -XX
to catch the packets on the target PC.
And connected to the network card wm0 there is connected a computer with wireshark.

When run the program I see both packet in the terminal running tcpdump, but in wireshark i only see the ping packet.

So I wondering where my packet is blocked or stalled?
Is it in the bpf because it dont allow packet without tcpip header. Or is it something in the io-pkt there blocking for 
non tcp packet?

/Lasse
Attachment: Text DemoApp.cc 11.38 KB
Re: Send Raw ethernet packet using bpf  
I found something  about loading a filterprogram to the BPF device by using, BIOCSETF.

But the packet with another ethernet type is not send out on the ethernet card.
I attached the code with small differences to this post.

/Lasse
Attachment: Text DemoApp.cc 11.98 KB
RE: Send Raw ethernet packet using bpf  
Just to confirm, if you DON'T add the filter, does the packet get sent
out? 

Also, does the filter work in terms of the packets being received?

As a side note, one thing you might want to examine with this sort of
implementation is the real-time performance of the packet reception.
The stack hasn't been designed for highly-deterministic response to
packet reception / transmission through the socket resource manager
interface (representative of BPF) so there can be a significant amount
of jitter (especially under load) for packets being received by your
application.  I understand that EtherCAT is "real-time", so you might
want to ensure that the performance is "good enough" for this.  You also
have the possibility of using the lsm-nraw resource manager interface
which we've recently added to the repository (this provides the same
sort of interface that the nfm-nraw interface did in io-net).  

	Robert.

-----Original Message-----
From: Lasse Skov [mailto:community-noreply@qnx.com] 
Sent: Monday, February 23, 2009 10:40 AM
To: general-networking
Subject: Re: Send Raw ethernet packet using bpf

I found something  about loading a filterprogram to the BPF device by
using, BIOCSETF.

But the packet with another ethernet type is not send out on the
ethernet card.
I attached the code with small differences to this post.

/Lasse

_______________________________________________
General
http://community.qnx.com/sf/go/post22738
Re: RE: Send Raw ethernet packet using bpf  
I tried to run a program without the filter. But no packet is send out on the ethernet port except the TCP packet.

If i run a program there looks like DemoApp but instead of write to the bpf0 i read from it i catch both packets.
And it is the same with tcpdump.

Actual a filter is not necessary because the netcard is only used to ethercat communication.
Actually i don't understand, when the filter program is loaded, and if there is a way to see witch filter program is 
started? Or is it not possible.

And when adding a filterprogram to a bpf device is this overwrite the existing program on the bpf?

Maybe the lsm-nraw is a better way to communicate.
How is this connected to the io-pkt and how is the stack implemented to this?

/Lasse
RE: RE: Send Raw ethernet packet using bpf  
Here's an example of how to create and send / receive ICMP ping packets.


Compile it

cc -lsocket -oicmp icmp.c

Run it:

./icmp interface src-mac src-ip dst-mac dst-ip.

There are obviously ways to snarf out the relevant source information so
that you don't have to add them on the command line, but I took the path
of least resistance with some example code that we had lying around for
io-net.

lsm-nraw hooks into the stack using the packet filter interface.  See
http://community.qnx.com/sf/wiki/do/viewPage/projects.networking/wiki/Fi
ltering_wiki_page

	Robert.

-----Original Message-----
From: Lasse Skov [mailto:community-noreply@qnx.com] 
Sent: Tuesday, February 24, 2009 1:24 PM
To: general-networking
Subject: Re: RE: Send Raw ethernet packet using bpf

I tried to run a program without the filter. But no packet is send out
on the ethernet port except the TCP packet.

If i run a program there looks like DemoApp but instead of write to the
bpf0 i read from it i catch both packets.
And it is the same with tcpdump.

Actual a filter is not necessary because the netcard is only used to
ethercat communication.
Actually i don't understand, when the filter program is loaded, and if
there is a way to see witch filter program is started? Or is it not
possible.

And when adding a filterprogram to a bpf device is this overwrite the
existing program on the bpf?

Maybe the lsm-nraw is a better way to communicate.
How is this connected to the io-pkt and how is the stack implemented to
this?

/Lasse

_______________________________________________
General
http://community.qnx.com/sf/go/post22847

Attachment: Text icmp.c 5.76 KB
Re: RE: RE: Send Raw ethernet packet using bpf  
This is working and it's possible to send a lot of data.

Now im woundering how it is possible to let io-pkt create a bpf more.
So i have two bpf one named
/dev/bpf0
/dev/bpf1

So i can setup multiple filter on those two devices bound to the same network adapter.

/Lasse
Re: RE: RE: Send Raw ethernet packet using bpf  
Hi Robert Craig,

I am also trying to send/receive raw packets using BPF. I am using QNX 6.3.2. On QNX 6.3.2 BPF was not there. 

I mounted nfm-bpf.so using “mount –T io-net nfm-bpf.so” command.

On mounting “en-en0” was created in /dev/io-net. And also bpf is available in /dev/socket in QNX 6.3.2.

I did a sample program to open bpf . It was successful.
When i am running using "./icmp interface src-mac src-ip dst-mac dst-ip"
its saying 
icmp: write: Function not implemented.

I am new to QNX and BPF. No idea about the error.
May i know why I am facing this error. Thanks in advance.




Re: RE: RE: Send Raw ethernet packet using bpf  
bpf wasn't officially supported in 6.3.2.  It was read only.
I suggest going to 6.5 is possible.

Regards,

-seanb

On Thu, Jul 21, 2011 at 12:07:54PM -0400, Nagarjuna b wrote:
> Hi Robert Craig,
> 
> I am also trying to send/receive raw packets using BPF. I am using QNX 6.3.2. On QNX 6.3.2 BPF was not there. 
> 
> I mounted nfm-bpf.so using ???mount ???T io-net nfm-bpf.so??? command.
> 
> On mounting ???en-en0??? was created in /dev/io-net. And also bpf is available in /dev/socket in QNX 6.3.2.
> 
> I did a sample program to open bpf . It was successful.
> When i am running using "./icmp interface src-mac src-ip dst-mac dst-ip"
> its saying 
> icmp: write: Function not implemented.
> 
> I am new to QNX and BPF. No idea about the error.
> May i know why I am facing this error. Thanks in advance.
> 
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> 
> General
> http://community.qnx.com/sf/go/post87502
Re: RE: RE: Send Raw ethernet packet using bpf  
hi Sean Boudreau,

Thankyou for quick reply. Don't we have any option to implement in QNX 6.3.2 ?

As of now there is no scope for me to upgrading to higher version of QNX . 
Also please let me know why am i getting that error?
"write:function not implemenmted"

Re: RE: RE: Send Raw ethernet packet using bpf  
BPF was read only in 6.3.2.  Write wasn't implemented.

Regards,

-seanb

----- Original Message -----
From: Nagarjuna b [mailto:community-noreply@qnx.com]
Sent: Thursday, July 21, 2011 12:17 PM
To: general-networking <post87505@community.qnx.com>
Subject: Re: RE: RE: Send Raw ethernet packet using bpf

hi Sean Boudreau,

Thankyou for quick reply. Don't we have any option to implement in QNX 6.3.2 ?

As of now there is no scope for me to upgrading to higher version of QNX . 
Also please let me know why am i getting that error?
"write:function not implemenmted"





_______________________________________________

General
http://community.qnx.com/sf/go/post87505
Re: RE: RE: Send Raw ethernet packet using bpf  
Sean Boudreau

Thankyou very much for your reply :)
Re: RE: RE: Send Raw ethernet packet using bpf  
Hi Sean Boudreau,
We have mounted nfm-bpf.so and nfm-nraw.so in QNX 6.3.2
I have learned bpf can be used to receive and nraw to send raw packets in QNX6.3.2.

We are successful in testing receive function.
How can we use nraw to send raw packets?
Can I get any documents or sample code to send raw packets using "nraw"?


Please help.
Re: RE: RE: Send Raw ethernet packet using bpf  
Sorry!! The previous post was not complete. I Tried the code posted above  (icmp.c)

Compilation was success. When i run it says write: function not implemented.

Please help.