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

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

问题描述

我正在编写一个 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 标头来启用 IP 分段来发送大型 UDP 数据包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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