Transmission Control Protocol (TCP)

Previous Lecture (4):

Today (lecture 6):

  • Intro to TCP
  • Connection establishment
  • more on sliding windows
  • TCP flow control

  • TCP Characteristics

    Byte Stream

    Provides the upper layer with a continuous byte stream. The application need not worry about creating or sending packets.  TCP numbers all the packets (sequence number) and makes sure that they are sent to the upper layer in the correct order.

    Duplex Connection

    Bi-directional streams. Hosts can send data to each other at the same time. Client and server are both sender and receiver.

    Reliable

    Takes care of error recovery. Application sees loss-less channels.

    Flow Control

    Indirectly determines the rate at which data should be sent.  Helps to prevent network congestion.


    Connection Establishment: Three-Way Handshake

    1. Client sends SYN packet to server.
    2. Server acknowledges SYN packet received from client and sends a new SYN packet to client.
    3. Client acknowledges  SYN packet received from server.

    SYN packet

    Ack

    The SYN flag is used to indicate that a sender is ready to transmit data. The acknowledgment is used to indicate that the receiver is ready to accept data. Since a TCP connection is bi-directional, two SYNs and two ACKs must be sent. However, the server SYN and the client ACK share the same packet. So we just need 3 packets (three-way handshake)
    to establish a TCP connection.

    Connection Termination

    Since each direction of the TCP connection can be closed at different times, the two FINs and two ACKs required to tear down the TCP connection may all travel in different packets. Therefore, up to four packets can be sent during this final phase of the TCP connection.

    TCP Sliding Window

    A duplex TCP connection uses up to four sliding windows. A sender window and receiver window is needed for both the client-to-server connection and the server-to-client connection.
    For now, we only need to focus on one of the two directional connections. Both the sender and receiver sliding windows in TCP inherit much of the functionality of the generic
    sliding windows presented in lecture 4. However TCP introduces some novelties.
     

    Receiver Window

    Novelty :  Receiver adds rcv_wnd  (receiver window size) to the ack it sends to the source.

    For some reason, the ack field  in TCP contains the next sequence number expected at the receiver rather than the sequence number of the
    acked packet.

    Sender Window

    Novelty : Sender sets snd_wnd dynamically for flow control purposes.

    rcv_wnd and snd_wnd stand for receiver and sender window respectively. snd_una stands for smallest unacked sequence number, and snd_nxt stands for the next
    sequence number to be sent. These last two variables differ from the corresponding terminology used by the textbook (LAR and LFS) by one.
     

    Sender Window Size: snd_wnd

    The limit imposed by rcv_wnd guarantees that the receiver buffer will not overflow.
    The limit imposed by snd_cwnd attempts to guarantee that the network buffers will not overflow.


    TCP Flow Control

    To Prevent Congestion

    Since the amount of data transiting the network is limited by snd_wnd, setting snd_wnd to be always less than the delay-bandwidth product will ensure
    that there is no congestion in the network.

    Problem: It is extremely hard for TCP to accurately measure the delay-bandwidth product of a connection. The bandwidth as well as the delay can be constantly
    changing, and packets might get lost due to factors that have nothing to do with congestion.

    Solution: Introduce a congestion window snd_cwnd that is continuously updated using feedback from the network. snd_cwnd tries to approximate itself to the new delay-bandwidth product  at each instant of time.

    A larger snd_cwnd will allow the sender to use more bandwidth. If RTT is the round-trip delay product, the maximum rate at which the sender can transmit data is snd_cwnd/RTT.

    Delay-Bandwidth Product Estimation

    This conservative approach tends to underestimate the delay-bandwidth product. This might lead to some bandwidth under-utilization, but it is always preferable to network congestion.

    TCP Tahoe

    Original TCP flow control algorithm. Proposed by Van Jacobson in 1988.