Lecture 9
Lecture 9
Lecture 9
SrcPort
16
DstPort
31
Data
Optional checksum
psuedo header + UDP header + data
TCP Overview
Connection- Full duplex
oriented Flow control: keep
Byte-stream sender from
app writes bytes overrunning receiver
TCP sends Congestion control:
segments keep sender from
app reads bytes overrunning network
Application process Application process
Write Read
bytes bytes
TCP TCP
Send buffer Receive buffer
Transmit segments
TCP Header
0 4 10 16 31
SrcPort DstPort
SequenceNum
Acknowledgment
Checksum UrgPtr
Options (variable)
Data
FIN
FIN
SN=X
SN=X
ACK=X+1
ACK=X+1
...
FIN
FIN
SN=Y
SN=Y
ACK=Y+1
ACK=Y+1
State Transition Diagram
Client Server
CLOSED CLOSED
Close/FIN ESTABLISHED
Close/FIN FIN/ACK
FIN_WAIT_1 CLOSE_WAIT
Close/FIN FIN/ACK AC FIN/ACK
ACK K Close/FIN
FIN_WAIT_1 +
CLOSE_WAIT FI
N/
AC FIN/ACK FIN_WAIT_2 AC CLOSING LAST_ACK
ACK K Close/FIN K
+
FI ACK Timeout after two ACK
N segment lifetimes
FIN_WAIT_2 /A CLOSING LAST_ACK FIN/ACK
C TIME_WAIT CLOSED
K
ACK Timeout after two ACK
segment lifetimes
FIN/ACK
TIME_WAIT CLOSED
TCP TIME_WAIT
Once a TCP connection has been
terminated (the last ACK sent) there is
some unfinished business:
What if the ACK is lost? The last FIN will
be resent and it must be ACK’d.
What if there are lost or duplicated
segments that finally reach the destination
after a long delay?
TCP hangs out for a while (2 * Max.
Segment Life) to handle these
situations.
Checking TCP states with netstat
$ netstat -a -n
Active Connections
http://www.firewall.cx
http://www.javasoft.com