Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Bulk udp read: (2 Items)
   
Bulk udp read  
When doing read() on a datagram stream, each read() return one packet.  Is there any way to read multiple packets in a 
single operation.

When receiving data from a GigE camera we get a packet every 30us.  Would like to cut down on the context switches.  

Re: Bulk udp read  
On 10/03/10 06:56 PM, Mario Charest wrote:
> When doing read() on a datagram stream, each read() return one packet.
Yes, and this is expected and according to specs for UDP sockets. In 
fact, when you think about it, you want to keep the packet boundaries, 
so there isn't much option other than introducing new ancillary data 
which tell you the boundaries or in-line data markers or length fields. 
None of which are in the standard/de facto socket interface.
>    Is there any way to read multiple packets in a single operation.
>    
Several choices come to mind. Perhaps using BPF which can return you 
several packets in one read is an option, but you've got to check if you 
can control the latency (how much it waits to bulk them up before giving 
them). And because it's unprocessed directly from driver you'd have to 
do some protocol work in your code. Or you can create your own custom 
interface with the stack which bulk packets and package them with 
boundary information according to your preference. Or, easiest might be 
to use plain read(). But I'm not sure if it'll still return each packet 
or not, I haven't tried, and you'll have to figure out a way to restore 
your packet boundaries...

> When receiving data from a GigE camera we get a packet every 30us.  Would like to cut down on the context switches.
>    

If the packets all have constant size, maybe that can help you with 
packet boundaries...

Just ideas to try, but hope it helps...
/P