Download Course Computer Communications Study Period 2, 2012

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Course on Computer Communication and
Networks
Lecture 5
Chapter 3; Transport Layer, Part B
EDA344/DIT 420, CTH/GU
Based on the book Computer Networking: A Top Down Approach, Jim Kurose, Keith Ross, Addison-Wesley.
Marina Papatriantafilou – Transport layer part2
1
Roadmap Transport Layer
•
•
•
•
•
transport layer services
multiplexing/demultiplexing
connectionless transport: UDP
principles of reliable data transfer
connection-oriented transport: TCP
– reliable transfer
• Acknowledgements
• Retransmissions
• Connection management
• Flow control and buffer space
– Congestion control
• Principles
• TCP congestion control
Marina Papatriantafilou – Transport layer part2
3b-3
socket
door
TCP: Overview
RFCs: 793,1122,1323, 2018, 5681
 full duplex data:
 bi-directional data flow in same
connection
 MSS: maximum segment size
• point-to-point:
– one sender, one receiver
• reliable, in-order byte steam:
• pipelined:
 connection-oriented:
 handshaking (exchange of control
msgs) inits sender & receiver
state before data exchange
 flow control:
– TCP congestion and flow
control set window size
 sender will not overwhelm
receiver
 congestion control:
application
writes data
application
reads data
TCP
send buffer
TCP
receive buffer
 sender will not flood network
(but still try to maximize
throughput)
socket
door
segment
Marina Papatriantafilou – Transport layer part2
3-4
TCP segment structure
32 bits
URG: urgent data
(generally not used)
source port #
dest port #
sequence number
ACK: ACK # valid
PSH: push data now
(generally not used)
RST, SYN, FIN:
connection estab
(setup, teardown
commands)
Internet
checksum
(as in UDP)
acknowledgement number
head not
UAP R S F
len used
checksum
counting
by bytes
of data
(not segments!)
receive window
Urg data pointer
options (variable length)
# bytes
rcvr willing
to buffer
(flow control)
application
data
(variable length)
Marina Papatriantafilou – Transport layer part2
3-5
Roadmap Transport Layer
•
•
•
•
•
transport layer services
multiplexing/demultiplexing
connectionless transport: UDP
principles of reliable data transfer
connection-oriented transport: TCP
– reliable transfer
• Acknowledgements
• Retransmissions
• Connection management
• Flow control and buffer space
– Congestion control
• Principles
• TCP congestion control
Marina Papatriantafilou – Transport layer part2
3b-6
TCP seq. numbers, ACKs
outgoing segment from sender
source port #
sequence numbers:
sequence number
acknowledgement number
rwnd
checksum
window size
–“number” of first byte in
segment’s data
N
acknowledgements:
–seq # of next byte
expected from other side
–cumulative ACK
dest port #
sender sequence number space
sent
ACKed
sent, not- usable not
yet ACKed but not usable
yet sent
(“inflight”)
incoming segment to sender
source port #
dest port #
sequence number
acknowledgement number
rwnd
A
checksum
Marina Papatriantafilou – Transport layer part2
3-7
TCP seq. numbers, ACKs
Always ack next in-order expected byte
Host B
Host A
User
types
‘C’
Seq=42, ACK=79, data = ‘C’
host ACKs
receipt of ‘C’,
echoes back
Seq=79, ACK=43, data = ‘C’
‘C’
host ACKs
receipt
of echoed ‘C’
Seq=43, ACK=80
Simple example scenario
Based on telnet msg exchange
Marina Papatriantafilou – Transport layer part2
3-8
TCP:
cumulative Ack - retransmission scenarios
Host B
Host A
Host B
Host A
Seq=92, 8 bytes of data
Seq=92, 8 bytes of data
Seq=100, 20 bytes of data
Seq=100, 20 bytes of data
X
ACK=100
timeout
timeout
SendBase=92
ACK=100
ACK=120
ACK=120
Seq=120, 15 bytes of data
SendBase=100
Seq=92, 8
bytes of data
SendBase=120
ACK=120
SendBase=120
Cumulative ACK
Marina Papatriantafilou – Transport layer part2
(Premature) timeout
3-9
Roadmap Transport Layer
•
•
•
•
•
transport layer services
multiplexing/demultiplexing
connectionless transport: UDP
principles of reliable data transfer
connection-oriented transport: TCP
– reliable transfer
• Acknowledgements
• Retransmissions
• Connection management
• Flow control and buffer space
– Congestion control
• Principles
• TCP congestion control
Marina Papatriantafilou – Transport layer part2
3b-12
Q: how to set TCP timeout value?
 longer than endto-end RTT
 but that varies!!!
 too short timeout:
