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

Hao Wu wuhao.thu at gmail.com
Thu Nov 26 12:14:11 UTC 2015


Hi Ulric,

   Got it! Many thanks :)

+++++++++++++++++
Best,
Hao

On Thu, Nov 26, 2015 at 6:25 PM, <ulric at siag.nu> wrote:

>
>
> 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