Lecture 7. TCP Connection Management. Opening a TCP Connection Closing a TCP Connection Special Scenarios State Diagram. TCP Connection Management. Recall: TCP sender, receiver establish “connection” before exchanging data segments initialize TCP variables: seq. #s
Recall:TCP sender, receiver establish “connection” before exchanging data segments
Socket clientSocket = new Socket("hostname","port number");
Socket connectionSocket = welcomeSocket.accept();
Step 1:client host sends TCP SYN segment to server
Step 2:server host receives SYN, replies with SYNACK segment
Step 3: client receives SYNACK, replies with ACK segment, which may contain data
Closing a connection:
client closes socket:clientSocket.close();
Step 1:client end system sends TCP FIN control segment to server
Step 2:server receives FIN, replies with ACK. Closes connection, sends FIN.
Step 3:client receives FIN, replies with ACK.
Step 4:server, receives ACK. Connection closed.
Note:with small modification, can handle simultaneous FINs.
When aida initiates the data transfer (starting with SeqNo=15322112355), mng will reject all data.
(1) X sends a FIN to Y (active close)
(2) Y ACKs the FIN,
(at this time: Y can still send data to X)
(3) and Y sends a FIN to X (passive close)
(4) X ACKs the FIN.
1 mng.poly.edu.telnet > aida.poly.edu.1121: F 172488734:172488734(0) ack 1031880221 win 8733
2 aida.poly.edu.1121 > mng.poly.edu.telnet: . ack 172488735 win 17484
3 aida.poly.edu.1121 > mng.poly.edu.telnet: F 1031880221:1031880221(0) ack 172488735 win 17520
4mng.poly.edu.telnet > aida.poly.edu.1121: . ack 1031880222 win 8733
c.Causes/costs of congestion scenario 2
costs” of congestion:
Two broad approaches towards congestion control:
How does sender perceive congestion?
Long-lived TCP connection
When should the exponential increase switch to linear?
A: When CongWin gets to 1/2 of its value before timeout.
➜ L = 2·10-10 Wow
New versions of TCP for high-speed needed
connection 2TCP Fairness
Two competing sessions:
Fairness and UDP
Research area: TCP friendly
Fairness and parallel TCP connections
Q:How long does it take to receive an object from a Web server after sending a request?
Ignoring congestion, delay is influenced by:
WS/R > RTT + S/R: ACK for first segment in window returns before window’s worth of data sent
delay = 2RTT + O/R
Now suppose window grows according to slow start
Will show that the delay for one object is:
where P is the number of times TCP idles at server:
- where Q is the number of times the server idles if the object were of infinite size.
- and K is the number of windows that cover the object.
Calculation of Q, number of idles for infinite-size object, is similar
For low bandwidth, connection & response time dominated by transmission time.
Persistent connections only give minor improvement over parallel
For larger RTT, response time dominated by TCP establishment & slow start delays. Persistent connections now give important improvement: particularly in high delaybandwidth networks.