premature,
unnecessary
retransmissions
 too long: slow
reaction to loss
application
segment
transport
network
link
physical
application
transport
network
link
physical
Marina Papatriantafilou – Transport layer part2
network
link
physical
application
transport
network
link
physical
application
segment
transport
network
link
physical
13
TCP round trip time, timeout estimation
EstimatedRTT = (1-)*EstimatedRTT + *SampleRTT

exponential weighted moving average: influence of past
sample decreases exponentially fast
RTT: gaia.cs.umass.edu to fantasia.eurecom.fr
typical value:  = 0.125
RTT (milliseconds)
RTT: gaia.cs.umass.edu to fantasia.eurecom.fr
350

RTT (milliseconds)
300
250
200
sampleRTT
EstimatedR
150
100
1
8
15
22
29
DevRTT = (1-)*DevRTT +
*|SampleRTT-EstimatedRTT|
36
43
50
57
64
71
78
85
92
99
106
time
(seconds)
time (seconnds)
SampleRTT
Estimated RTT
(typically,  = 0.25)
TimeoutInterval = EstimatedRTT + 4*DevRTT
“safety margin”
Marina Papatriantafilou – Transport layer part2
3-14
TCP fast retransmit (RFC 5681)
 time-out can be long:
Host B
Host A
 long delay before resending
lost packet
 IMPROVEMENT: detect lost
segments via duplicate ACKs
Seq=92, 8 bytes of data
Seq=100, 20 bytes of data
X
TCP fast retransmit
timeout
ACK=100
if sender receives 3 duplicate
ACKs for same data
•
ACK=100
ACK=100
Seq=100, 20 bytes of data
resend unacked segment
with smallest seq #
 likely that unacked segment
