如何发送大小大于64 KB的UDP数据包 [英] How to send UDP packets of size greater than 64 KB

查看:49
本文介绍了如何发送大小大于64 KB的UDP数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法发送大小超过64 KB的 IP多播数据报(实验中需要这样做).我正在通过 10千兆以太网链接直接连接的计算机之间传输数据包(之间没有任何跃点,由 traceroute 确认).

I am unable to send IP multicast datagrams of size greater than 64 KB (which I need to, for my experiments). I am transferring packets between computers connected directly by 10 Gigabit ethernet links (without any hops in between, confirmed by traceroute).

所有计算机均已安装Ubuntu 12.04.我通过在/etc/sysctl.conf 中添加以下几行来更改读写缓冲区的限制:

All computers have Ubuntu 12.04 installed. I changed the limits of read and write buffers by adding the following lines in /etc/sysctl.conf :

net.core.rmem_max=12582912
net.core.wmem_max=12582912
net.core.rmem_default=12582912
net.core.wmem_default=12582912

,并使用sysctl -a验证了更改(运行sysctl -p之后).我需要重新启动才能看到更改吗?(我正在共享机器,因此并不总是可以重新启动.)

and verified the changes using sysctl -a (after running sysctl -p). Do I need to restart so that I can see the changes? (I am sharing the machines, so a restart is not always possible).

在所有计算机中,用于发送和接收的接口的 MTU 为9000字节.我已经成功发送了大约60 KB的数据包,对于100 KB的数据包,使用 tcpdump 进行捕获显示,数据包甚至没有被发送,并且可能被内核丢弃了(我看不到它们)在tcpdump跟踪中).

The MTU of the interface used to send and receive is 9000 Bytes in all the computers. I have been successful in sending packets of size around 60 KB, and for 100 KB packets, capturing using tcpdump reveals that the packets are not even sent and probably dropped by the kernel (I don't see them in the tcpdump trace).

要传输大型数据包(最好大小为100 MB),我还需要做些什么?

What more do I need to do to be able to transfer large packets (preferably of sizes of the order of 100 MBs)?

推荐答案

UDP数据报必须容纳在单个IP数据报中.IP标头中的 总长度 字段为16位,因此最大长度(包括IP和UDP标头)为65535个字节. UDP标头也有一个16位的 Length 字段.UDP长度字段包括UDP报头,而不是IP报头,但是由于整个UDP数据报必须适合IP数据包的有效负载,因此它受IP长度的限制.

A UDP datagram has to fit inside a single IP datagram. The Total Length field in the IP header is 16 bits, so the maximum length (including the IP and UDP headers) is 65535 bytes. The UDP header also has a 16-bit Length field. The UDP Length field includes the UDP header, not the IP header, but since the entire UDP datagram has to fit in the payload of an IP packet, it's constrained by the IP length.

因此,不可能发送大于64KB的UDP数据报.由于IP和UDP标头的最小大小分别为20和8个字节,因此实际有效载荷的最大数量最多为65507个字节.

So it's not possible to send a UDP datagram larger than 64KB. Since the minimum sizes of the IP and UDP headers are 20 and 8 bytes, respectively, the actual maximum amount of payload is at most 65507 bytes.

如果需要发送更大的消息,则需要将其分解为多个数据报.或者,也许您应该考虑使用其他传输协议,例如TCP(不幸的是,如果您正在进行多播,则不可能这样做).

If you need to send larger messages, you need to break it up into multiple datagrams. Or perhaps you should consider using a different transport protocol, such as TCP (unfortunately, this is not possible if you're doing multicast).

IPv6支持大于64K的 Jumbograms .但是您不能在IPv4中做到这一点.

IPv6 supports Jumbograms that are larger than 64K. But you can't do it in IPv4.

这篇关于如何发送大小大于64 KB的UDP数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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