I try to use UDP to transfer large Data over a local Network, using QT as Framework for the Socket Access. Sending simple messages is not a problem so far. However, I do not (fully) understand how segmentation of packages is handled and who does it.
So QT states:
Sending datagrams larger than 512 bytes is in general disadvised, as even if they are sent successfully, they are likely to be fragmented by the IP layer before arriving at their final destination.
Therefore I implemented my own little protocol to handle split and merge of large Data. Playing around with larger sizes than 512 bytes (in the order of 10kBytes), I came across the following snippet from wireshark:
"17","0.145050","192.168.2.111","192.168.2.222","IPv4","1514","Fragmented IP protocol (proto=UDP 17, off=0, ID=3a47) [Reassembled in #23]"
"18","0.145051","192.168.2.111","192.168.2.222","IPv4","1514","Fragmented IP protocol (proto=UDP 17, off=1480, ID=3a47) [Reassembled in #23]"
"19","0.145051","192.168.2.111","192.168.2.222","IPv4","1514","Fragmented IP protocol (proto=UDP 17, off=2960, ID=3a47) [Reassembled in #23]"
"20","0.145051","192.168.2.111","192.168.2.222","IPv4","1514","Fragmented IP protocol (proto=UDP 17, off=4440, ID=3a47) [Reassembled in #23]"
"21","0.145052","192.168.2.111","192.168.2.222","IPv4","1514","Fragmented IP protocol (proto=UDP 17, off=5920, ID=3a47) [Reassembled in #23]"
"22","0.145052","192.168.2.111","192.168.2.222","IPv4","1514","Fragmented IP protocol (proto=UDP 17, off=7400, ID=3a47) [Reassembled in #23]"
"23","0.145052","192.168.2.111","192.168.2.222","UDP","1186","63230 > 8007 Len=10024"
And from that I get one Datagram in QT. So for me it seems that the IP layer is already taking care of splitting/merging my (too large) UDP Packets. So:
- Why is it advised to split the Data for UDP by myself?
- "Who" handles the IP layer? (QT,Windows, Network-hardware?)
- I assume there is a second limit resulting from read/write buffers in the UDP Socket, where can I check on that?