← all topics

13 · Transport services + multiplexing/demultiplexing

Slides 3-1 → 3-11 · HW3 P1

What the transport layer does

Transport vs network layer

Network layerTransport layer
Logical communication between hostsLogical communication between processes
Relies on and enhances network-layer services
Household analogy: 12 kids in Ann's house send letters to 12 kids in Bill's house.
• hosts = houses · processes = kids · app messages = letters in envelopes
• transport protocol = Ann and Bill, who collect and hand out letters to their siblings (mux/demux)
• network-layer protocol = the postal service (house to house)

TCP vs UDP (again, Ch3 version)

TCPUDP
Reliable, in-order deliveryUnreliable, unordered delivery
Congestion control"No-frills" extension of best-effort IP
Flow control
Connection setup
Neither provides: delay guarantees or bandwidth guarantees.

Multiplexing and demultiplexing

Multiplexing (at the sender)Demultiplexing (at the receiver)
Gather data from multiple sockets, add a transport header to each chunk (used later for demux)Use the header info to deliver each received segment to the correct socket

Memory hook: mux = many sockets → one network. Demux = one network → the right socket.

How demux works

|<------------ 32 bits ------------>|
|  source port #  |   dest port #    |
|        other header fields         |
|      application data (payload)    |

Connectionless demux (UDP)

Key fact: UDP segments with the same destination port but different source IPs and/or source ports all go to the same socket.
A UDP socket is identified by just (dest IP, dest port).

Slide example (3-9)

Server socket on port 6428. Client P3 on port 9157, client P4 on port 5775.

Segmentsource portdest port
P3 → server91576428
server → P364289157
P4 → server57756428
server → P464285775

The reply just swaps source and destination. Both clients' segments land in the server's one socket (port 6428).

Connection-oriented demux (TCP)

Slide example (3-11)

Server B, port 80. Three segments, all to B:80, go to three different sockets:

Segmentsource IP, portdest IP, portServer socket
from host AA, 9157B, 80P4
from host C (1st)C, 5775B, 80P5
from host C (2nd)C, 9157B, 80P6

A and C both use source port 9157, but the source IPs differ, so the 4-tuples differ. And C's two connections have the same IP but different source ports. Every 4-tuple is unique, so every segment finds its own socket.

Reply from the server to A: source = B, 80, dest = A, 9157.

The one-line difference
• UDP: demux by dest IP + dest port only → different senders can share one socket.
• TCP: demux by the 4-tuple → each connection gets its own socket.

Worked example: HW3 P1

Q: In the textbook figure (clients A and C talking to Web server B on port 80, like slide 3-11), what are the source and destination ports in segments going from the server back to the clients? What IP addresses are in the datagrams carrying them?

Why it works even though two clients use the same port number: TCP demuxes on the full 4-tuple, and A and C have different IPs.

Quick check

1. Transport layer vs network layer, in one line each? Network: logical communication between hosts. Transport: logical communication between processes (built on top of the network layer).
2. In the household analogy, who are Ann and Bill? The transport protocol: they collect letters from their siblings and hand out the ones that arrive (mux/demux). The postal service is the network layer.
3. What is demultiplexing? At the receiver, using header info (ports, and IPs) to deliver each received segment to the correct socket.
4. How does a UDP receiver pick the socket? How does a TCP receiver? UDP: by destination port (dest IP + dest port). TCP: by the 4-tuple (source IP, source port, dest IP, dest port).
5. Two different hosts send UDP segments to the same server port. Same socket or different? Same socket. UDP only looks at the destination port.
6. Two different hosts open TCP connections to the same server port 80. Same socket or different? Different sockets. Their source IPs differ, so the 4-tuples differ.
7. Client A (IP A, port 4000) sends to server B port 80. What are the ports and IPs on the server's reply? (HW3 P1 style) Source B, port 80 → destination A, port 4000. Just swap.
8. Name two services neither TCP nor UDP provides. Delay guarantees and bandwidth guarantees.

← 12 · Video, CDNs, sockets · all topics · 14 · UDP checksum →