保证TCP包大小 [英] Guarantee TCP Packet Size

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

问题描述

我们使用嵌入式设备通过串口到以太网转换器将数据包从串行端口发送到服务器。我们使用的一个制造商,Moxa将始终以与构造相同的方式发送数据包。意思是,如果我们构造一个255的数据包,它将始终以255的长度发送数据包。另一个制造商Tibbo,如果我们发送数据包大小为255,那么如果它大于128,它将打破数据包。这是当时从Tibbo工程师收到的答案:

We use an embedded device to send packets from a serial port over a serial-to-Ethernet converter to a server. One manufacturer we use, Moxa, will always send the packets in the same manner which they are constructed. Meaning, if we construct a packet size of 255, it will always send the packet in a 255 length. The other manufacturer, Tibbo, if we send the packet size 255, it will break the packet up if it is greater than 128. This is the answer I received from the Tibbo engineers at the time:


从我的理解和
工程师的说法,即使其他
设备为您提供正确的
数据包大小现在不保证
当在其他
网络中实现时会发生相同的情况。这个
是为什么我们感觉到数据包
数据传输通过TCP
不是可靠的,因为它不是
TCP被设计为使用的方式。

"From what I understand and what the engineers said, even if the other devices provide you with the right packet size now does not guarantee that when implemented in other networks the same will happen. This is the reason why we feel that packet size based data transfer through TCP is not reliable as it was not the way TCP was designed to be used."

我知道这可能不是如何TCP被设计为使用,但是如果我创建一个255字节的数据包,并且TCP允许它,那么TCP在TCP之外如何工作?我明白,在某些时候,数据包可能会分解,但是如果服务器期望某个数据包的大小,并且Moxa的产品与Tibbo设备没有相同的问题。

I understand that this may not be how TCP was designed to be used, but if I create a packet of 255 bytes and TCP allows it, then how is this outside of how TCP works? I understand that at some point the packet may get broken up but if the server is expecting a certain packet size and Moxa's offering does not have the same problem as the Tibbo device.

那么,是否可以保证合理的TCP数据包大小?

So, is it possible to guarantee a reasonable TCP packet size?

推荐答案

没有。 TCP不是数据包协议,它是一个流协议。它保证您发送的字节将全部到达,并以正确的顺序,但没有别的。特别地,TCP不给你任何类型的消息或分组边界。如果你想要这样的东西,他们需要在你的协议的更高级别上实现。

No. TCP is not a packet protocol, it is a stream protocol. It guarantees that the bytes you send will all arrive, and in the right order, but nothing else. In particular, TCP does not give you any kind of message or packet boundaries. If you want such things, they need to be implemented at a higher level by your protocol.

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

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