13 · Transport services + multiplexing/demultiplexing
Slides 3-1 → 3-11 · HW3 P1
What the transport layer does
- Provides logical communication between application processes on different hosts. "Logical" = it looks to the processes like they're directly connected, even though they're not.
- Transport protocols run only in end systems, not routers:
- Sender: breaks app messages into segments and passes them to the network layer.
- Receiver: reassembles segments into messages and passes them up to the app.
Transport vs network layer
| Network layer | Transport layer |
|---|---|
| Logical communication between hosts | Logical communication between processes |
| Relies on and enhances network-layer services |
• 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)
| TCP | UDP |
|---|---|
| Reliable, in-order delivery | Unreliable, 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
- The host receives IP datagrams. Each has a source IP and destination IP, and carries one transport-layer segment.
- Each segment has a source port # and destination port # (16 bits each, the first 32 bits of the TCP/UDP header).
- The host uses IP addresses + port numbers to send the segment to the right socket.
|<------------ 32 bits ------------>| | source port # | dest port # | | other header fields | | application data (payload) |
Connectionless demux (UDP)
- When you create a UDP socket, you give it a host-local port #.
- When you send a datagram, you must specify the destination IP + destination port.
- The receiving host checks only the destination port # and sends the segment to the socket with that port.
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.
| Segment | source port | dest port |
|---|---|---|
| P3 → server | 9157 | 6428 |
| server → P3 | 6428 | 9157 |
| P4 → server | 5775 | 6428 |
| server → P4 | 6428 | 5775 |
The reply just swaps source and destination. Both clients' segments land in the server's one socket (port 6428).
Connection-oriented demux (TCP)
- A TCP socket is identified by a 4-tuple: source IP, source port, dest IP, dest port.
- The receiver uses all four values to pick the socket.
- A server can have many TCP sockets at once, one per connected client, each with its own 4-tuple. (That's the new socket
accept()makes in topic 12.)
Slide example (3-11)
Server B, port 80. Three segments, all to B:80, go to three different sockets:
| Segment | source IP, port | dest IP, port | Server socket |
|---|---|---|---|
| from host A | A, 9157 | B, 80 | P4 |
| from host C (1st) | C, 5775 | B, 80 | P5 |
| from host C (2nd) | C, 9157 | B, 80 | P6 |
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.
• 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?
- Ports: just swap the client's request. Source port = 80 (the Web server). Dest port = the client process's port. In the textbook figure that's 26145 for A, and 7532 and 26145 for C's two connections (the slide's version uses 9157 and 5775).
- IP addresses: source IP = B (the server), dest IP = A or C (whichever client).
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 →