is it possible to send large UDP Packets by settin

2019-03-04 08:06发布

问题:

I'm wrting a UDP client and UDP server.

I have some large UDP payload, which is between 2000-3000. I tried some simple tests. I let the UDP client send 2000 bytes in a datagram, and used tcpdump to capture packets. I notice there is only 1 outgoing packet and it is not parsed to UDP packet, but a IP packet of 1514 bytes, this means there are about 500 bytes lost.

Is it possible to put all the payload in the same UDP packet(it will take some effort to split the payload into 2 parts and then assemble them on the receving application layer), and let IP stack the fragment each UDP packets into several IP fragments. And on the server side, the IP stack assemble the IP fragments and handle them to the UDP server.

If it is possible, how to enable IP fragmentation?

回答1:

That's what should happen by default. The problem with that is that if a fragment never arrives, there is nothing at the IP level that will cause a retransmit, so the entire datagram is lost. In general with UDP you are best off using datagrams smaller than the path MTU, if you can discover it, otherwise 534 bytes, as all hosts are required not to fragment below this level.