problems with windows sockets

G

GilNajera

Hi everyone!

I have an application that communicates 2 computers using tcp sockets
(winsocks). The most of the time it works fine, but some packets are
received as 1 when they was sent as 2 or 3. I mean, I execute two or
three send commands and receive all the data in one single packet.

The packets are sent every 200 ms (Naggle's algorithm is disabled) and
there is an independent thread receiving on the other side's
application. When a packet is received it is processed immediately,
after that, the receiving is resumed.

I'm not an expert in networking, can anybody tell me why is this
happening, and how can I solve it.

Thanks in advance.
 
T

Tom St Denis

Hi everyone!

I have an application that communicates 2 computers using tcp sockets
(winsocks). The most of the time it works fine, but some packets are
received as 1 when they was sent as 2 or 3. I mean, I execute two or
three send commands and receive all the data in one single packet.

The packets are sent every 200 ms (Naggle's algorithm is disabled) and
there is an independent thread receiving on the other side's
application. When a packet is received it is processed immediately,
after that, the receiving is resumed.

I'm not an expert in networking, can anybody tell me why is this
happening, and how can I solve it.

TCP is a streaming protocol not a datagram one. So it can merge
packets so that a single recv() can read multiple send()'s worth of
data.

If you want datagram service use UDP.

Tom
 
P

Pavel Borzenkov

Hi,

TCP is a streaming protocol not a datagram one. So it can merge
packets so that a single recv() can read multiple send()'s worth of
data.

If you want datagram service use UDP.

I think this is not a very good advice, since UDP doesn't guarantee packets'
delivery. A better solution is to develop a communication protocol that
includes a header for every data packet and put the data size into this
header.

-P
 
T

Tom St Denis

Hi,





I think this is not a very good advice, since UDP doesn't guarantee packets'
delivery. A better solution is to develop a communication protocol that
includes a header for every data packet and put the data size into this
header.

While true, it's not of practical use. I have never, ever, with all
my lab work, ever seen a UDP packet dropped or lost.

But ya, if he wants to do things properly he should either put headers
on his TCP traffic or do some form of UDP ACK/NAK.

Tom
 
D

David Resnick

While true, it's not of practical use.  I have never, ever, with all
my lab work, ever seen a UDP packet dropped or lost.

But ya, if he wants to do things properly he should either put headers
on his TCP traffic or do some form of UDP ACK/NAK.

Tom

RTP (media transport typically used for VoIP) is generally sent using
UDP. I've seen quite a few cases where there was packet loss in real
telephony networks, so I'd say it is a practical issue. Of course, at
50 packets per second losing one here or there doesn't actually
degrade audio quality (loss of 20 milliseconds of audio data matters
not at all). But still, any design that requires reliability
shouldn't use UDP unless you build a protocol to enable
retransmission...

-David
 
M

Michael Angelo Ravera

Hi everyone!

I have an application that communicates 2 computers using tcp sockets
(winsocks). The most of the time it works fine, but some packets are
received as 1 when they was sent as 2 or 3. I mean, I execute two or
three send commands and receive all the data in one single packet.

The packets are sent every 200 ms (Naggle's algorithm is disabled) and
there is an independent thread receiving on the other side's
application. When a packet is received it is processed immediately,
after that, the receiving is resumed.

I'm not an expert in networking, can anybody tell me why is this
happening, and how can I solve it.

Thanks in advance.

If I understand your problem correctly, the usual solution is to
prefix each logical packet with a size word of whatever length you
like (2 or 4 bytes is fairly common). The other common solution is to
send all logical packets as the same fixed size or to make them self-
described in length somehow( terinating character for instance). You
have to pick one of these.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top