Title: Chapter 5 Transport Layer: UDP, TCP
1Chapter 5Transport Layer UDP, TCP
- Professor Rick Han
- University of Colorado at Boulder
- rhan_at_cs.colorado.edu
2Announcements
- Netstat portion of Homework 3 on Web, due March
12 (two weeks) - Programming Assignment 2 due Friday March 22 by
midnight - Midterm March 14
- Only through Network Layer, Chapter 4
- OH changed today 445-545 due to BACTAC talk
- Next, transport layer
3Recap of Previous Lecture
- IP Multicast
- 1-gtN
- Link-State Multicast MOSPF
- Piggyback off of Dijkstras shortest path tree
- Distance-Vector Multicast DVMRP
- Reverse-path flooding to all nodes
- Reverse-path pruning
- Protocol Independent Multicast PIM
- For sparse wide-area trees
- Unicast to Rendezvous Point, RP then multicasts
- Tree built by explicit joins
- Internet Group Management Protocol (IGMP)
- How leaf nodes join a multicast group
4The Layered Network Stack
Internet Stack
Application Layer
Transport Layer (TCP/UDP)
Network Layer (IP)
Data Link Layer
Physical Layer
5UDP Unreliable Transport Protocols
- IP Provides Best-Effort unreliable datagram
delivery - User Datagram Protocol (UDP) provides best-effort
unreliable datagram delivery - Packets may be lost
- Due to congestion
- In routers
- At receiver and/or sender
- Due to fading
- Packets may be reordered
- Packets may be duplicated
6UDP (2)
- UDP Features
- Transport protocol above IP
- simply passes IP through to the upper
(application) layers - UDP Features
- Gives apps the option to send packets unreliably
- Useful for multicast apps
- Low delay transmission for interactive
text/audio/video - Minimal connection setup time
- Minimal connection state connectionless
- No congestion control blast away
- Build own application-level protocol on top of
UDP
7UDP (3)
16
32
Source Port
Dest. Port
UDP length
Checksum
UDP payload
UDP payload data
IP hdr
UDP hdr
- UDP Header
- Only 8 bytes! (vs. IP 20 bytes header)
- Source port for UDP sending process
- Dest port for UDP receiving process
- Length in bytes of UDP header payload
- Checksum over UDP header payload
8UDP (4)
- UDP Checksum calculation
- UDP creates a pseudo-header containing IP
header info - Doublechecks that the packet has the correct IP
address and UDP port
16
32
32-bit IP source address
32-bit IP destination address
Pseudo-Header
Protocol
UDP length
0
Source Port
Dest. Port
UDP Header
UDP length
Checksum
- Discarded if checksum fails
UDP payload data
9UDP Multiplexing/Demultiplexing
Host 1
Host 2
UDP Port 5100
UDP Port 5200
UDP Port 6001
UDP Port 433
- IP layer inspects Protocol field UDP
- Sends to buffer of waiting UDP process with
matching port
IP
IP
Eth. MAC
Eth MAC
Phys.
Phys.
10TCP Transmission Control Protocol Reliable
Delivery
- TCP provides
- Reliable delivery of packets, AND
- Stream or in-order delivery
- Also, full-duplex service
- Why TCP, when we can build reliable protocols on
top of UDP? - Many applications require reliable in-order
delivery of packets - Web pages, email, file transfer,
- Why should each application reinvent the wheel?
- Can concentrate expert knowledge into building
one reliable protocol provided to every
application
11TCP (2)
- TCP is a true transport protocol, above IP
- TCP Features
- Flow control
- Congestion control
- Connection setup
- Connection state machine
- Reliability, at the cost of some delay
- Achieves reliability by
- Retransmission of a segment after a timeout or
duplicate ACK - Sliding window with sequence s
TCP payload
IP hdr
TCP hdr
12TCP (3)
- TCP Header
- 20 bytes
- Source port for TCP sending process
- Dest port for TCP receiving process
- 32-bit Sequence (host is sender)
- 32-bit ACK (host is receiver ACKing data sent
by other endpoint)
16
32
Source Port
Dest. Port
32-bit Sequence
32-bit Acknowledgement
Window Size
Flags
Checksum
Urgent Pointer
13TCP (3)
- TCP Header
- Flags
- SYN synchronize sequence s to initiate
connection - FIN sender is finished sending data
- RST reset the connection,
- More
16
32
Source Port
Dest. Port
32-bit Sequence
32-bit Acknowledgement
Window Size
Flags
Checksum
Urgent Pointer
14TCP (4)
- TCP Header
- Flow control window size Receiver advertises how
many bytes it is willing to accept into its
buffer - Checksum computed over TCP header payload
- Similar to UDP, prepends an IP Pseudo-Header
- Urgent Pointer points to where there is emergency
data in payload
16
32
Source Port
Dest. Port
32-bit Sequence
32-bit Acknowledgement
Window Size
Flags
Checksum
Urgent Pointer
15TCP (5)
- TCP Header
- Variable-sized (not just 20 bytes), can have
Options after the Urgent Pointer field - Signalled in Flags field
- Most common option Maximum Segment Size (MSS)
exchanged during setup
16
32
Source Port
Dest. Port
32-bit Sequence
32-bit Acknowledgement
Window Size
Flags
Checksum
Urgent Pointer
16High-Level TCP Characteristics
- Protocol implemented entirely at the ends
- Fate sharing
- Protocol has evolved over time and will continue
to do so - Nearly impossible to change the header
- Uses options to add information to the header
- Change processing at endpoints
- Backward compatibility is what makes it TCP
17Connection Setup
- A and B must agree on initial sequence number
selection - Use 3-way handshake
A
B
SYN Seq A
SYNACK-A Seq B
ACK-B
18Connection Setup (2)
- Why a three-way handshake?
- Three-way handshake is necessary and sufficient
for unambiguous setup/teardown even under
conditions of - Loss
- Duplication
- Delay
19Two-Way Handshake
Handshake pictures courtesy of UMass Amherst
20Two-Way Handshake Old Accepts
21Two-Way Handshake Duplicate Requests
22Two-Way Handshake Failure
23Two-Way Handshake W/ Timers
243-way Handshake Unique IDs
Server (passive)
Client (active)
- Both sender and receiver choose unique IDs to
label their (x,y) connection - x chosen by Sender, y by receiver
- Prevents Failure scenario in two-way handshakes
w/o timers