Transmission Control Protocol (TCP)


Transmission Control Protocol (TCP) works at the Transport layer to provide connection-oriented, guaranteed communication using acknowledgements to ensure that delivery has occurred.

  • if packets are missing, they can be retransmitted
  • can be used for unicast transmission only
  • takes data from the application layer as a stream of bytes and divides it into segments
    • each is given a header
    • TCP segments become the payload of the underlying IP datagrams
  • IP transmits a stream of application data as a series of packets
    • Any given packet could be damaged or fail to arrive due to faults or network congestion
    • TCP provides several mechanisms to overcome this lack of reliability
  • described as a connection-oriented protocol because it performs a TCP handshake:
    • Establishes a connection between the sender and recipient using a handshake sequence of SYN, SYN/ACK, and ACK packets
    • Assigns each packet a sequence number so that it can be tracked
    • Allows the receiver to acknowledge (ACK) that a packet has been received
    • Allows the receiver to send a negative acknowledgement (NACK) to force retransmission of a missing or damaged packet
    • Allows the graceful termination of a session using a FIN handshake

TCP Header

  • main drawback is that this connection information requires numerous header fields to maintain state information
    • adds to the size of each packet
      • header size is 20 bytes or more

Main Header Fields

FieldExplanation
Source portTCP port of sending host.
Destination portTCP port of destination host.
Sequence numberThe ID number of the current segment (the sequence number of the last byte in the segment).

This allows the receiver to rebuild the message correctly and deal with out-of-order packets.
Ack numberThe sequence number of the next segment expected from the other host (that is, the sequence number of the last segment received +1). Packets might be out of order because they are delayed, but they could also be lost completely or arrive in a damaged state. In the first case, the lack of acknowledgment results in the retransmission of data and, in the second case, a Negative Acknowledgment (NAK or NACK) forces retransmission.
Data lengthLength of the TCP segment.
FlagsType of content in the segment (ACK, SYN, FIN, and so on).
WindowThe amount of data the host is willing to receive before sending another acknowledgment. TCP’s flow control mechanism means that if it is getting overwhelmed with traffic, one side can tell the other to slow the sending rate.
ChecksumEnsures validity of the segment. The checksum is calculated on the value of not only the TCP header and payload but also part of the IP header, notably the source and destination addresses. Consequently, the mechanism for calculating the checksum is different for IPv6 (128-bit addresses) than for IPv4 (32-bit addresses).
Urgent PointerIf urgent data is being sent, this specifies the end of that data in the segment.
OptionsAllows further connection parameters to be configured. The most important of these is the maximum segment size. This allows the host to specify how large the segments it receives should be, minimizing fragmentation as they are transported over data link frames.

Uses

  • used when the application protocol cannot tolerate missing or damaged information
    • E.g.,
      • HyperText Transfer Protocol (HTTP)/HyperText Transfer Protocol Secure (HTTPS)
        • used to deliver web pages and other resources
        • secure version uses encryption to authenticate the server and protect the information that is being transmitted
        • single missing packet would cause this process to fail completely
      • Secure Shell (SSH)
        • used to access the command-line interface of a computer from across the network
        • uses encryption to authenticate the server and user and protect the information that is being transmitted
        • would fail if a data packet is not received