编程实践:如何为UDP数据报选择数据包大小?(programing practices : how to choose a packet size for UDP datagrams?)

编程入门 行业动态 更新时间:2024-10-25 06:32:11
编程实践:如何为UDP数据报选择数据包大小?(programing practices : how to choose a packet size for UDP datagrams?)

免责声明 :这不是一个“如何”的问题。 我想更多地了解,作为背景信息,实际使用的实际操作有何不同。

我们知道UDP没有像TCP这样的PMTU发现。 所以我看到几种避免使用UDP进行IP分片的方法:

最多发送512字节数据包(UDP方法) 重新实现一些PMTU(使用ICMP“需要碎片化”消息)。 依赖于本地MTU(但可靠性有多远,因为UDP不是连接协议,它如何知道其数据包将通过哪个接口?) 其他... ?

那么我想要的是对当前UDP程序/协议正在使用哪些方法的“背景”概念,特别是关于流/ VoIP常见应用程序?

谢谢提前,

乔斯林

Disclaimer : this is not a "how to" question. I would more like to know, as a background information what are the different actual practices actually used.

We know that UDP does not have a PMTU discovery like TCP. So I see several approaches to avoid IP fragmentation with UDP :

Sending 512 bytes packets max (the UDP approach) re-implementing some PMTU  (using ICMP "needs fragmentation" message). Relying on local MTU (but how far is it reliable, as UDP isn't a connected protocol, how can it knows which interface its packets are going to go through ?) others... ?

So what I would like is to have a "background" idea of which approaches are being used by current UDP programs/protocols, especially regarding streaming/VoIP common applications ?

Thanks by advance,

Jocelyn

最满意答案

限制为576个字节非常常见。 大多数Internet协议(如DNS)都是这样做的。 大多数实时流媒体协议也使用较小的数据包,因为它具有提供较低的序列化延迟和在单个数据包丢失时影响较小的额外好处。

一些协议具有协商更大分组大小的方式,但通常不像PMTU发现那样健壮(DHCP,例如允许最大消息大小协商)。

还有一些默认为1500左右的东西,并允许用户在必要时降低它。 大多数SNMP的实现似乎都是这样的。

无论如何,DF位通常不会被设置,因此过于乐观的结果是碎片,而不是破碎。

Limiting to 576 bytes is very common. Most of the Internet protocols such as DNS do this. Most real-time streaming protocols also use smaller packets since it has the added benefit of providing lower serialization delay and less impact if a single packet is lost.

Some protocols have ways of negotiating a larger packet size, though often not in a way that's as robust as PMTU discovery (DHCP, for example allows a maximum message size negotiation).

There's also stuff that defaults to 1500 or so and lets the user lower it if necessary. Most implementations of SNMP seem to do something like this.

In any event, the DF bit isn't generally set, so the consequence of being overly optimistic is fragmentation, not brokenness.

更多推荐

本文发布于:2023-08-07 07:13:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1462965.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据包   何为   大小   数据   programing

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!