Title: TCP Connection Management, State Transition Diagram
1TCP Connection Management, State Transition
Diagram
EECS 325/425, Fall 2005 October 5
2Quiz 1 Information
- All materials covered (including todays lecture)
- 3 problems
- 20 points
- 10 of final grade
3Remember the fields in TCP segment?
32 bits
URG urgent data (generally not used)
counting by bytes of data (not segments!)
source port
dest port
sequence number
ACK ACK valid
acknowledgement number
head len
not used
Receive window
F
S
R
P
U
A
PSH push data now (generally not used)
bytes rcvr willing to accept
checksum
Urg data pnter
RST, SYN, FIN connection estab (setup,
teardown commands)
Options (variable length)
application data (variable length)
Internet checksum (as in UDP)
4TCP Connection Establishment
- Three way handshaking
- Step 1 client host sends TCP SYN segment to
server - specifies initial seq
- no data
- SYN bit
- Step 2 server host receives SYN, replies with
SYNACK segment - server allocates buffers
- specifies server initial seq.
- SYN bit ACK bit
- Step 3 client receives SYNACK, replies with ACK
segment, which may contain data - ACK bit
- Recall TCP sender, receiver establish
connection before exchanging data segments - initialize TCP variables
- seq. s
- buffers, flow control info (e.g. RcvWindow)
- client connection initiator
- Socket clientSocket new Socket("hostname","p
ort number") - server contacted by client
- Socket connectionSocket welcomeSocket.accept()
5TCP Connection Establishment
6TCP Connection Teardown
- 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.
closed
7TCP Connection Teardown
- Step 3 client receives FIN, replies with ACK.
- Enters timed wait - will respond with ACK to
received FINs - Step 4 server, receives ACK. Connection closed.
- Note with small modification, can handle
simultaneous FINs.
client
server
close
FIN
ACK
close
FIN
ACK
timed wait
closed
closed
8TCP Connection Typical Lifetime
TCP server lifecycle
TCP client lifecycle
9TCP State Transition Diagram
- More complicated than previous slide
- Different roles (client and server)
- Need to handle exceptions, losses
- Timing (which closes first?)
- etc
- Let us draw the diagram