Link to home
Start Free TrialLog in
Avatar of bachar
bachar

asked on

TCP/IP

I'm building client server application over TCP. The order of the arrival of the messages from the client to the server is important. Does TCP assure me that all the messages (packets) that I will send from the client to server will arrived at the same order they had been send?

Thank you.
Avatar of jjeff1
jjeff1

No, packets can arrive out of order. They are reordered, but I am not sure at what layer.
packets can also be dropped, requiring a resend
ASKER CERTIFIED SOLUTION
Avatar of BrettNem
BrettNem

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
> No, packets can arrive out of order.

Yes, IP-packets can arrive out of order.

> They are reordered, but I am not sure at what layer.

I am sure that it is the TCP (Transmission Control Protocol) running _OVER_ the IP (Internet Protocol) --
read it as "Tea See Pea over Eye Pea" -- which
re-requests "missing" packets, and orders the IP-packets
You are right, it's TCP (layer 4) that re-orders the packets and requests re-transmission of any missing packets (it knows that a packet is missed because of sequence numbers in the session).

If on the other hand you were to use UDP then you would have to build the reliability into your application. TCP is less efficient but it's reliable.
As long as you are using tcp, and not udp, al your packets will arrive..
tcp wiats for an aknowledgement, before he sends the next packet..
Udp, does not, thats why it faster, but less relyable
gr

Erik Kruijswijk
The answer is simply YES. Providing that your application is using TCP protocol. In that case you don't have to be woried about the mesages order. Your distination host will receive it in the same order your source host is sending with error recovery and this is one of the TCP fruits if we compare it with UDP.
I Hope that this will satisfy your needs.
Regards,
Fathalla
> TCP waits for an acknowledgement before sending the next packet..

Not always true -- a "windowing" technique is often used.
TCP will send, say, five packets, and then wait to receive
the acknowledgment of the _FIRST_ packet before sending
the _SIXTH_ packet.  
Obviously, this increases "throughput" of the connection.
If you use TCP in your application all of the stuff mentioned above will be carried out for you by NIC/NIC Driver/ Opperating system and WINSOCK.

You will therefore gain a error corrected, in order data pipe between your client and server without needing to get involved in the underlying layers.

A word of warning though, if you mishandle using tcp you can cause issues with the underlyiong layers. I have seen some socket dlls do pretty weird things on the network if for example you put some data in the send buffer and then cxlose the socket before waiting for the send buffer to empty.
Avatar of Asta Cu
Greetings.

This question remains open today; perhaps just overlooked this or it just got lost in the volumes.  If you've been helped to resolve this, please accept the comment which helped you as the accepted answer to then grade and close so that others may benefit from this information as it migrates to our PAQ Database.  If more is needed, please update here via comments so that you can achieve your goal.

Your attention to finalizing this is very much appreciated.

Asta
bachar,

These questions are still open and our records show you logged in recently. Please resolve them appropriately as soon as possible. Continued disregard of your open questions will result in the force/acceptance of a comment as an answer; other actions affecting your account may also be taken. I will revisit these questions in approximately seven (7) days. Please note that the recommended minimum for an "Easy" question is 50 points.
https://www.experts-exchange.com/jsp/qShow.jsp?ta=progsoftgen&qid=20186509
https://www.experts-exchange.com/jsp/qShow.jsp?ta=progsoftgen&qid=20100277
https://www.experts-exchange.com/jsp/qShow.jsp?ta=progsoftgen&qid=20005648
https://www.experts-exchange.com/jsp/qShow.jsp?ta=progsoftgen&qid=11452298
https://www.experts-exchange.com/jsp/qShow.jsp?ta=progsoftgen&qid=11404058
https://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20141685
https://www.experts-exchange.com/jsp/qShow.jsp?ta=cplusprog&qid=20093290
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=20145151
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=20116236
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=20094685
https://www.experts-exchange.com/jsp/qShow.jsp?ta=networkgen&qid=20032846

EXPERTS: Please leave your thoughts on this question here.

Thanks,

Netminder
Community Support Moderator
Experts Exchange
Admin notified of user neglect. Force/accepted by

Netminder
Community Support Moderator
Experts Exchange