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

查看:32
本文介绍了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?

推荐答案

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

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天全站免登陆