Transmission Control Protocol: Notes Derived From "
Transmission Control Protocol: Notes Derived From "
Transmission Control Protocol: Notes Derived From "
1
TCP: Features/Context
Connection-oriented
State vars, buffer etc
Routers are oblivious to TCP
Full-duplex service
Point-to-Point Service
Three-way handshake for con. Est.
2
TCP: Context
MSS(Maximum Segment Size)
Max amount of app data
It is the maximum size of the body of
transport segment
MTU (Maximum Transmission Unit)
Largest link layer frame
Send Buffer/Receive Buffer
It breaks the file into MSS
TCP header is typically 20 byte
3
TCP segment structure
32 bits
URG: urgent data counting
(generally not used) source port # dest port #
by bytes
sequence number of data
ACK: ACK #
valid acknowledgement number (not segments!)
head not
PSH: push data now len used
UA P R S F Receive window
(generally not used) # bytes
checksum Urg data pnter
rcvr willing
RST, SYN, FIN: to accept
Options (variable length)
connection estab
(setup, teardown
commands)
application
Internet data
checksum (variable length)
(as in UDP)
4
Sequence and Acknowledgement
Number
TCP views data as unstructured, but
ordered stream of bytes.
Sequence numbers are over bytes, not
segments
Initial sequence number is chosen randomly
TCP is full duplex – numbering of data is
independent in each direction
Acknowledgement number – sequence
number of the next byte expected from
the sender
ACKs are cumulative
5
TCP seq. #’s and ACKs
Seq. #’s:
Host A Host B
byte stream “number”
of first byte in 1000 byte Seq=4
data 2,
segment’s data ACK=
79, da
t a
ACKs: host ACKs
seq # of next byte receipt of
data data
expected from other 10 4 2 no
CK=
side Seq=
79, A
cumulative ACK
6
TCP seq. #’s and ACKs(n)
Seq. #’s:
Host A Host B
byte stream “number”
of first byte in 1000 byte Seq=4
data 2,
segment’s data ACK=
79, da
t a
ACKs: host ACKs
seq # of next byte receipt of
d ata data
expected from other =10 4 3, no
side =7 9 , ACK
Seq
cumulative ACK
CPSC 441:TCP 7
TCP: Cumulative ACK/Dupack
1001
ACK 2001
2000
2001
3000
4001
ACK 2001
5000
2001
3000
4001
5000 Generate all the acknowledgement. Assume that no
acks are lost.
5001
6000
TCP: Cumulative ACK/Dupack
1001
2000
2001
3000
4001
This segment is lost
5000
2000 2000
2001 2001
3000 3000
A 3001 3001 B
4000 4000
4001 4001
5000 5000
13
TCP: Phases
Slow Start
TCP is in slow-start when cwnd < ssthresh
During congestion avoidance, TCP increases the
cwnd by 1 with every receipt ACK
14
TCP: Reliable Transfer
Unreliable transfer can occur due to
Router overflow
Out of order delivery
Corruption
15
TCP: Reliable Transfer
data rcvd from app: timeout:
When timer expires,
Create segment with
timeout event is triggered
seq # retransmit segment that
seq # is byte-stream caused timeout
number of first data restart timer
byte in segment Dupack:
start timer if not If we receive 3 or more
16
TCP Flow Control
flow control
sender won’t overflow
receive side of TCP
receiver’s buffer by
connection has a transmitting too
receive buffer: much,
too fast
speed-matching
service: matching the
send rate to the
receiving app’s drain
rate
app process may be
slow at reading from
buffer
17
TCP Flow control: how it works
Rcvr advertises spare
room by including value
of RcvWindow in
segments
Sender limits unACKed
(Suppose TCP receiver data to RcvWindow
discards out-of-order guarantees receive
segments) buffer doesn’t overflow
spare room in buffer
= RcvWindow
= RcvBuffer-[LastByteRcvd -
LastByteRead]
18
TCP Connection Establishment (n)
19
TCP Connection Termination (n)
client server
closing
FIN_WAIT1 F IN
CLOSE_WAIT
ACK
LAST_ACK
FIN_WAIT2 FIN
TIME_WAIT
timed wait
ACK
CLOSED
CLOSED
20
Principles of Congestion Control (n)
Congestion: informally: “too many sources
sending too much data too fast for network to
handle”
Different from flow control!
Manifestations:
Packet loss (buffer overflow at routers)
Increased end-to-end delays (queuing in router buffers)
Results in unfairness and poor utilization of
network resources
Resources used by dropped packets (before they were
lost)
Retransmissions
Poor resource allocation at high load
21
Congestion Control: Approaches
(n)
Goal: Throttle senders as needed to ensure
load on the network is “reasonable”
End-end congestion control:
no explicit feedback from network
congestion inferred from end-system
observed loss, delay
approach taken by TCP
22
TCP Congestion Control: Overview
Congestion detection
Timeout
Dupacks
Congestion action
Action for timeout
• Reduce transmission rate to 1 seg/rtt
Action for dupack
• Reduce transmission rate to half
23