View
215
Download
0
Tags:
Embed Size (px)
Citation preview
1CMPE 150- Introduction to Computer Networks
CMPE 150
Fall 2005Lecture 27
Introduction to Computer Networks
2CMPE 150- Introduction to Computer Networks
Announcements
• Homework 5 posted.– Due, Mon, 12.05.
• Lab tonight!• Final exam: December 7th. 4-7pm
– In class.– Closed books/notes.– Comprehensive.
• Course evaluation.– Last day of class.
• CE 151 will be offered in Winter 06!
3CMPE 150- Introduction to Computer Networks
Today
• Transport Layer (Cont’d).– Chapter 6 of Tanenbaum.
4CMPE 150- Introduction to Computer Networks
The Transport Layer
• End-to-end.– Communication from source to destination host.
– Only hosts run transport-level protocols.
– Under user’s control as opposed to network layer which is controlled/owned by carrier.
5CMPE 150- Introduction to Computer Networks
The Transport Service
• Service provided to application layer.
• Transport entity: process that implements the transport protocol running on a host.– Typically at OS kernel, or user-level process.
7CMPE 150- Introduction to Computer Networks
Three-Way Handshake
• Solves the problem of getting 2 sides to agree on initial sequence number.
CR (seq=x)
ACK(seq=y,ACK=x)
DATA(seq=x, ACK=y)
CR: connectionrequest.
1 2
8CMPE 150- Introduction to Computer Networks
Delayed Duplicates
. Old duplicate CR.
. The ACK from host 2 triesto verify if host 1 was trying to open a new connection with seq=x.. Host 1 rejects host 2’s attempt to establish.Host 2 realizes it was a duplicateCR and aborts connection.
CR(seq=x)*
ACK(seq=y, ACK=x)
REJECT(ACK=y)
1 2
9CMPE 150- Introduction to Computer Networks
Delayed Duplicates
. Old duplicate CR and ACKto connection accepted.
CR(seq=x)*
ACK(seq=y, ACK=x)
REJECT(ACK=y)
1 2
DATA(seq=x,ACK=z)
11CMPE 150- Introduction to Computer Networks
Sequence Numbers versus Time 1
Seq.#’s
Time
. Linear relation between timeand initial sequence number.
12CMPE 150- Introduction to Computer Networks
Connection Release
• Asymmetric release: telephone system.– When one party hangs up, connection breaks.
– May cause data loss.
• Symmetric release: – Treats connection as 2 separate unidirectional
connections.
– Requires each to be released separately.
13CMPE 150- Introduction to Computer Networks
Symmetric Release• How to determine when all data has been sent and connection could be released?• 2-army problem:
Blue army 1
White army
Blue army 2
. White army largerthan either blue armies.. Blue army together is larger.. If each blue army attacks, it’ll be defeated. They win if attack together.
14CMPE 150- Introduction to Computer Networks
2-Army Problem
• To synchronize attack, they must use messengers that need to cross valley: unreliable.
• Is there a protocol that allows blue army to win? No.– Blue army 1 sends message to blue army 2.– Blue army 2 sends ACK back.– Blue army 2 is not sure whether ACK was
received.
15CMPE 150- Introduction to Computer Networks
2-Army Problem (Cont’d)
• Use 2-way handshake.– Blue army 1 ACKs back but it’ll never know if the ACK
was received.
• Applying to connection release:– Neither side is prepared to disconnect until convinced
other side is prepared to disconnect.
– In practice, hosts are willing to take risks.
16CMPE 150- Introduction to Computer Networks
Connection Release Protocol
DR
DR
ACK
DR: disconnectionrequest.
Send DR+start timer
Send DR+start timerRelease
connection
Send ACK Release
connection
17CMPE 150- Introduction to Computer Networks
Connection Release: Scenario 1
DR
DR
ACK
DR: disconnectionrequest.
Send DR+start timer
Send DR+start timerRelease
connection
Send ACK Timeout:
Release connection
18CMPE 150- Introduction to Computer Networks
Connection Release: Scenario 2
DR
DR
DR: disconnectionrequest.
Send DR+start timer
Send DR+start timerTimeout:
send DR+start timer
Release connection
DR
Send DR+start timerDR
ACK
19CMPE 150- Introduction to Computer Networks
TCP Connection Release
• Each side released independently.– TCP segment with FIN bit set.
– Means that side has no more data to send.
• When both sides have shutdown, connection is released,
20CMPE 150- Introduction to Computer Networks
TCP Connection Release
FIN
FIN ACK
FIN
FIN ACK
Timers to avoid 2-army problem.
21CMPE 150- Introduction to Computer Networks
TCP Reliability
• Reliability.• Ordering. • Duplicate detection.
22CMPE 150- Introduction to Computer Networks
TCP Reliability: Mechanisms
• Acknowledgements.• Timers.• Sequence numbers.
23CMPE 150- Introduction to Computer Networks
Delayed ACKs
• ACKs are delayed waiting for data to be sent in the “other” direction.
• Either data will be sent or delayed ACK timer expires.
25CMPE 150- Introduction to Computer Networks
Window Flow Control: Sender
Sent but not acked Not yet sent
advertised window (from receiver)
Sequence numbers
last byte sentlast byte ACKed
effective window
send buffer
26CMPE 150- Introduction to Computer Networks
Window Flow Control: Receiver
ACKed but notdelivered to user
recv’dbut notACKed
Receive buffer (possible window)
Sequence numbers
advertisedwindow
mis
sing
dat
a
27CMPE 150- Introduction to Computer Networks
Problem: Rapid Wrap-Around
• Sequence number is 32 bits long.• Wraparound time vs. link speed:
• 1.5Mbps: 6.4 hours• 10Mbps: 57 minutes• 45Mbps: 13 minutes• 100Mbps: 6 minutes• 622Mbps: 55 seconds• 1.2Gbps: 28 seconds
Protection Against Wrapped Sequences (PAWS extension): Use timestamp option to extend sequence number space.
29CMPE 150- Introduction to Computer Networks
Window Advancement Issues
• What if window is full?– Sender sends full window, but ACK is lost. Sender sends 1-byte probes (solicits new ACK).
• Silly window syndrome (RFC-813)– Receiver avoids small window advances. Silly Window Avoidance: delay ACKing (receiver) or
avoid sending small segments (sender).• Sender avoids sending small chunks (like telnet).
Nagle’s algorithm (RFC-896): send 1st partial packet, but not more until it’s ACKed or you have a full packet
31CMPE 150- Introduction to Computer Networks
What is Congestion Control?
• “Efforts made by network nodes to prevent or respond to overload condition”, [Peterson&Davie].– Prevent senders from sending too much data into
network.• Flow control?
– Prevents (faster) sender from overrunning (slower) receiver.
• Both concepts are often confused as they share common mechanisms.
32CMPE 150- Introduction to Computer Networks
TCP Congestion Control
• (a) A fast network feeding a low capacity receiver.
• (b) A slow network feeding a high-capacity receiver.
33CMPE 150- Introduction to Computer Networks
Why do congestion control?
• Use network resources efficiently.• Preserve fair network resource allocation.• Prevent or avoid congestion collapse.• Congestion collapse is not just a theory!
– Has been frequently observed in many networks.
34CMPE 150- Introduction to Computer Networks
Congestion Collapse
• If both sources send full speed, the router is completely overwhelmed congestion collapse: senders lose data from
congestion and they resend, causing more congestion (can be self-reinforcing).
10 Mbps
10 Mbps
1.5 Mbps
36CMPE 150- Introduction to Computer Networks
E2E congestion control
• Why do it at the transport layer?– Real fix to congestion is to slow down sender.
• Use law of “conservation of packets”.– Keep number of packets in the network constant.
– Don’t inject new packet until old one leaves.
• Congestion indicator: packet loss.
37CMPE 150- Introduction to Computer Networks
Congestion Control Design
• Avoidance or detection/recovery? – Avoidance keeps system at knee of curve
• Requires some congestion signal.
– Detection/recovery responds to loss after the fact.
• TCP– Which is TCP?
• Congestion detection/recovery.
– How does TCP do it?• Slow start, congestion avoidance, exponential backoff.
38CMPE 150- Introduction to Computer Networks
TCP congestion control
• Underlying design principle: packet conservation– At equilibrium, inject packet into network only
when one is removed.
– Basis for stability of physical systems.
39CMPE 150- Introduction to Computer Networks
Self-clocking
• If we have large actual window, should we send data in one shot?– No, use ACKs to clock sending new data.
41CMPE 150- Introduction to Computer Networks
TCP congestion control basics
• Like, flow control, also window based.– Sender keeps congestion window (cwin).
– Each sender keeps 2 windows: receiver’s advertised window and congestion window.
– Sender’s maximum window: min(advertised window, cwin).
• Sender’s actual window:– Max window - unacknowledged segments.
42CMPE 150- Introduction to Computer Networks
TCP congestion control mechanisms
• Collection of interrelated mechanisms:– Slow start.
– Congestion avoidance.
– Accurate retransmission timeout estimation.
– Fast retransmit.
– Fast recovery.
43CMPE 150- Introduction to Computer Networks
TCP congestion window
• New congestion window cwnd– What the network can handle,
– versus flow control window (wnd): what the other end can handle
• Actual congestion window:– min (wnd, cwnd).
44CMPE 150- Introduction to Computer Networks
How to adjust window?
• When to increase/decrease?
• A control theory problem:– Observe network.
– Reduce window if congested.
– Increase window if not congested.
• Constraints:– Efficiency.
– Fairness.
– Stability (too much oscillation is bad).
– Out-of-date info• RTT is fundamental
limit to how quickly you can react
45CMPE 150- Introduction to Computer Networks
Slow start [Jacobson 1988]
• How do we get this self-clocking behavior to start?– Initialize cwnd = 1.– Upon receipt of every ack, cwnd = cwnd + 1
• Implications– Window actually increases in RTT * log2W (exponential
increase).– Can overshoot window and cause packet loss.
Connection’s congestion window starts at 1 segment.
46CMPE 150- Introduction to Computer Networks
Slow start example
1
one RTT
one pkt time
0R
21R
3
42R
567
83R
91011
1213
1415
1
2 3
4 5 6 7
47CMPE 150- Introduction to Computer Networks
When to End Slow-Start?
• Want to end when the pipe is full.– When cwnd > ssthresh.– Start with large ssthresh, but then refine it.
• On packet loss.– cwnd=1 and go back to slow start.– ssthresh = cwnd / 2
• assume that pipe size was somewhere between last good window (cwnd/2) and current window (cwnd).
• Eventually, ssthresh is right and transition to congestion avoidance without packet loss.
48CMPE 150- Introduction to Computer Networks
Congestion avoidance
Upon receiving ACK Increase cwnd by 1/cwnd. This is additive increase.
Why not multiplicative increase? Growing too fast in equilibrium =>
oscillations
49CMPE 150- Introduction to Computer Networks
TCP Congestion Control: Operation
threshold
timeout
threshold
cwin
time
50CMPE 150- Introduction to Computer Networks
TCP Retransmission Timer
• When segment sent, retransmission timer starts.
– If segment ACKed, timer stops.
– If time out, segment retransmitted and timer starts again.
51CMPE 150- Introduction to Computer Networks
How to set timer?
• Based on round-trip time: time between a segment is sent and ACK comes back.
• If timer is too short, unnecessary retransmissions.
• If timer is too long, long retransmission delay.
52CMPE 150- Introduction to Computer Networks
Jacobson’s Algorithm 1
• Determining the round-trip time:– TCP keeps RTT variable.
– When segment sent, TCP measures how long it takes to get ACK back (M).
– RTT = alpha*RTT + (1-alpha)M.
– alpha: smoothing factor; determines weight given to previous estimate.
– Typically, alpha=7/8.
53CMPE 150- Introduction to Computer Networks
Jacobson’s Algorithm 2
• Determining timeout value:– Measure RTT variation, or |RTT-M|.
– Keeps smoothed value of cumulative variation D=alpha*D+(1-alpha)|RTT-M|.
– Alpha may or may not be the same as value used to smooth RTT.
– Timeout = RTT+4*D.
54CMPE 150- Introduction to Computer Networks
Karn’s Algorithm
• How to account for ACKs of retransmitted segments?
– Count it for first or second transmission?
– Karn proposed not to update RTT on any retransmitted segment.
– Instead RTT is doubled on each failure until segments get through.
55CMPE 150- Introduction to Computer Networks
Persistence Timer
• Prevents deadlock if an window update packet is lost and advertised window = 0.
• When persistence timer goes off, sender probes receiver; receiver replies with its current advertised window.
• If 0, persistence timer is set again.