1
04832250 – Computer Networks (Honor Track)
- Prof. Chenren Xu
04832250 Computer Networks (Honor Track) A Data Communication and - - PowerPoint PPT Presentation
04832250 Computer Networks (Honor Track) A Data Communication and Device Networking Perspective A Data Communication and Device Networking Perspective Module 5: End-to-End Transport Prof. Chenren Xu Center for
1
2
applications with the desired reliability or quality
network
Physical Link Network Transport Application
TCP IP 802.11 app IP 802.11 IP 802.3 TCP IP 802.3 app Router Host Host 802.11 IP TCP App, e.g., HTTP Segment Packet Frame TCP (Streams) UDP (Datagrams) Connections Datagrams Bytes are delivered reliably, and in order Messages may be lost, reordered, duplicated Arbitrary length content Limited message size Flow control matches sender to receiver Can send regardless
Congestion control matches sender to network Can send regardless
3
4
Socket, Port #1 Socket, Port #2
Primitive Meaning SOCKET Create a new communication endpoint BIND Associate a local address (port) with a socket LISTEN Announce willingness to accept connections ACCEPT Passively establish an incoming connection CONNECT Actively attempt to establish a connection SEND (TO) Send some data over the socket RECEIVE (FROM) Receive some data over the socket CLOSE Release the socket Only needed for Streams To/From forms for Datagrams
5
Port Protocol Use 20, 21 FTP File transfer 22 SSH Remote login, replacement for Telnet 25 SMTP Email 80 HTTP World Wide Web 110 POP-3 Remote email access 143 IMAP Remote email access 443 HTTPS Secure Web (HTTP over SSL/TLS) 543 RTSP Media player control 631 IPP Printer sharing
6
I just want to send a packet! Network
7
application processes
Client Server Time 1: socket 2: bind 1: socket 6: sendto 3: recvfrom* 4: sendto 5: recvfrom* 7: close 7: close *= call blocks request reply App Port Mux/Demux App App Application Transport (TCP) Network (IP) packet Message queues Ports
8
SYN! ACK! Network SYNACK!
9
10
1 2 3 Active party (client) Passive party (server) Time Active party (client) Passive party (server) X X
REJECT REJECT Delayed or duplicates
11
LISTEN SYN_RCVD SYN_SENT ESTABLISHED 1 2 3 Active party (client) Passive party (server) Time CLOSED CLOSED ESTABLISHED
Both parties run instances of this state machine
12
§ Active sends FIN(x), ACKs § Passive sends FIN(y), ACKs § FINs are retransmitted if lost
Network FIN! FIN! Active party Passive party 1 2
13
Both parties run instances of this state machine Active party Passive party 1 2 FIN_WAIT_1 LAST_ACK FIN_WAIT_2 TIME_WAIT CLOSED CLOSED ESTABLISHED (timeout) ESTABLISHED
before completing the close, but why?
§ ACK might have been lost, in which case FIN will be resent for an orderly close § Could otherwise interfere with a subsequent connection
A/B means event A triggers the transition, with action B
考!
14
15
Yeah! Network
16
§ Fine for LAN (only one frame fit) § Not efficient for network paths with BD >> 1 packet
§ Assume pkt is 1250 Byte = 10 Kb, 10 Kb / 100 ms = 100 Kbps = 0.1 Mbps = only 10% channel utilization § What if R = 10 Mbps?
§ Need W = 2BD to fill network path
Frame 0 ACK 0 Timeout Time Sender Receiver Frame 1 ACK 1
17
.. 5 6 7 .. 2 3 4 5 2 3 .. LAR LFS W=5 Acked Unacked 3 .. Unavailable Available
Sliding Window LAR LFS W=5 Acked Unavailable
Unacked .. 5 6 7 2 3 4 5 2 3 .. LAR LFS W=5 Acked 3 .. Unavailable Available
.. 2 Unacked .. ..
18
the next segment
§ State variable, LAS (LAST ACK SENT)
§ If seq. number is LAS+1, accept and pass it to app, update LAS, send ACK § Otherwise discard (as out of order) and resend an ACK of LAS
detect losses
§ On timeout or receiving an duplicate ACK of LAR, resends buffered packets starting at LAR+1
§ Buffer segments [LAS+1, LAS+W] § Pass up to app in-order segments from LAS+1, and update LAS § Send ACK for LAS regardless
to detect losses
§ On timeout for segment, resend it § Hope to resend fewer segments
http://www.ccs-labs.org/teaching/rn/animations/gbn_sr/
19
Time
Acks (at Receiver) Delay (=RTT/2) Transmissions (at Sender) Retransmissions Loss Timeout
20
Pkt 1: A sends a SYN to B with seq# 0 and ack# 0 Pkt 3: A adds a 1 to B’s ISN and sends an ack to B to acknowledge its ISN Pkt 4: A sends a 100 byte long GET request to B Pkt 6: A sends another request of 50
expected seq# should be 151. It acknowledges the 200 bytes sent by B by sending an ack# of 201
Pkt 2: B starts its seq# of 0 and acknowledges A’s seq # by adding a 1 Pkt 5: B responds to the request from A. Since B has not sent data yet, its seq # is still 1. It sends the packet with ack = 101 to acknowledge receipt of the 100 bytes from A Pkt 7: B responds to the request with a 1000 byte
expected seq# is 1201. It receives 50 bytes from A, so it acks with 151.
21
§ LAS = last ack sent, app pulls in-order data from buffer with recv() call
§ LAS rises, but we can’t slide window!
§ Must drop segments until app recvs!
§ Window slides
Streaming video Big Iron Mobile Arg …
.. 5 6 7 5 2 3 .. LAS W=5 Finished 3 .. Too high
5 5 5 5 Acceptable Sliding Window .. 5 6 7 2 3 LAS W=5 Finished 3 .. Too high Nothing Acceptable 4 4 Acked 4 4 4 Acked .. 5 6 7 2 3 .. LAS W=5 Finished 3 .. Too high Acceptable 5 4 4 4 Acked .. 5 6 7 5 2 3 .. LAS W=5 Finished 3 .. Too high Acceptable 5 5 5 5 4 4 Acked
22
23
.. 5 6 7 5 2 3 .. LAS W=5 Finished 3 .. Too high Acceptable
5 5 5 5 4 4 Acked .. 5 6 7 5 2 3 .. LAS WIN=3 Finished 3 .. Too high 5 5 5 4 4 Acked
24
25
§ Set timer when a segment is sent § Cancel timer when ack is received § If timer fires, retransmit data as lost
§ Too long wastes network capacity § Too short leads to spurious resends
§ Short, fixed, predictable RTT
§ Wide range, variable RTT
Lost? Network Retransmit!
100 200 300 400 500 600 700 800 900 1000 50 100 150 200 Round Trip Time (ms) Variation due to queuing at routers, changes in network paths, etc. BCNàSEAàBCN Propagation (+transmission) delay ≈ 2D Need to adapt to the network conditions
26
§ SRTTN+1 = 0.9*SRTTN + 0.1*RTTN+1 § SvarN+1 = 0.9*SvarN + 0.1*|RTTN+1– SRTTN+1|
200 400 600 800 1000 50 100 150 200
Seconds RTT (ms) SRTT Svar
200 400 600 800 1000 50 100 150 200
Seconds RTT (ms) Timeout (SRTT + 4*Svar) Early timeout
27
§ With adaptive timeout
TCP TCP TCP
We love TCP/IP! Network We love TCP/IP! We love TCP/IP!
We ♥ TCP/IP!
28
Four segments, each with 512 bytes
2048 bytes of data delivered to app in a single recv() call
A B data B → A
ACK A → B ACK B → A
data A → B
29
30
§ List up to 3 ranges of received bytes
§ “Three duplicate ACKs” treated as loss
ACK up to 100 and 200-299 ACK 100 ACK 100,
200-299
ACK 100,
200-399
ACK 100,
200-499 Sender decides 100-199 is lost
31
What’s the hold up? Network
32
33
§ Delay and loss rise sharply with more load § Throughput falls below load (due to loss) § Goodput may fall below throughput (due to spurious retransmissions)
Want to operate network just before the onset of congestion
. . .
. . . . . .
. . . Input Buffer Output Buffer Fabric Input Output Router
(FIFO) Queue Queued Packets Router
34
work together
load is constantly changing
parts of the network
has an overall picture of its state
their own view of the network
usage as a whole is efficient and fair
loads continue to change over time
35
§ Now we learn what fair means
§ Example network with traffic A → B, B → C and A → C § How much traffic can we carry?
§ A → C uses more network resources (two links) than A → B or B → C § Host A sends two flows, B sends one
§ More important to avoid starvation; “Equal per flow” is good enough
§ Give equal bandwidth to each flow § A → B: ½ unit, B → C: ½, and A → C: ½ § Total traffic carried is 1 ½ units
§ Maximize total traffic in network § A → B: 1 unit, B → C: 1, and A → C: 1 § Total traffic carried is 2 units
36
37
the rate of a smaller flow
1. Start with all flows at rate 0 2. Increase the flows until there is a new bottleneck in the network 3. Hold fixed the rate of the flows that are bottlenecked 4. Go to step 2 for any remaining flows
Bottleneck Bottleneck Bottleneck
When rate=1/3, flows B, C, and D bottleneck R4 – R5. Fix B, C, and D, continue to increase A When rate=2/3, flow A bottlenecks R2 – R3. Done. End with A=2/3, B, C, D=1/3, and R2 – R3, R4 – R5
capacity that can’t be used
38
39
§ Example: Additive Increase Multiplicative Decrease
AIMD! Sawtooth
40
§ But do not talk to each other directly
§ Tells hosts if network is congested
Rest of Network Bottleneck Router Host 1 Host 2 1 1 1
Each point is a possible allocation AI and MD move the allocation
Host 1 Host 2 1 1 Fair, y=x Efficient, x+y=1 Optimal Allocation Congested Multiplicative Decrease Additive Increase Host 1 Host 2 1 1 Fair Efficient Congested A starting point
time for rate of each host
efficient and fair when hosts run it
§ Holds for more general topologies
laws do not! (Try MIAD, MIMD, AIAD)
the network
Always converge to good allocation!
Multiplicative Decrease Additive Increase Time Host 1 or 2’s Rate
41
Signal Example Protocol Pros / Cons Packet loss TCP NewReno Cubic TCP (Linux) Hard to get wrong Hear about congestion late Packet delay Compound TCP (Windows) Hear about congestion early Need to infer congestion Router indication TCPs with Explicit Congestion Notification Hear about congestion early Require router support
42
§ Initially fine for reliability
§ Links stayed busy but transfer rates fell by orders of magnitude!
Congestion collapse
43
44
1988 1990 1970 1980 1975 1985 Origins of “TCP” (Cerf & Kahn, ’74) 3-way handshake (Tomlinson, ‘75) TCP Reno (Jacobson, ‘90) Congestion collapse Observed, ‘86 TCP/IP “flag day” (BSD Unix 4.2, ‘83) TCP Tahoe (Jacobson, ’88) Pre-history Congestion control . . . TCP and IP (RFC 791/793, ‘81)
2010 2000 1995 2005 ECN (Floyd, ‘94) TCP Reno (Jacobson, ‘90) TCP New Reno (Hoe, ‘95) TCP BIC (Linux, ’04) TCP with SACK (Floyd, ‘96) Diversification Classic congestion control . . . 1990 TCP LEDBAT (IETF ’08) TCP Vegas (Brakmo, ‘93) TCP CUBIC (Linux, ’06) . . . Background Router support Delay based FAST TCP (Low et al., ’04) Compound TCP (Windows, ’07)
45
§
ACKs “clock” data segments
Tick Tock! Ack 1 2 3 4 5 6 7 8 9 10 20 19 18 17 16 15 14 13 12 11 Data
46
Fast link Fast link Slow (bottleneck) link Queue Fast link Fast link Slow (bottleneck) link Segments “spread out” Slow link Acks maintain spread Slow link Segments spread Queue no longer builds
47
§ Fixed sliding window doesn’t adapt and is rough on the network (loss!) § AI with small bursts adapts cwnd gently to the network, but might take a long time to become efficient
Slow-start
48
49
50
§ Instead of MD cwnd (for AIMD)
§ Slow-start ramps up the ACK clock
§ Done in TCP Reno
51
§ Carries highest in-order seq. number § Normally a steady advance
§ Tell us some new data did arrive, but it was not next segment, thus the next segment may be lost
AIMD sawtooth
52
Ack 1 2 3 4 5 5 5 5 5 5
Ack 10 Ack 11 Ack 12 Ack 13
. . .
Ack 13 Ack 13 Ack 13 Data 14
. . .
Ack 13 Ack 20
. . . . . .
Data 20
Third duplicate ACK, so send 14 Retransmission fills in the hole at 14 ACK jumps after loss is repaired . . . . . . Data 14 was lost earlier, but got 15 to 20
53
54
ACK clock running
continue with a smaller cwnd
Ack 1 2 3 4 5 5 5 5 5 5
Third duplicate ACK, so send 14 Data 14 was lost earlier, but got 15 to 20 Retransmission fills in the hole at 14 Set ssthresh, cwnd = cwnd/2 More ACKs advance window; may send segments before jump Ack 12 Ack 13 Ack 13 Ack 13 Ack 13 Data 14 Ack 13 Ack 20 . . . . . . Data 20 Data 21 Data 22 Ack 13 Exit Fast Recovery
55
MD of ½ , no slow-start ACK clock running TCP sawtooth
56
57
Signal Example Protocol Pros / Cons Packet loss Classic TCP Cubic TCP (Linux) Hard to get wrong Hear about congestion late Packet delay Compound TCP (Windows) Hear about congestion early Need to infer congestion Router indication TCPs with Explicit Congestion Notification Hear about congestion early Require router support
58