Sub topic 1
What the Transport Layer Adds to IP
Prerequisites
Assume you know that an IP address identifies a network interface and that IP carries packets between hosts. This chapter focuses on how applications use transport protocols above IP.
What the Transport Layer Adds to IP
IP provides best-effort delivery. It can lose, duplicate, delay, or reorder packets. It also delivers packets to a host, not to a particular application.
The transport layer adds communication between application processes. It provides:
- Ports, which identify applications on a host.
- Multiplexing, which lets many applications share one IP address.
- Optional delivery guarantees, such as ordering and retransmission.
- Checksums for detecting corrupted data.
TCP and UDP are transport-layer protocols. They place transport headers around application data before IP carries it.
Ports, Sockets and Multiplexing
A port is a 16-bit number from 0 through 65,535. A server listens on a known port, while a client normally receives a temporary, or ephemeral, port.
A socket is an operating-system interface for network communication. For a TCP connection, the two endpoints are identified by a four-tuple:
(source IP, source port, destination IP, destination port)
This allows one server port, such as TCP port 443, to support many clients at the same time. The operating system examines packet addresses and ports, then delivers each payload to the correct socket.
Connectionless versus Connection-oriented Delivery
A connectionless protocol sends each message independently. UDP does not establish a session, guarantee delivery, or reorder lost messages. Each datagram includes its destination, so the receiver can process it without a prior handshake.
A connection-oriented protocol first establishes shared state. TCP uses a handshake, tracks sequence numbers, acknowledges received bytes, retransmits missing data, and presents an ordered byte stream. These guarantees require extra packets, memory, and processing.
UDP: Independent Datagrams with a Minimal Header
UDP preserves message boundaries. One sendto call produces one datagram, subject to size limits. The UDP header is only 8 bytes:
| Field | Purpose |
|---|---|
| Source port | Identifies the sender’s application |
| Destination port | Identifies the receiver’s application |
| Length | Gives the header-plus-data size |
| Checksum | Detects corruption |
A checksum detects many transmission errors, but it does not recover a lost datagram. An application that needs retries must implement them itself.
Exercise
Which transport protocol fits a telemetry message where occasional loss is acceptable and low delay matters?
Show answer
UDP, because it avoids connection setup and retransmission overhead. The application must tolerate loss or add its own recovery.