Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If a tcp program A send two data packets to another TCP program B, packet 1: sequence number from 1000 to 2000; packet 2: seq number from 2000 to 3000.

Generally B should reply with 2 ACKs, one for acknowledging packet 1 and the other for packet 2. Now, if only the second ACK is received by A, will A still wait for the first ACK or not?

I know TCP is byte-oriented stream protocl. so A should not wait for the first ACK, is it right? In theory, it is like this, how about the real implemented TCP stack?

BTW, I have a pecular question. If A send to B an ACK to with ack seq number 3001(this is for acknowledging packet 2). But someone in the middle modify the ack seq number to 2501, that's being said, B acknowledge a half TCP packet. Then will A retransmit from byte which corresponds to seq 2000 or 2501?

share|improve this question

closed as not constructive by Breakthrough, soandos, Brad Patton, Tanner, Ƭᴇcʜιᴇ007 Jun 4 '13 at 14:58

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

3 Answers 3

up vote 2 down vote accepted

No, TCP applies a "sliding window" mechanism to reduce the number of acknowledgments needed.

A nice visualization and explanation: http://histrory.visualland.net/tcp_swnd.html

share|improve this answer
    
This is theory, how about the practical, I mean the TCP stack implementation. And I have a pecular question, pls check my updated question. thanks! –  misteryes May 27 '13 at 12:38
2  
@misteryes This is also real-world behavior. If you want to see the "practical behavior", install a monitor like Wireshark or consult one of the open-source TCP stacks (e.g. Linux). –  Lekensteyn May 27 '13 at 14:22
add comment

TCP will ack sequence numbers, not packets. So even without "someone in the middle", Program A can ack just a fraction of a received packet (i.e. socket doesn't have enough buffer space for all of the packet.) In your example, 2501 will then be re-transmitted by Program B.

TCP also supports Selective Ack, so that just a missing segment (in the seq number space) needs to be transmitted

share|improve this answer
    
+1 This answer is wonderful. Right on the spot with the most important scentence at the beginning. I wonder why it has (had) no upvotes. –  artistoex Jun 28 '13 at 16:09
add comment

B offers a 'window' (of buffer space) to A in its acknowledgement. A need not wait for a specific acknowledgement before send subsequent packets so long as it doesn't exceed B's current window.

Caveat: Much simplified, both in the interest of brevity and due my somewhat limited understanding of the protocol. RFC: 813 - WINDOW AND ACKNOWLEDGEMENT STRATEGY IN TCP talks about this very technique.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.