Title: ELEN 602 Lecture 15
1ELEN 602 Lecture 15
2TCP Streams
Application
Application
byte stream
byte stream
segments
Transmitter
Receiver
Send buffer
Receive buffer
ACKs
3TCP end-to-end Flow control
Transmitter
Receiver
Send Window
Receive Window
SlastWa-1
RlastWR1
Rlast
...
...
...
Rnext
Rnew
Octets transmitted and ACKed
Slast
Srecent
SlastWs-1
Slast oldest unacknowledged octet Srecent
highest-numbered transmitted octet SlastWa-1
highest-numbered octet that can be
transmitted SlastWs-1 highest-numbered octet
that can be accepted from the application
Rlast highest-numbered octet not yet read by the
application Rnext next expected octet Rnew
highest numbered octet received correctly RlastWR
-1 highest-numbered octet that can be
accommodated in receive buffer
4TCP Segment
0 4 10
16
24 31
Source Port
Destination Port
Sequence Number
Acknowledgement Number
U
A
P
R
S
F
Header
R
C
S
S
Y
I
Reserved
Window Size
Length
G
K
H
T
N
N
Checksum
Urgent Pointer
Options
Padding
Data
5TCP Pseudoheader
0 8
16
31
Source IP Address
Destination IP Address
0 0 0 0 0 0 0 0 Protocol 6
TCP Segment Length
63-way Handshake for connection establishment
Host A
Host B
SYN, Seq_no x
SYN, Seq_no y, ACK, Ack_no x1
Seq_no x1, ACK, Ack_no y1
7Sequence numbers
Host A
Host B
SYN, Seq_no n
SYN, Seq_no n, ACK, Ack_no n1
Seq_no n1, ACK, Ack_no n1
Delayed segment with
Seq_no n2
will be accepted
8TCP application example
Host B (Server)
Host A (Client)
socket bind listen accept (blocks)
socket connect (blocks)
SYN, Seq_no x
SYN, Seq_no y, ACK, Ack_no x1
connect returns
Seq_no x1, ACK, Ack_no y1
write read (blocks)
accept returns read (blocks)
request message
read returns
write read (blocks)
reply message
read returns
9TCP Window control
Host A
Host B
t0
Seq_no 1, Ack_no 2000, Win 2048, No Data
t1
Seq_no 2000, Ack_no 1, Win 1024, Data
2000-3023
t2
Seq_no 3024, Ack_no 1, Win 1024, Data
3024-4047
t3
Seq_no 1, Ack_no 4048, Win 512, Data 1-128
t4
Seq_no 4048, Ack_no 129, Win 1024, Data
4048-4559
10TCP Header overhead
TCP Header
20 bytes of TCP header
20 bytes of IP header
IP Header
11Connection Termination
Host A
Host B
FIN, seq 5086
ACK 5087
Data, seq. 303, ACK 5087
Deliver 150 bytes
ACK 453
FIN, seq. 453, ACK 5087
ACK 454
12TCP State diagram
CLOSED
passive open, create TCB
applic.close
active open,create TCB send SYN
LISTEN
receive SYN, send SYN, ACK
receive RST
send SYN
applic. close or timeout, delete TCB
SYN_SENT
SYN_RCVD
receive SYN, send ACK
receiveACK
receive SYN, ACK, send ACK
applic. close, send FIN
ESTABLISHED
receive FIN, send ACK
applic. close, send FIN
CLOSE_WAIT
receive FIN send ACK
applic. close send FIN
CLOSING
FIN_WAIT_1
receive ACK
LAST_ACK
receive ACK
receive ACK
receive FIN, ACK send ACK
receive FIN send ACK
2MSL timeout delete TCB
FIN_WAIT_2
TIME_WAIT
13Routing for mobile hosts
Foreign network
Home network
Foreign agent
Mobile host
2
Home agent
Internet
3
1
Correspondent host
14IP to IP Encapsulation
Outer IP Header
IP Header
IP Header
IP Payload
IP Payload