Transport Layer
May 2026
Services
- provide logical communication between applications running on different hosts.
- Sender breaks application messages into
segmentsto pass to the network layer. - The receiver reassembles
segmentsinto messages, and passes them to the application layer.
The transport layer focuses on communication between processes, wheras the network layer focuses on communication between hosts.
Transport layer actions
Sender
- passed an application layer messages
- construct a segment and pass it to IP
Receiver
- receives a segment from IP
- extract the application-layer message and demultiplex it if needed
(De)Multiplexing
When the host receives IP datagrams, they contain:
- source IP
- destination IP Each datagram includes a transport-layer segment including
- source port
- destination port
This information can be used to determine which socket to direct the segment to.
Connectionless
With UDP, demultiplexing can be done by reading the destionation port number in the segmen.
IP/UDP datagrams with the ame destination port but a different source IP/source port will be directed to the same socket at the receiving host
Connection-Oriented
a TCP socket is identified by:
- source IP
- source port number
- destination ip address
- destination port number
a demux receiver uses all four values to direct a segment to the appropriate socket, as such a server may support simultaneous TCP sockets each one being identified by its own 4-tuple.
Summary
UDP only demultiplexes using the destination port number, wheras TCP can be demultiplexed using a 4-tuple
(de)multiplexing can happen at all layers
TCP
- Reliable in-order delivery
- Congestion control
- Flow control
- Connection setup
UDP (Connectionless Transport)
- Unreliable unordered delivery
- Bare bones
- Segments may be lost or delivered out of order
- Less RTT delay since no connection establishment
- Simple protocol, no connection state at sender or receiver
- Small header size
- No congestion control
UDP is notably used by DNS, HTTP/3 (as part of QUIC) and for streaming
UDP sender actions:
- passed an application layer message
- determines UDP segment header fields values
- creates the UDP segment
- passes the segment to IP
UDP receiver actions:
- receives segment from IP
- checks UDP checksum header value
- extracts application layer message
- demultiplexes message up to application via socket
UDP contains a checksum in the segment header to detect errors
Internet Checksum
Sender:
- treat contents of UDP segment including the header fields and IP addresses as a sequence of 16-bit integers
- The checksum is a one’s complement sum of segment content
- Checksum value is then inserted into the UDP checksum field
Receiver:
- computes checksum of received segment
- check if computed checksum equals checksum field value
Since the internet checksum is based on pure addition, it is a weak checksum and data corruption can occur in such a manner that the checksum matches anyway.
Principles of reliable data transfer
- The sender and receiver CANNOT determine the state of the other without sending a message
- The underlying channel may flip bits in the packet
There is a way to ensure reliable data transfer
- ACKs (acknowledgement that the data was received intact)
- NAKs (negative acknowledgement - the data is corrupted)
- sender retransmits the packet on receipt of NAK
However, the channel can also corrupt NACKs/ACKs, so what do we do?
- Sender adds a sequence number fo each packet
- receiver discards duplicate packets
- sender sends a packet and waits for the response
However, the channel can also drop packets, so what do we do?
- wait a “reasonable” amoun tof time for an ACK, if no ACK is received, retransmit
TCP
- point-to-point (one sender, one receiver)
- reliable, in-order byte stream
- full duplex data
- cumulative ACKs
- pipelining (congestion and flow control)
- connection-oriented (handshaking)
- flow controlled (sender will not overwhelm receiver)
Timeout
- Timeout needs to be longer than RTT, since RTT varies the RTT must be sampled
- esimtated RTT is tracked via an Exponential Weighted Moving Average (EWMA)
- timeout interval is the estimated RTT with a safety margin
- a larger variation in the estimate will warrant a larger safety margin
TCP Sender
- Create a segment with seq #
- seq # is byte-stream number of first data byte in segment
- start timer if not already running
on timeout, retransmit the segment that caused timeout and restart timer
on ACK receive - if ACK acknowledge previously unACKed segments, update what is known to be ACKed, start timer if there are still unACKed segments (timer tracks time since unACKed segment)
TCP handshake
A two-way handshake isn’t used as it can lead to half open connections or duplicate data, so a three-way handshake is used instead
- Client picks an init seq number, sends TCP SYN
- Server picks an init seq number, sends TCP SYNACK
- Client receives a SYNACK, sends ACK for SYNACK (may contain client to server data)
- Server now knows the client is live