lecture14 - Academic Csuohio

Download Report

Transcript lecture14 - Academic Csuohio

EEC-484/584
Computer Networks
Lecture 14
Wenbing Zhao
[email protected]
(Part of the slides are based on Drs. Kurose &
Ross’s slides for their Computer Networking book)
2
Outline
• Reminder:
– Wiki project#2 due: 11/17
– Quiz 4: 11/26 (review session on 11/24)
• TCP
– Reliable data transfer
– Flow control
– Congestion control
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
3
TCP Reliable Data Transfer
• TCP creates rdt
service on top of IP’s
unreliable service
• Pipelined segments
• Cumulative acks
• TCP uses single
retransmission timer
Fall Semester 2008
• Retransmissions are
triggered by:
– timeout events
– duplicate acks
• Initially consider
simplified TCP
sender:
– ignore duplicate acks
– ignore flow control,
congestion control
EEC-484/584: Computer Networks
Wenbing Zhao
4
TCP Sender Events:
Data rcvd from app:
Timeout:
• Create segment with
sequence number
• seq # is byte-stream
number of first data
byte in segment
• Start retransmission
timer if not already
running (think of timer
as for oldest unacked
segment)
• retransmit segment that
caused timeout
• restart timer
Fall Semester 2008
Ack rcvd:
• If acknowledges
previously unacked
segments
– update what is known to
be acked
– restart timer if there are
outstanding segment
EEC-484/584: Computer Networks
Wenbing Zhao
5
TCP: Retransmission Scenarios
timeout
Host A
SendBase
= 100
time
Fall Semester 2008
Host B
X
loss
lost ACK scenario
EEC-484/584: Computer Networks
Wenbing Zhao
6
TCP: Retransmission Scenarios
Host B
Sendbase
= 100
SendBase
= 120
SendBase
= 120
Seq=92 timeout
Seq=92 timeout
Host A
time
Fall Semester 2008
premature timeout
EEC-484/584: Computer Networks
Wenbing Zhao
7
TCP Retransmission Scenarios
timeout
Host A
Host B
X
loss
SendBase
= 120
time
Cumulative ACK scenario
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
8
TCP ACK Generation
Event at Receiver
TCP Receiver action
Arrival of in-order segment with
expected seq #. All data up to
expected seq # already ACKed
Delayed ACK. Wait up to 500ms
for next segment. If no next segment,
send ACK
Arrival of in-order segment with
expected seq #. One other
segment has ACK pending
Immediately send single cumulative
ACK, ACKing both in-order segments
Arrival of out-of-order segment
higher-than-expect seq. # .
Gap detected
Immediately send duplicate ACK,
indicating seq. # of next expected byte
Arrival of segment that
partially or completely fills gap
Immediate send ACK, provided that
segment starts at lower end of gap
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
9
TCP Flow Control
• Receive side of TCP
connection has a
receive buffer:
• App process may be
slow at reading from
buffer
Fall Semester 2008
Flow control:
sender won’t overflow
receiver’s buffer by
transmitting too much,
too fast
• Speed-matching
service: matching
the send rate to the
receiving app’s drain
rate
EEC-484/584: Computer Networks
Wenbing Zhao
10
TCP Flow Control
(Suppose TCP receiver discards
out-of-order segments)
Spare room in buffer
= RcvWindow
= RcvBuffer-[LastByteRcvd
- LastByteRead]
Fall Semester 2008
• Rcvr advertises
spare room by
including value of
RcvWindow in
segments
• Sender limits
unACKed data to
RcvWindow
– guarantees receive
buffer doesn’t
overflow
EEC-484/584: Computer Networks
Wenbing Zhao
11
Principles of Congestion Control
Congestion:
• Informally: “too many sources sending too much
data too fast for network to handle”
• Different from flow control!
• Manifestations:
– lost packets (buffer overflow at routers)
– long delays (queueing in router buffers)
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
12
Approaches towards Congestion Control
Two broad approaches towards congestion control
End-end congestion
control:
Network-assisted
congestion control:
• no explicit feedback from
network
• congestion inferred from
end-system observed
loss, delay
• approach taken by TCP
• routers provide feedback
to end systems
– single bit indicating
congestion (SNA,
DECbit, TCP/IP ECN,
ATM)
– explicit rate sender
should send at
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
13
TCP Congestion Control:
Additive Increase, Multiplicative Decrease
• Approach: increase transmission rate (window size),
probing for usable bandwidth, until loss occurs
– Additive increase: increase cwnd every RTT until
loss detected
– Multiplicative decrease: cut cwnd after loss
Saw tooth
behavior: probing
for bandwidth
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
14
TCP Congestion Control
• Sender limits transmission:
How does sender
perceive
LastByteSent-LastByteAcked
 cwnd
