Split / merge UDP. Which layer is processing it? (QT Networking)

I am trying to use UDP to transfer big data over LAN using QT as a Framework for Socket Access. Sending simple messages is not a problem yet. However, I do not fully understand how packet segmentation is handled and who does it.

So the QT states:

Sending datagrams larger than 512 bytes is generally disadvantageous because, even if sent successfully, they are likely to be split into the IP layer before arriving at their final destination.

So I applied my own little protocol to handle split and merge big data. While playing with larger sizes than 512 bytes (in the order of 10KB) 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 it seems to me that the IP layer already takes care of splitting / merging my (oversized) UDP packets. So:

  • Why is it advisable to split data for UDP yourself?
  • "Who" handles the IP layer? (QT, Windows, networking hardware?)
  • I am guessing there is a second limit arising from read / write buffers in UDP Socket, where can I check this?
+3


source to share


1 answer


What QT states are nonsense. Even if datagrams are fragmented along the way over the Internet, they will be retransmitted to their destination. They are correct in that this is done at the IP level, so you have nothing to worry about your application unless you intend to break the 64k maximum datagram size (64k - Wikipedia in UDP )

As for your questions:



  • A common mistake. Hang up.
  • The IP layer is handled by the IP stack, usually at the core level
  • The "2nd limit" is defined by the IP protocol (v4 in your case), which defines a field of length up to 16 bits, making the maximum datagram size 64k (RFC 791)

However, if you plan to transfer large chunks of data in a reliable way, you should really use TCP instead of UDP. Let TCP handle these things instead of your application.

+3


source







All Articles