Implicit NAK!
lost, so don’t wait for
Q: Why need at
timeout
least 3?
Marina Papatriantafilou – Transport layer part2
3b-15
Roadmap Transport Layer
•
•
•
•
•
transport layer services
multiplexing/demultiplexing
connectionless transport: UDP
principles of reliable data transfer
connection-oriented transport: TCP
– reliable transfer
• Acknowledgements
• Retransmissions
• Connection management
• Flow control and buffer space
– Congestion control
• Principles
• TCP congestion control
Marina Papatriantafilou – Transport layer part2
3b-16
Connection Management
before exchanging data, sender/receiver “handshake”:
• agree to establish connection + connection parameters
application
connection state: ESTAB
connection variables:
seq # client-to-server
server-to-client
rcvBuffer size
at server,client
network
Socket clientSocket =
newSocket("hostname","port
number");
Marina Papatriantafilou – Transport layer part2
application
connection state: ESTAB
connection Variables:
seq # client-to-server
server-to-client
rcvBuffer size
at server,client
network
Socket connectionSocket =
welcomeSocket.accept();
3-17
Setting up a connection: TCP 3-way handshake
client state
server state
LISTEN
choose init seq num, x
send TCP SYN msg
SYNSENT
received SYN/ACK(x)
server is live;
ESTAB
send ACK for SYN/ACK;
this segment may contain
client-to-server data
SYN=1, Seq=x
SYN=1, Seq=y
ACK=1; ACKnum=x+1
choose init seq num, y
send TCP SYN/ACK
SYN RCVD
msg, acking SYN
Reserve buffer
ACK=1, ACKnum=y+1
Marina Papatriantafilou – Transport layer part2
received ACK(y)
indicates client is live
Transport Layer
ESTAB
3-18
TCP: closing a connection
client state
server state
ESTAB
ESTAB
clientSocket.close()
FIN_WAIT_1
FIN_WAIT_2
can no longer
send but can
receive data
FIN=1, seq=x
CLOSE_WAIT
ACK=1; ACKnum=x+1
wait for server
close
LAST_ACK
FIN=1, seq=y
can no longer
send data
TIME_WAIT
timed wait
(typically 30s)
can still
send data
ACK=1; ACKnum=y+1
CLOSED
CLOSED
simultaneous FINs
can be handled
RST: alternative way to close connection
immediately, when error occurs
Marina Papatriantafilou – Transport layer part2
3-19
Roadmap Transport Layer
•
•
•
•
•
transport layer services
multiplexing/demultiplexing
connectionless transport: UDP
principles of reliable data transfer
connection-oriented transport: TCP
– reliable transfer
• Acknowledgements
• Retransmissions
• Connection management
• Flow control and buffer space
– Congestion control
• Principles
• TCP congestion control
Marina Papatriantafilou – Transport layer part2
3b-21
TCP flow control
application
might remove data from
TCP socket buffers ….
… slower than TCP
is delivering
(i.e. slower than
sender is sending)
application
process
application
TCP socket
receiver buffers
TCP
code
IP
code
flow control
receiver controls sender, so
sender won’t overflow
receiver’s buffer by transmitting
too much, too fast
Marina Papatriantafilou – Transport layer part2
OS
from sender
receiver protocol stack
3-22
TCP flow control
• receiver “advertises” free
buffer space through rwnd
value in header
– RcvBuffer size set via socket
options (typical default 4 Kbytes)
– OS can autoadjust RcvBuffer
• sender limits unacked (“inflight”) data to receiver’s
rwnd value
to application process
RcvBuffer
rwnd
buffered data
free buffer space
TCP segment payloads
receiver-side buffering
– s.t. receiver’s buffer will not
overflow
source port #
To sender
dest port #
sequence number
acknowledgement number
A
rwnd
checksum
Marina Papatriantafilou – Transport layer part2
3-23
Q: Is TCP stateful or stateless?
Marina Papatriantafilou – Transport layer part2
24
Roadmap Transport Layer
•
•
•
•
•
transport layer services
multiplexing/demultiplexing
connectionless transport: UDP
principles of reliable data transfer
connection-oriented transport: TCP
– reliable transfer
• Acknowledgements
• Retransmissions
• Connection management
• Flow control and buffer space
– Congestion control
• Principles
• TCP congestion control
Marina Papatriantafilou – Transport layer part2
3b-25
Principles of congestion control
congestion:
• informally: “too many sources sending too much data
too fast for network to handle”
• manifestations:
– lost packets (buffer overflow at routers)
– long delays (queueing in router buffers)
Marina Papatriantafilou – Transport layer part2
Fig. A. Tanenbaum
Computer Networks
Need for flow control
Marina Papatriantafilou – Transport layer part2
Need for congestion control
27
delay
Causes/costs of congestion
original data: lin
lin
R/2
 Recall queueing
behaviour + losses
 Losses =>
retransmissions => Host B
even higher load…
throughput:
lout
Host A
output link capacity: R
link buffers
lout
R/2
lin
R/2
 Ideal per-connection
throughput: R/2 (if 2
connections)
Marina Papatriantafilou – Transport layer part2
 reality 
3-28
Approaches towards congestion control
end-end congestion
control:
network-assisted
congestion control:
 no explicit feedback
from network
 routers provide feedback
to end-systems eg.
 congestion inferred
from end-system
observed loss, delay
 approach taken by TCP
Marina Papatriantafilou – Transport layer part2
 a single bit indicating
congestion
 explicit rate for sender
to send at
3-32
Roadmap Transport Layer
•
•
•
•
•
transport layer services
multiplexing/demultiplexing
connectionless transport: UDP
principles of reliable data transfer
connection-oriented transport: TCP
– reliable transfer
• Acknowledgements
• Retransmissions
• Connection management
• Flow control and buffer space
– Congestion control
• Principles
• TCP congestion control
Marina Papatriantafilou – Transport layer part2
3b-33
TCP congestion control:
additive increase multiplicative decrease
end-end control (no network assistance), sender limits transmission
How does sender perceive congestion?
 loss = timeout or 3 duplicate acks
 TCP sender reduces rate (Congestion Window) then

rate
~
~
cwnd
RTT
bytes/sec
 Additive Increase: increase cwnd by 1 MSS every RTT until loss detected
 Multiplicative Decrease: cut cwnd in half after loss
AIMD saw tooth
behavior: probing
for bandwidth
cwnd: TCP sender
congestion window size
 To start with: slow start
additively increase window size …
…. until loss occurs (then cut window in half)
time
Marina Papatriantafilou – Transport layer part2
3-34
TCP Slow Start
 initially cwnd = 1 MSS
 double cwnd every ack of
prev.ious “batch”
 done by incrementing cwnd for
every ACK received
summary: initial rate is slow
but ramps up exponentially
fast
Host A
Host B
RTT
when connection begins,
increase rate exponentially
until first loss event:
time
then, saw-tooth
Marina Papatriantafilou – Transport layer part2
3-35
TCP cwnd:
from exponential to linear growth + reacting to loss
Reno: loss indicated by
timeout or 3 duplicate ACKs:
cwnd is cut in half; then grows
linearly
Implementation:
 variable ssthresh (slow
start threshold)
 on loss event, ssthresh =
½*cwnd
Marina Papatriantafilou – Transport layer part2
Non-optimized: loss indicated by timeout:
cwnd set to 1 MSS; then window slow start
to threshold, then grows linearly
3-36
Q: How many windows does a TCP’s sender maintain?
Fig. A. Tanenbaum
Computer Networks
Need for flow control
Marina Papatriantafilou – Transport layer part2
Need for congestion control
39
TCP combined flow-ctrl, congestion ctrl windows
sender sequence number space
Min{cwnd, rwnd}
last byte
ACKed
sent, notyet ACKed
(“inflight”)
last byte
sent
TCP sending rate:
 send min {cwnd, rwnd}
bytes, wait for ACKS, then
send more
sender limits transmission:
LastByteSent< Min{cwnd, rwnd}
LastByteAcked
 cwnd is dynamic, function of perceived network
congestion,
 rwnd dymanically limited by receiver’s buffer space
Marina Papatriantafilou – Transport layer part2
Transport Layer
3-40
TCP Fairness
fairness goal: if K TCP sessions share same
bottleneck link of bandwidth R, each should
have average rate of R/K
TCP connection 1
TCP connection 2
bottleneck
router
capacity R
Marina Papatriantafilou – Transport layer part2
Transport Layer
3-41
Roadmap Transport Layer
•
•
•
•
•
transport layer services
multiplexing/demultiplexing
connectionless transport: UDP
principles of reliable data transfer
connection-oriented transport: TCP
– reliable transfer
• Acknowledgements
• Retransmissions
• Connection management
• Flow control and buffer space
– Congestion control
• Principles
• TCP congestion control
Marina Papatriantafilou – Transport layer part2
3b-42
Chapter 3: summary
 principles behind transport
layer services:
 Addressing
 reliable data transfer
 flow control
 congestion control
 instantiation, implementation
in the Internet
next:
• leaving the network
“edge” (application,
transport layers)
• into the network
“core”
 UDP
 TCP
Marina Papatriantafilou – Transport layer part2
3-43
Some review questions on this part
• Describe TCP’s flow control
• Why does TCp do fast retransmit upon a 3rd ack and not a 2nd?
• Describe TCP’s congestion control: principle, method for detection
of congestion, reaction.
• Can a TCP’s session sending rate increase indefinitely?
• Why does TCP need connection management?
• Why does TCP use handshaking in the start and the end of
connection?
• Can an application have reliable data transfer if it uses UDP? How or
why not?
Marina Papatriantafilou – Transport layer part2
3b-44
Reading instructions chapter 3
• KuroseRoss book
Careful
Quick
3.1, 3.2, 3.4-3.7
3.3
• Other resources (further study)
– Eddie Kohler, Mark Handley, and Sally Floyd. 2006. Designing DCCP: congestion
control without reliability. SIGCOMM Comput. Commun. Rev. 36, 4 (August 2006),
27-38. DOI=10.1145/1151659.1159918
http://doi.acm.org/10.1145/1151659.1159918
– http://research.microsoft.com/apps/video/default.aspx?id=1
04005
– Exercise/throughput analysis TCP in following slides
Marina Papatriantafilou – Transport layer part2
3-45
Extra slides, for further study
Marina Papatriantafilou – Transport layer part2
3: Transport Layer
3b-46
TCP throughput
• avg. TCP throughput as function of window size, RTT?
– ignore slow start, assume always data to send
• W: window size (measured in bytes) where loss occurs
– avg. window size (# in-flight bytes) is ¾ W
– avg. trhoughput is 3/4W per RTT
3 W
bytes/sec
avg TCP trhoughput =
4 RTT
W
W/2
Marina Papatriantafilou – Transport layer part2
Transport Layer
3-47
TCP Futures: TCP over “long, fat pipes”
• example: 1500 byte segments, 100ms RTT, want
10 Gbps throughput
• requires W = 83,333 in-flight segments
• throughput in terms of segment loss probability, L
[Mathis 1997]:
. MSS
1.22
TCP throughput =
RTT L
➜ to achieve 10 Gbps throughput, need a loss rate of L =
2·10-10 – a very small loss rate!
• new versions of TCP for high-speed
Marina Papatriantafilou – Transport layer part2
Transport Layer
3-48
Why is TCP fair?
two competing sessions:
 additive increase gives slope of 1, as throughout increases
 multiplicative decrease decreases throughput proportionally
R
equal bandwidth share
loss: decrease window by factor of 2
congestion avoidance: additive increase
loss: decrease window by factor of 2
congestion avoidance: additive increase
Connection 1 throughput
Marina Papatriantafilou – Transport layer part2
R
3-49
Fairness (more)
Fairness, parallel TCP
Fairness and UDP
connections
multimedia apps often application can open
do not use TCP
multiple parallel
connections between two
 do not want rate
hosts
throttled by
congestion control
web browsers do this
e.g., link of rate R with 9
instead use UDP:
existing connections:
 send audio/video at
constant rate, tolerate
packet loss
Marina Papatriantafilou – Transport layer part2
 new app asks for 1 TCP, gets rate
R/10
 new app asks for 11 TCPs, gets R/2
3-50
TCP delay modeling (slow start – related)
Q: How long does it take to
Notation, assumptions:
receive an object from a Web • Assume one link between client
and server of rate R
server after sending a
• Assume: fixed congestion
request?
• TCP connection establishment
• data transfer delay
•
•
•
•
Marina Papatriantafilou – Transport layer part2
window, W segments
S: MSS (bits)
O: object size (bits)
no retransmissions (no loss, no
corruption)
Receiver has unbounded buffer
3: Transport Layer
3b-51
TCP delay Modeling: simplified, fixed
window
K:= O/WS
Case 1: WS/R > RTT + S/R:
ACK for first segment in window
returns before window’s worth
of data nsent
delay = 2RTT + O/R
O
Case 2: WS/R < RTT + S/R:
wait for ACK after sending
window’s worth of data sent
delay = 2RTT + O/R
+ (K-1)[S/R + RTT - WS/R]
Marina Papatriantafilou – Transportdelay
layer part2 2 RTT 
P
3: Transport Layer
 idleTime
p
3b-52
TCP Delay Modeling: Slow Start
initiate TCP
connection
Delay components:
• 2 RTT for connection estab request
object
and request
• O/R to transmit object
RTT
• time server idles due to slow
start
Server idles:
P = min{K-1,Q} times
where
- Q = #times server stalls
until cong. window is larger
than a “full-utilization” window
(if the object were of
object
unbounded size).
delivered
first window
= S/R
second window
= 2S/R
third window
= 4S/R
fourth window
= 8S/R
complete
transmission
Example:
• O/S = 15 segments
time at
server
time
at
- K = #(incremental-sized)
•
K
=
4
windows
client
congestion-windows that
•Q=2
“cover” the object.
• Server idles P = min{K-1,Q} = 2 times
3: Transport Layer
Marina Papatriantafilou – Transport layer part2
3b-53
TCP Delay Modeling (slow start - cont)
S
 RTT  time from when server starts to send segment
R
until server receives acknowledg ement
initiate TCP
connection
2k 1
S
 time to transmit the kth window
R

request
object
S
k 1 S 

RTT

2
 idle time after the kth window
 R
R 
first window
= S/R
RTT
second window
= 2S/R
third window
= 4S/R
P
O
delay   2 RTT   idleTime p
R
p 1
P
O
S
S
  2 RTT   [  RTT  2 k 1 ]
R
R
k 1 R
O
S
S
  2 RTT  P[ RTT  ]  (2 P  1)
R
R
R
Marina Papatriantafilou – Transport layer part2
fourth window
= 8S/R
complete
transmission
object
delivered
time at
server
time at
client
3: Transport Layer
3b-54
TCP Delay Modeling
Recall K = number of windows that cover object
How do we calculate K ?
K  min {k : 20 S  21 S    2 k 1 S  O}
 min {k : 20  21    2 k 1  O / S}
O
k
 min {k : 2  1  }
S
O
 min {k : k  log 2 (  1)}
S
O


 log 2 (  1)
S


Calculation of Q, number of idles for infinite-size object,
is similar.
Marina Papatriantafilou – Transport layer part2
3b-55
Related documents