Can I send the Ethernet frames with particular payload via Netmap?

ulric at siag.nu ulric at siag.nu
Thu Nov 26 10:35:40 UTC 2015



2015-11-25 15:30 skrev Hao Wu:
> Hi all,
> 
>    I just start using Netmap. I want to know can I build the Ethernet
> frames and send out via Netmap? I used to build the Ethernet frames via
> Libnet, but it is too slow. So I turn to Netmap now. But I have no idea 
> on
> how to write the code using Netmap or what functions should I call?
> 
>    Any replay is highly appreciated!


It's crazy simple. To open a netmap descriptor:

	d = nm_open(ifname, NULL, 0, 0);

To receive a frame:

	uint8_t *b = nm_nextpkt(d, &h);

To send a frame:

	int n = nm_inject(d, b, len);

Working example from Pen:

https://github.com/UlricE/pen/blob/master/dsr.c

Ulric


More information about the freebsd-net mailing list