WWW

How the Internet Works, Chapter 9
The Transport Layer: Network Reliability and TCP

posted in: How the Internet Works | 0

The Link and Internet layers do not ensure actual delivery of data. Frames can get lost in transit, and frames can arrive corrupted. So, the process of moving data between two IP addresses is not entirely reliable. The Transport Layer is responsible for network reliability.

Reliability

“Network reliability” can refer to different aspects of a network’s reliability:

  • Whether messages can be guaranteed to reach their destination, and in the order they were sent
  • How quickly messages make it to their destination
  • Whether a message gets to its destination without being viewed or tampered with

The Transport Layer addresses the first two of these. The Application Layer handles the last one.

TCP

The Transmission Control Protocol (TCP) is a protocol that ensures reliability, and is the most common transport layer protocol in use.

TCP ensures that messages reach their destination in the proper order. It also uses congestion avoidance and flow control to prevent traffic bottlenecks at chokepoints along the traversal path. And finally, it serves as a platform for Transport Layer Security, or TLS, a cryptographic protocol that defines security measures that prevent unauthorized access to data.

TCP PDUs are called segments. A TCP segment looks like this:

    1. Source port.
    2. Destination port.
    3. Sequence number. Used to determine the order of segments sent.
    4. Acknowledgement number. Used to identify lost segments.
    5. Header length. The header can include a variable number of options, so the more options a header uses, the larger its length value.
    6. Three bits reserved for future use.
    7. Nine bits for flags. Used for congestion management (CWR, ECE), handshaking (SYN, ACK, RST, FIN) priority management (PSH, URG) and security (NS).
    8. Window size. Used for flow control.
    9. Checksum. Checks for errors in transmission.
    10. Urgent pointer. Pointer to urgent data, used if the URG flag is set.
    11. Options.
    12. Payload (an Application Layer PDU).

Handshaking

TCP is a connection-based protocol. This means that it sets up a connection that two nodes use to transfer a segment from the sender to the receiver. TCP establishes this connection through a process called a handshake. This process has three steps, so it’s a three-way handshake.

Three-way handshaking uses the SYN and ACK flags to set up a connection. The process has these steps:

    1. A client sends a segment to a server (called the *SYN segment*), with a newly generated sequence number. This segment has the SYN (synchronize) flag set. The SYN flag tells the receiver that the sequence number in the segment is the starting sequence number.
    2. The server sends a segment (called the *SYN/ACK segment*), also with a newly generated sequence number for traffic going the other way, to the client, with both the SYN and ACK (acknowledge) flags set. The acknowledgement number in this segment is the sequence number in the SYN segment plus 1.
    3. The client sends a segment (called the *ACK segment*) with the ACK flag set. The acknowledgement number in this segment is the sequence number in the SYN/ACK segment plus 1. Now, each end has the other’s starting sequence number, and the handshaking is complete.

If this process fails, the end that notices the failure sends a segment with the RST (reset) flag set, and the process starts over again.

The next article explains how TCP guarantees message delivery.