views:

55

answers:

1

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:

"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."

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.

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

+8  A: 

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.

dty
which is strange because with the other product we have been using it for years on a number of different networks with no problems and the packets always come in the same size. Never any issues whatsoever.
0A0D
The fact that one device sents a 255 byte packet and the other sends two 128 byte packets is irrelevant and is just a function of the devices. Packets this small are very unlikely to get fragmented by the network - in fact, there is a minimum packet size but I can't recall what it is off the top of my head. Either way, the server code needs to be able to cope with this situation as it is making incorrect assumptions about the nature of TCP.
dty
Thanks `dty` for your information.
0A0D
You're welcome.
dty
+1, nice answer dty, this is exactly right.
Dan