Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux / C udp send methods

Tags:

c

sockets

udp

send

The only way to send UDP packets in C is to use send/sendo/write/... calls.

The problem with those is, that for each packet I need to perform a new call from user-space.

Does anyone know whether there is a function which allows for something like

send_packets( int socket, const char* buffer, int packetSize )

Which does automatically split the data in the buffer into packets of size packetSize (e.g. 1472) and then send them as UDP packets?

Thanks

like image 618
david Avatar asked Jan 25 '26 17:01

david


1 Answers

You can batch raw packets but not higher level protocols. The low-level API is for utilities like Wireshark.

On Linux you can modify the kernel to implement a sendmmsg() API similar to recvmmsg() but when I did it I only registered a performance loss due to how cumbersome the interface is actually to use.

The userbase of such an API is pretty limited as if you really want high performance simply move to InfiniBand or use the userspace socket API provided by Solarflare (OpenOnload) or Mellanox that depends upon their 10 GigE RDMA over Ethernet capable interfaces.

like image 110
Steve-o Avatar answered Jan 27 '26 16:01

Steve-o