UDP数据包大小和数据包丢失 [英] UDP Packet size and packet losses

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

问题描述

我一直在编写一个程序,该程序使用UDP之上的停止和等待协议在LAN和WAN上发送数据包.我最近一直在测试程序,注意到较大的数据包(接近64k字节)的数据包丢失率更高.直觉上这是有道理的,但是真正的原因是什么?

I've been writing a program that uses a stop and wait protocol on top of UDP to send packets over LAN and also over WAN. I've recently been testing my program and have noticed that the packet loss rate is higher for larger packets (approaching 64k bytes). Intuitively this makes sense but what are the actual reasons for this?

推荐答案

大于 MTU大小承载它们的网络将被自动拆分为多个数据包,然后由接收者重新组合.如果多个子分组中的任何一个被丢弃,那么接收者也将丢弃其余的子分组.

UDP packets greater than the MTU size of the network that carries them will be automatically split up into multiple packets, and then reassembled by the recipient. If any of those multiple sub-packets gets dropped, then the receiver will drop the rest of them as well.

例如,如果您发送一个63k UDP数据包,并且它通过以太网,它将分解成47个或更小的碎片"数据包(因为以太网的MTU为1500字节,但是其中一些用于UDP标头等等,因此UDP数据包中可用的用户数据空间量要小于该数据包).如果所有47个以上的分段数据包都通过,则接收方将仅看到"该UDP数据包.如果仅丢弃其中一个片段包,则整个操作将失败.

So for example if you send a 63k UDP packet, and it goes over Ethernet, it will get broken up into 47+ smaller "fragment" packets (because Ethernet's MTU is 1500 bytes, but some of those are used for UDP headers, etc, so the amount of user-data-space available in a UDP packet is smaller than that). The receiver will only "see" that UDP packet if all 47+ of those fragment-packets make it through okay. If just one of those fragment-packets gets dropped, the whole operation fails.

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

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