本文介绍了UDP是否允许重新打包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,对于TCP,您可以启用 Nagle算法.但是,您可以为UDP使用类似的东西吗?

I know that for TCP you can have for example Nagle's Algorithm enabled. However, can you have something similar for UDP?

实际问题(假设使用UDP套接字):

如果我在短时间内两次调用send(),每次send()调用中都有1个字节的数据.传输层是否可能决定仅发送1个带有1 byte + 1 byte = 2 bytes数据的UPD数据包?

If I call send() two times in a short period of time with 1 byte of data in each send() call. Is it possible that the transport layer decides to send only 1 UPD packet with the 1 byte + 1 byte = 2 bytes of data?

提前谢谢!

推荐答案

不符合RFC( RFC 768 ).除了IP设施本身之外,UDP实际上仅作为附加功能提供基于端口的路由,并提供了一些额外的检测是否损坏或错误路由的功能.

Not according to the RFC (RFC 768). Above IP facilities themselves, UDP really only provides, as extras, port-based routing and a little bit of extra detection for corruption or misrouting.

这意味着没有工具可以组合数据报.实际上,由于它是面向事务的,所以我认为将两笔交易合并为一个交易对于保持这些交易的完全不同可能是一个 bad 想法.

That means there's no facility to combine datagrams. In fact, since it's meant to be transaction oriented, I would say that combining two transactions into one may well be a bad idea in terms of keeping these transaction disparate.

否则,您将需要在UDP之上的一层,该层可以弄清楚如何从数据报中提取这些事务.目前,这不是必需的,因为数据报事务.

Otherwise, you would need a layer above UDP which could figure out how to extract these transactions from a datagram. At the moment, that's not necessary since the datagram is the transaction.

作为对此争用的附加支持(当然不是绝对的),请参见 UDP维基百科页面:

As added support (though not, of course, definitive) for this contention, see the UDP wikipedia page:

但是,对其的最佳支持来自其客户之一. UDP是专门为TFTP设计的(除其他外),如果您不能区分事务,该协议就会失效.

However, the best support for it comes from one of its clients. UDP was specially engineered for TFTP (among other things) and that protocol breaks down if you cannot distinguish a transaction.

具体来说,TFTP事务类型之一是data事务,它由操作码,块号和最多512字节的数据组成.如果没有开始处的长度指示或末尾的标记值,则除非有事务与数据报之间的一对一映射,否则无法通过 方法来确定下一个事务将从何处开始.

Specifically, one of the TFTP transaction types is the data transaction which consists of an opcode, block number and up to 512 bytes of data. Without a length indication at the start or a sentinel value at the end, there is no way to work out where the next transaction would start unless there is a one-to-one mapping between transaction and datagram.

顺便说一句,其他四种TFTP事务类型具有固定长度或字符串结尾标记值,但data事务是决定者.

As an aside, the other four TFTP transaction types have either a fixed length or end-of-string sentinel values but the data transaction is the decider here.

这篇关于UDP是否允许重新打包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 10:39
查看更多