2

It is my understanding that when you open a tcp connection to send data the tcp layer on the receiving end holds on to all the packet until the transmission is complete, then sends all the data up to the application.

From wikipedia on tcp:

Due to network congestion, traffic load balancing, or other unpredictable network behavior, IP packets can be lost, duplicated, or delivered out of order. TCP detects these problems, requests retransmission of lost data, rearranges out-of-order data, and even helps minimize network congestion to reduce the occurrence of the other problems. Once the TCP receiver has reassembled the sequence of octets originally transmitted, it passes them to the receiving application. Thus, TCP abstracts the application's communication from the underlying networking details.

But, when you download a large file, the browser keeps track, knows how much data has been sent, knows how fast it is being transmitted, etc. How does it know all of that if the transfer hasn't been completed and therefore hasn't been passed to the receiving application?

What am I missing here?

1 Answer 1

1

What you are missing is that this doesn't require that all the data be received before passing them to the receiving application. It simply requires that it has reassembled the sequence of the data so far.

In other words, if it is missing a segment or a segment is corrupt, it will request a re-transmission of that segment and wait to receive it before passing along the data.

In simple terms, imagine if my computer requested data that would arrive in 10 segments. It receives segments as follows: 1, 2, 3, 5, 6, 7, 4, 8, 10.

As it receives the segments, it can pass along 1-3 directly to the application. Since 4 is out of order, it must wait to pass along 5-7 until it also receives 4. It can then pass along 8, but it doesn't receive 9 (or is corrupt), so must wait to pass along 10 until it can request re-transmission of segment 9 and receive it as well.

2
  • So does that mean that an application can receive only half a request?
    – Shane
    Dec 3, 2014 at 14:34
  • Handling the data it receives is the job of the applicatin, not TCP. Whether the application can do anything with partial data would be entirely dependent on the application. For instance, consider how a web browser deals with images (either on a slow connection or a very large image). An interlaced image will display whole with increasing resolution, a non-interlaced image will display the top and then more as it downloads. Or consider a video stream, which can play while still downloading/buffering.
    – YLearn
    Dec 3, 2014 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .