Title: Transmission Control Protocol TCP Part II
1Transmission Control Protocol (TCP) Part II
- D. E. Comer, Internetworking with TCP/IP
Principles, Protocols and Architectures, Ch. 13,
Prentice Hall, 2000 - Presented by Tony Dongliang Feng for CMPT 880
-
tdfeng_at_cs.sfu.ca
2Road Map
- TCP congestion control
- Silly Window Syndrome
- TCP connection management
3TCP Congestion Congest Collapse
- Congestion a condition of severe delay caused by
an overload of datagram at one or more switching
points (routers) - Congestion Collapse Retransmissions aggravate
congestion instead of alleviating it
4How TCP Can Help?
- Remember TCP is an end-to-end protocol,
endpoints do not know the details of where
congestion has occurred or why - What TCP knows? Increased delay
- What can TCP do? the rate of transmission, window
size, timeout value
5Response To Congestion
- Two recommended techniques
- multiplicative decrease
- slow start
6Congestion Window
- At any time, TCP window size
- Allowed_window min(receiver_advertisement,
congestion_window) - In a steady state of non-congested connection,
congestion window size equals to receiver window
size - Reducing the congestion window reduces the
traffic TCP will inject into the connection
7How to Estimate Congestion Window Multiplicative
Decrease
- Idea upon loss of a segment, reduce the
congestion window by half (down to a minimum of
one segment). For those segments that remain in
the allowed window, back-off the retransmission
timer exponentially - If loss continues, TCP eventually limits
transmission to a single segment and continue to
double timeout before retransmission
8How To Recover When It Ends?
- Why not reverse the process? Meaning
multiplicative increase and double the congestion
window?
- Slow Start (additive) Recovery whenever starting
traffic on a new connection or increasing traffic
after a period of congestion, start the congest
window at the size of 1 segment and increase the
congestion window by 1 segment each time an
acknowledgement arrives
9Is slow start really slow?
A
B
- The answer is NO
- Example
- Initially, cwnd1, send one segment
- After receiving 1 ACK, cwnd2, send two segments
- After receiving two ACKs, cwnd4, send four
segments - continue on
- It takes only Log2N round trips before TCP can
send N segments
10One Additional Restriction Congestion Avoidance
Phase
- Once congestion window reaches one half its
original size before congestion, TCP enters a
congestion avoidance phase and slow down the rate
of increment - During this phase, it increases the cwnd by 1
only if all segments in the window have been ACKed
11Congestion Control Summary
- Together, slow start increase, multiplicative
decrease, congestion avoidance, and exponential
timer back-off improves the TCP performance
dramatically without adding significant
computational overhead
12Congestion, Tail Drop and TCP
- Tail-Drop Policy If the input queue is filled
when a datagram arrives, discard the datagram. - Advantage Simple
- Disadvantage Global Synchronization
13Random Early Discard (RED)
- Idea
- Drop early to signal impending congestion
- Algorithm
avg average queue size p discard probability
Tmin lower bound on avg to drop packets Tmax
upper bound on avg to not drop every packet
for each packet arrival calculate average
queue size avg if avg lt Tmin add the
packet to the queue else if Tmin lt avg lt
Tmax calculate discard probability p
drop arriving packet with probability p
else if Tmax lt avg drop the arriving
packet
14Random Early Discard (RED) (2)
- Calculating average queue size avg
- Calculated using an exponentially weighted
average of previous queue lengths - avg (1- ?) Old_avg ? Current_queue_size
- The purpose of using an average queue size is to
filter out transient congestion at the router
15Random Early Discard (RED) (3)
- Calculating the discard probability p
- Tmin lower bound on avg to drop pkts
- Tmax upper bound on avg to not drop every pkt
- maxp the drop probability as avg approaches Tmax
1
P
maxp
0
avg
Tmin
Tmax
16Silly Window Syndrome (SWS)
- Example An application chooses to read incoming
data one octet at a time, which can result sender
sending one segment with one octet data - Summary Early TCP implementation exhibited a
problem known as silly window syndrome in which
each acknowledgement advertises a small amount of
space available and each segment carries a small
amount of data
17Avoid SWS (1)
- Receiver-side SWS avoidance
- Before sending an updated window advertisement
after advertising a zero window, wait for space
to become available that is either at least 50
of the total buffer size or equal to a maximum
sized segment, whichever comes first
18Avoid SWS (2)
- Delayed Acknowledgements
- TCP delays sending an acknowledgement when silly
window avoidance specifies that the window is not
sufficiently large to advertise - Pros decrease traffic, increase throughput
- Cons delay ACKs can potentially trigger
retransmission also confuse RTT estimates - Practice (1) delay should be no more than 500
msec (2) receiver should ACK at least every other
data segment
19Avoid SWS (3)
- At sender side, the goal is to avoid sending
small segments - Clumping sending TCP must delay sending a
segment until it can accumulate a reasonable
amount of data - Challenges how long should TCP wait before
transmitting data? A fixed delay is not optimal
for all applications
20Avoid SWS Nagle Algorithm (4)
- Self clocking (sender side SWS avoidance)
- When a sending application generates additional
data to be sent over a connection for which
previous data has been transmitted but not
acknowledged, place the new data in the output
buffer as usual, but do not send additional
segments until there is sufficient data to fill a
Maximum Sized Segment. - If still waiting to send when an ACK arrives,
send all data that has accumulated in the buffer.
- Apply this rule even when the user requests a
PUSH operation
21SWS Avoidance Summary
- TCP now requires the sender and receiver to
implement heuristics that avoid the silly window
syndrome. A receiver avoid advertising a small
window, and a sender uses an adaptive scheme to
delay transmission so it can clump data into
large segments
22TCP Connection Management
- Establishing a connection
- Initial Sequence Number (ISN)
- Closing a TCP connection
- Connection Reset
- TCP state machine
23Three-way Handshake Protocol
B
A
Send SYN seqx
Receive SYN segment Send SYN, seqy, ACK x1
Receive SYN ACK segment Send ACK y1
Receive ACK segment
24ISN Initial Sequence Number
- Two tasks have been accomplished by 3-way
handshaking - Both sides are ready to transfer data
- Both sides agree on ISN, ISN is chosen randomly
- How is it done in three messages?
- A node chooses x, B node ACKs x1, which
specifies the B will expect octet from x1 - B node piggybacks his chosen ISN, y, on second
message, with SYN set - A node ACKs this y by y1
25TCP Closing Connection
A
B
Application close connection, send FIN seqx
Receive FIN segment, send ACK x1, inform
application
Receive ACK segment
Application close connection, send FIN seqy,
ACK x1
Receive FIN ACK segment, send ACK y1
Receive ACK segment
26TCP Connection Reset
- Normally, TCP closes connection, analogous to
closing a file - Under abnormal conditions, an RST bit indicates
immediate abort, resources such as buffers are
released
27TCP Finite State Machine