是否可以通过设置IP头来发送大型UDP数据包以启用IP分段? [英] is it possible to send large UDP Packets by setting IP header to enable IP fragmentation?

查看:286
本文介绍了是否可以通过设置IP头来发送大型UDP数据包以启用IP分段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UDP客户端和UDP服务器。

I'm wrting a UDP client and UDP server.

我有一些大的UDP有效负载,介于2000-3000之间。我尝试了一些简单的测试。我让UDP客户端在数据报中发送2000个字节,并使用 tcpdump 来捕获数据包。我注意到只有1个传出数据包,它没有解析为UDP数据包,而是一个1514字节的IP数据包,这意味着丢失了大约500个字节。

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.

是可以将所有有效载荷放在同一个UDP数据包中(需要花费一些精力将有效载荷分成两部分,然后将它们组装在接收应用层上),并让IP将每个UDP数据包的片段堆叠成几个IP片段。在服务器端,IP堆栈汇集IP分段并将它们处理到UDP服务器。

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.

如果可能,如何启用IP分段?

If it is possible, how to enable IP fragmentation?

推荐答案

这是默认情况下应该发生的事情。问题在于,如果片段永远不会到达,则IP级别上没有任何内容会导致重新传输,因此整个数据报都会丢失。通常使用UDP时,最好使用小于路径MTU的数据报,如果可以发现它,否则为534字节,因为所有主机都不需要在此级别之下进行分段。

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.

这篇关于是否可以通过设置IP头来发送大型UDP数据包以启用IP分段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