Title: TCP Overview TCP Connection Establishment and Termination
1TCP OverviewTCP Connection Establishment and
Termination
2TCP Properties
- Connection oriented
- Byte stream based
- Reliable
- Provides sequenced delivery
3TCP Header
4Quiz
- There is a header size field in TCP header, but
not in UDP header. Why? - TCP does not interpret the data payload. How can
an application know where a record begins and
where it ends? - Can multiple TCP sockets have the same local port
number? - Why is the length of the entire packet not in the
TCP header? - TCP Timers typically fire at 500 ms ticks. Why?
5An Example
- Active open/close Performed by the side that
sends the first SYN/FIN. - Passive open/close The other side
- MSS option limits the size of TCP payload from
other end - only appears in SYN. Default 536
- MSS40 must be lt MTU (Ethernet payload). Why?
1 0.000000 192.168.10.201
192.168.10.202 TCP 32991 gt 3000 SYN
Seq3765803341 Len0 MSS1460 2 0.000188
192.168.10.202 192.168.10.201 TCP
3000 gt 32991 SYN, ACK Seq3834295109
Ack3765803342 Win5792 Len0 MSS1460 3
0.000221 192.168.10.201 192.168.10.202
TCP 32991 gt 3000 ACK Seq3765803342
Ack3834295110 Win1460 Len0 4 3.918699
192.168.10.201 192.168.10.202 TCP
32991 gt 3000 FIN, ACK Seq3765803342
Ack3834295110 Win1460 Len0 5 3.920539
192.168.10.202 192.168.10.201 TCP
3000 gt 32991 ACK Seq3834295110
Ack3765803343 Win1448 Len0 6 6.619394
192.168.10.202 192.168.10.201 TCP
3000 gt 32991 FIN, ACK Seq3834295110
Ack3765803343 Win1448 Len0 7 6.619424
192.168.10.201 192.168.10.202 TCP
32991 gt 3000 ACK Seq3765803343
Ack3834295111 Win1460 Len0
6Connection Termination
FIN
Application close
ACK of FIN
Deliver EOF to application
FIN
Application close
ACK of FIN
7TCP Half Close
FIN
Application close
Deliver EOF to application
ACK of FIN
DATA
Application write
Application read
ACK of Data
FIN
Application close
Deliver EOF to application
ACK of FIN
8TCP State Diagram
92MSL Timeout
- MSL Maximum Segment Lifetime The time for which
a segment can be in the network before being
discarded. - Common values used 30 sec 2 mins
- To allow retransmission of the last ACK for FIN
- Disallows a new connection with the same port for
2MSL - Can be overridden by SO_REUSEADDR socket option
- Quiet Time Do not create any TCP connection for
MSL seconds after rebooting. Why?
10Reset Segments
- Connection request to Nonexistent Port
- Aborting a connection
- application can issue it with SO_LINGER socket
option and close()
11Netstat output showing TCP states
Proto Recv-Q Send-Q Local Address
Foreign Address State
PID/Program name tcp 0 0 719
LISTEN - tcp 0
0 sunrpc
LISTEN - tcp
0 0 localhost.localdomainipp
LISTEN -
tcp 0 0 localhost.localdomainsmtp
LISTEN -
tcp 0 0 localhost.lox11-ss
h-offset LISTEN
- tcp 0 0
localhost.localdomain32996 localhost.localdomain
4000 FIN_WAIT2 - tcp
0 0 localhost.localdomain32995
localhost.localdomain4000 TIME_WAIT -
tcp 0 0 pc201.localdomain3
2988 pc202.localdomainssh ESTABLISHED
26033/ssh tcp 0 0
localhost.lox11-ssh-offset localhost.localdomain
32977 ESTABLISHED - tcp
0 0 localhost.lox11-ssh-offset
localhost.localdomain32976 ESTABLISHED -
tcp 0 0 localhost.localdoma
in4000 localhost.localdomain32996 CLOSE_WAIT
26155/sock tcp 0 0
localhost.lox11-ssh-offset localhost.localdomain
32994 ESTABLISHED - tcp
0 0 localhost.localdomain32994
localhost.lox11-ssh-offset ESTABLISHED
26130/xterm tcp 0 0
localhost.localdomain32977 localhost.lox11-ssh-o
ffset ESTABLISHED 25980/xterm tcp
0 0 localhost.localdomain32976
localhost.lox11-ssh-offset ESTABLISHED
25960/xterm tcp 0 0 ssh
LISTEN - tcp 0
0 1x11-ssh-offset
LISTEN - tcp
0 0 pc201.localdomainssh
filehost67838123 ESTABLISHED -
12Local and Foreign IP/port
- localIP.lport foreignIP.fport
- Restricted to one client (normally not supported)
- localIP.lport .
- Restricted to connections arriving on one
interface and port - .lport .
- Receives all connections sent to lport