Lecture06 Part1
Lecture06 Part1
Lecture 6 (Part 1)
TCP services: Flow Control, Congestion Control
Kaushik P. Seshadreesan, Fall 2024
Partially adapted from Kurose & Ross slides: http://gaia.cs.umass.edu/kurose_ross/ppt.htm
Partially adapted from prior year slides by Kostas Pelechrinis and Amy Babay
Partially adapted from JHU Computer Networks course: https://github.com/xinjin/course-net
network network
clientSocket.connect("hostname, connectionSocket =
"port number"); welcomeSocket.accept();
10/07/2024 TELCOM 2310 Fall 2024: Lecture 6 10
Connection Parameters: Initial Sequence Number
• Sequence number for the very first byte
• Why not just use ISN = 0?
– Practical issue
• IP addresses and port #s uniquely identify a connection
• Eventually, though, these port #s do get used again; small chance an old
packet is still in flight
• Also, others might try to spoof your connection
– Why does using ISN help?
• Hosts exchange ISNs when establishing connection
• Three-way handshake to A B
establish connection
– Host A sends a SYN (open;
“synchronize sequence numbers”)
to host B
– Host B returns a SYN
acknowledgment (SYN ACK)
– Host A sends an ACK to
acknowledge the SYN ACK
Sequence number
Flags:
SYN Acknowledgment
ACK HdrLen 0 Advertised window
Flags
FIN
RST Checksum Urgent pointer
PSH
URG Options (variable)
CWR
ECE
Data
Sequence number
Flags:
SYN – connection setup Acknowledgment
ACK – contains valid ack HdrLen 0 Advertised window
Flags
FIN – connection teardown
RST – connection teardown Checksum Urgent pointer
PSH – pass data up immediately
URG – data marked urgent Options (variable)
CWR – congestion control
ECE – congestion control
Data
Sequence number
Acknowledgment
Length of header in 32-bit words HdrLen 0 Flags Advertised window
Unused Checksum Urgent pointer
Options (variable)
Data
B’s Initial Sequence Number can be different from A’s Initial Sequence Number: they
each choose randomly
10/07/2024 TELCOM 2310 Fall 2024: Lecture 6 17
Step 3: Host A’s ACK of B’s SYN-ACK
connect() listen()
A
time
• Finish (FIN) to close and receive remaining bytes
– FIN occupies one byte in the sequence space Connection
now closed
• Other host acks the byte to confirm Connection
now half-closed
• Closes A’s side of the connection, but not B’s
– Until B likewise sends a FIN
– Which A then acks TIME_WAIT:
B will retransmit FIN
if ACK is lost
10/07/2024 TELCOM 2310 Fall 2024: Lecture 6 20
Closing a TCP Connection: Abrupt Termination
A
time
• A sends a RESET (RST) to B
– E.g., because application process on A crashed
• That’s it
– B does not ack the RST
– Thus, RST is not delivered reliably, and any data in flight is lost
– But: if B sends anything more, will elicit another RST
A B
100 Mbps
A3 B3
• How can we avoid congestion?
– A1, A2, A3 need to collectively send at a rate of at most 100 Mbps
– But none of them knows that the bottleneck link is 100 Mbps, how many
other senders there are, or how fast the others want to send…
10/07/2024 TELCOM 2310 Fall 2024: Lecture 6 30
Congestion Control Challenges
And reality looks more like this:
1Gbps
1Gbps
600Mbps
• High-level answers:
– Assume loss implies congestion
– Maintain a window that shrinks whenever congestion is detected
(and increases when no congestion is detected)
sending rate
– Lost segment: (timeout or 3 duplicate X