Today, we will look at a TCP Reliable Stream Service that applies ARQ flow control. TCP provides a reliable service that is error free, no duplication, and in the order produced by sender. It uses selective repeat ARQ protocol, but it varies in several key aspects. One difference is that the use of information doesn't consist of a sequence of blocks, but instead consists of a stream of bytes. In TCP, application layer writes bytes into a sender buffer through a socket, but boundaries between multiple bytes are not preserved. TCP may decide to break a stream into multiple ones or merge multiple small bytes into a single one. TCP was designed to deliver a connection-oriented service of IP that itself offers connection packet transfer service. In IP network, each packet that is transmitted between a sender and receiver can traverse a different path and packets can arrive with errors or loss, or even out-of-order. Packets can arrive after very long delays, as well. In the internet, it is possible for older segments from previous connections to arrive at our receiver, so detecting and eliminating duplicates is more complicated. Therefore, it is more complicated than the ordinary ARQs that operate in wire-like environment. TCP deals with this problem by using long, 32 bits sequence number and by establishing randomly selected initial sequence numbers during connection set up. At any time, the receive is accepting sequenced numbers from a much smaller window. So likelihood of accepting a very old message is very low. TCP uses a Three-Way Handshake to set up a TCP connection and establish the initial sequence number. Each connection uniquely identified by Sender IP address, Sender TCP Port number, Receiver IP Address and Receiver TCP Port number. We will take a deeper look at the Three-Way Handshake in a later course. Today, we focus on TCP flow control. There is a useful network protocol analyzer tool called Wireshark. Its former name is Israel. It lets you see what is happening on your network at a microscopic level, where you can see detailed information on packets and the protocols. In this example, it shows the first set of details, including the connection identifier on the initial sequence number from the client. We will see more in other posts in the future. TCP uses a sliding window mechanism that increments a form of selective repeat ARQ using acknowledged messages and a timer mechanism. The sender window contains four pointers. S last points to the oldest byte that has any yet acknowledged. S recent points to the last byte that has been transmitted, but another yet acknowledged. S last + Ws minus one points to the highest number of byte that it can be accepted from the application. S last + Wa minus one points to the highest number of byte that can be transmitted. Please note that the Wa here is advertised to the window size. Receiver window contains four pointers too. R last points to the oldest byte, that has been reader by the destination application. R next points to the location of the highest numbered byte that hasn't been yet received correctly. R new points to the location of the highest numbered byte that has been received correctly. Receiver can buffer at most Wr bytes and at any given time, so, R last + Wr minus one is the highest numbered byte that the receiver is prepared to accept. Wr here is the received window size. In TCP Data Exchange, the TCP sender arranges a consecutive string of bytes into segments. So to see the performance selective repeat the ARQ function. The segment contains a sequence number that corresponds to the number of the first byte in the string that is being transmitted. This is very different from the conventional ARQ protocol. TCP separates the Flow Control function from the acknowledgement function. The Flow Control function is implemented and advertises a window field in a second header. To advertised window size is given by Wa equals to Wr minus the difference between R new and R last. Therefore, TCP sender is obligated to keep the number outstanding bytes below the window size, Wa. In TCP, the transmitter sets a timer each time a segment is transmitted. The timeout cannot be too long nor be too short. Indeed, it depends on the round trip time, RTT. But unlike in a wire-like situation, in Internet, RTT is highly variable. In practice, TCP uses adaptive estimation of RTT. It measures RTT continuously, each time an acknowledgement is received. The RTT variation is also estimated as a standard deviation of the estimated RTT. The timeout is set to this estimated RTT plus the estimated RTT variation multiplied K. K is a suitable constant. In practice, it takes an approximate estimation of the deviation. As a summary, TCP flow control is based on selective repeat ARQ, yet varies in several key aspects.