Re: Broken TCP/IP packets



On 1 Apr 2007 02:48:10 -0700, "Ali" <abdulrazaq@xxxxxxxxx> wrote:

I have a serial device that is using MCU's UART (rs232) for data
transfer, every time my device is suppose to deliver 20 bytes making
it a single transaction. We have a VB and C# app using MSCOMM and it
works perfectly.
Now I have added an Ethernet converter to convert serial data to TCP/
IP packets. It works atleast for half of the time. For the rest of
the problematic half the behavior is very strange, yes, my received
packets are broken in parts. For example I'll receive 20 bytes in tow
transactions like 10 byte for each time. I tried to look at the MCU
UART signal via oscilloscope but the timing was quite consistent.
Can't understand why packets are broken/scattered, any idea?


regards,
ali

Ali

You cannot expect TCP to give you pakets on the remote end the way you
feed them into the system. That's just by design. TCP is a streaming
protocol, and it's up to the senders TCP stack implementation to fill
segments to what ever degree seems good to get a good performance.
That said, the sending part will most likely try to combine your 20
bytes chunks of data into as few segments as possible cause sending
out a segment over the wire is timewise expensive. The Nagle algorithm
will delay sending out segments a tad bit to see if more data arrives
and if so will concatenate your pakets into a single bigger TCP
segment.

So your reciveing end simply must be written so as it keeps on reading
from the TCP stream up until you have 20 bytes, and store excess bytes
it may have read for the next call. This can easily be implemented
with a ring buffer structure and as many calls to recv() as needed.

If you try to circumvent this, you are fighting against TCP and
potential oddities/requierements of the unterlaying network along the
comunication path.

HTH

Markus

.



Relevant Pages

  • Re: Broken TCP/IP packets
    ... it a single transaction. ... packets are broken in parts. ... You cannot expect TCP to give you pakets on the remote end the way you ... segments to what ever degree seems good to get a good performance. ...
    (comp.arch.embedded)
  • Re: Broken TCP/IP packets
    ... it a single transaction. ... packets are broken in parts. ... You cannot expect TCP to give you pakets on the remote end the way you ... segments to what ever degree seems good to get a good performance. ...
    (comp.arch.embedded)
  • Re: Broken TCP/IP packets
    ... In your TCP layer add packetization overhead and then decode it ... it a single transaction. ... Now I have added an Ethernet converter to convert serial data to TCP/ ... packets are broken in parts. ...
    (microsoft.public.win32.programmer.networks)
  • Re: Broken TCP/IP packets
    ... lost its TCP header, but IP header and TCP ... We started to see thousands of packets just like ... it a single transaction. ...
    (comp.arch.embedded)
  • Re: How do i avoid packet segmentation?
    ... different segments of 500 each before getting to the server. ... I'm sending the packets using the C sendfunction. ... The fact that you have three segments of 500B each indicates you have a MTU of 500B somewhere along the path - if you go for backbone networks you'll get segments of 56B or so - which will be put into a single 500B package on the backbone exit point. ... If it's TCP breaking up the data from the user, ...
    (comp.os.linux.development.apps)