congestion?
• Roughly,
• loss event = timeout
or 3 duplicate acks
cwnd
rate =
Bytes/sec
RTT
• TCP sender reduces
rate (cwnd) after
• cwnd is dynamic, function of
loss event
perceived network
congestion
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
15
TCP Slow Start
• When connection begins,
cwnd = 1 MSS
– Example: MSS = 500 bytes
& RTT = 200 msec
– Initial rate = 2.5 kBps
• When connection
begins, increase rate
exponentially fast until
first loss event
• Available bandwidth may
be >> MSS/RTT
– Desirable to quickly ramp
up to respectable rate
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
16
TCP Slow Start
Host A
Host B
RTT
• When connection
begins, increase rate
exponentially until first
loss event:
– Double cwnd every RTT
– Done by incrementing
cwnd for every ACK
received
• Summary: initial rate is
slow but ramps up
exponentially fast
Fall Semester 2008
EEC-484/584: Computer Networks
time
Wenbing Zhao
17
Congestion Avoidance
Q: When should the
exponential increase
switch to linear?
A: When cwnd gets to
1/2 of its value
before timeout
Implementation:
• Variable Threshold
• At loss event, Threshold
is set to 1/2 of cwnd just
before loss event
Fall Semester 2008
How to increase cwnd linearly:
cwnd (new) = cwnd + mss*mss/cwnd
EEC-484/584: Computer Networks
Wenbing Zhao
18
Congestion Control
• After 3 duplicated ACKs:
– cwnd is cut in half
– window then grows linearly
• But after timeout event:
– cwnd instead set to 1 MSS
– window then grows
exponentially
– to a threshold, then grows
linearly
Fall Semester 2008
Philosophy:
 3 dup ACKs indicates
network capable of
delivering some segments
 timeout indicates a
“more alarming”
congestion scenario
EEC-484/584: Computer Networks
Wenbing Zhao
19
Summary: TCP Congestion Control
• When cwnd is below Threshold, sender in slowstart phase, window grows exponentially
• When cwnd is above Threshold, sender is in
congestion-avoidance phase, window grows linearly
• When a triple duplicate ACK occurs, Threshold set
to cwnd/2 and cwnd set to Threshold
• When timeout occurs, Threshold set to cwnd/2
and cwnd is set to 1 MSS
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
TCP Sender Congestion Control
State
Event
TCP Sender Action
Commentary
Slow Start ACK receipt CongWin = CongWin + MSS,
(SS)
for previously
If (CongWin > Threshold)
unacked
set state to “Congestion
data
Avoidance”
Resulting in a doubling
of CongWin every RTT
Congestion
Avoidance
Additive increase,
resulting in increase of
CongWin by 1 MSS
every RTT
(CA)
ACK receipt CongWin = CongWin+
MSS * (MSS/CongWin)
for previously
unacked
data
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
20
TCP Sender Congestion Control
State
Event
TCP Sender Action
Commentary
SS or CA
Loss
event
detected
by triple
duplicate
ACK
Threshold = CongWin/2,
CongWin = Threshold,
Set state to “Congestion
Avoidance”
Fast recovery,
implementing
multiplicative
decrease. CongWin
will not drop below 1
MSS.
SS or CA
Timeout
Threshold = CongWin/2,
CongWin = 1 MSS,
Set state to “Slow Start”
Enter slow start
SS or CA
Duplicate
ACK
Increment duplicate ACK CongWin and
count for segment being Threshold not
acked
changed
Fall Semester 2008
EEC-484/584: Computer Networks
Wenbing Zhao
21
22
TCP Congestion Control
Slow start
Segment lost
Fall Semester 2008
Repeated acks
EEC-484/584: Computer Networks
Wenbing Zhao