简体   繁体   中英

UDP with gso doesn't receive the entire message

I am trying to use UDP with GSO (Generic Segmentation Offload) to send 50Kb sized packets.

// sender side 
int val = 1472; // ETHERNET - udp - upv4 header
if (setsockopt(fdt, SOL_UDP, UDP_SEGMENT, &val, sizeof(val)))
    error(1, errno, "setsockopt udp segment");
int ret = sendmsg(fd, msg, flags);

and on the recv size, I do

// recv side 
int ret = recvmsg(fd, msg, flags);

I can see that I send 50Kb message and receiver side only received 1472 with one call. I have heard about GRO (Generic Receive Offload) but I didn't find any example online. Do I have to make multiple syscalls to get all the data, is it possible to set a socekt option or make a syscall to receive reassembled message in one go? how can it be more efficient if I have to make multiple system calls instead of just relying on IP fragmentation and sending larger than MTU packets?

Here is an interesting article you can read for deep understand GSO and GRO. Ethtool may be able to enable/disable GRO on specific interfaces. Depends on the version. If you can go well with it, then it's best.

If not, since the Linux network stack is realy complicated, it's hard to check which part makes the segment fail just by the result. I think it's better to use some tools like netstat, ss, sar, tcpdump, wireshark and others to analyze each layer and then it's much easier to know where is wrong. But don't forget to check if your hardware support this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM