CCN - Chapter - 3
CCN - Chapter - 3
our goals:
understand learn about Internet
principles behind transport layer
transport layer protocols:
services: • UDP: connectionless
• multiplexing, transport
demultiplexing • TCP: connection-
• reliable data oriented reliable
transfer transport
• flow control • TCP congestion
• congestion control
control
provide logical n
transport
different hosts
lo
gi
ca
transport protocols run in
enl
end systems
d-
en
• send side: breaks app
d
tr
messages into
a
ns
segments, passes to
po
network layer
rt
• rcv side: reassembles applicatio
n
segments into transport
network
messages, passes to data link
physical
app layer
more than one transport
protocol available to apps
• Internet: TCP and UDP
Transport Layer 3-3
Transport vs. network
layer
network layer:
household analogy:
logical
communication 12 kids in Ann’s house
sending letters to 12
between hosts kids in Bill’s house:
transport layer: hosts = houses
logical processes = kids
communication app messages =
between letters in envelopes
transport protocol =
processes Ann and Bill who
• relies on, demux to in-house
enhances, siblings
network layer network-layer protocol
services = postal service
lo
network data link
gi
data link physical
• flow control
ca
physical
network
l en
data link
• connection setup
d-
physical
en
unreliable, network
d
data link
tr
unordered delivery:
a
physical
ns
network
po
UDP data link
r
physical
t
network
• no-frills extension of data link
physical
applicatio
n
“best-effort” IP network
data link transport
network
services not
physical
data link
physical
available:
• delay guarantees
• bandwidth
guarantees Transport Layer 3-5
Chapter 3 outline
3.1 transport-layer 3.5 connection-
services oriented transport:
3.2 multiplexing TCP
and • segment structure
demultiplexing • reliable data transfer
• flow control
3.3 connectionless
• connection
transport: UDP management
3.4 principles of 3.6 principles of
reliable data congestion control
transfer
3.7 TCP congestion
control
Transport Layer 3-6
Multiplexing/
demultiplexing
multiplexing at sender:
handle data from demultiplexing at receiver:
multiple use header info to deliver
sockets, add transport received segments to corre
header (later used for socket
demultiplexing)
application
length checksum
why is there a UDP?
no connection
application establishment (which
data can add delay)
(payload) simple: no connection
state at sender,
receiver
small header size
UDP segment format no congestion control:
UDP can blast away as
fast as desired
wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
send receive
side side
sender receiver
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
extract(rcvpkt,data)
deliver_data(data)
sndpkt = make_pkt(ACK, chksum)
udt_send(sndpkt)
L 8000 bits
Dtrans = R = 9 = 8 microsecs
10 bits/sec
U L/R .008
sender = = = 0.00027
RTT + L / R 30.008
U 3L / R .0024
sender = = = 0.00081
RTT + L / R 30.008
window size
acknowledgements: N
• seq # of next byte
expected from other
side sender sequence number space
User
types
‘C’
Seq=42, ACK=79, data = ‘C’
host ACKs
receipt of
‘C’, echoes
Seq=79, ACK=43, data = ‘C’ back ‘C’
host ACKs
receipt
of echoed
‘C’ Seq=43, ACK=80
300
(milliseconds)
RTT
250
RTT (milliseconds)
200
sampleRTT
150
EstimatedRTT
100
1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106
time (seconnds)
time Transport Layer 3-61
SampleRTT Estimated RTT
TCP round trip time,
timeout
timeout interval: EstimatedRTT plus “safety margin”
• large variation in EstimatedRTT -> larger safety margin
estimate SampleRTT deviation from EstimatedRTT:
DevRTT = (1-)*DevRTT +
*|SampleRTT-EstimatedRTT|
(typically, = 0.25)
if (y > SendBase) {
SendBase = y
/* SendBase–1: last cumulatively ACKed byte */
if (there are currently not-yet-acked segments)
start timer
else stop timer
} Transport Layer 3-66
TCP: retransmission
scenarios
Host A Host B Host A Host B
SendBase=92
Seq=92, 8 bytes of data Seq=92, 8 bytes of data
timeo
ACK=100
ut
ut
X
ACK=100
ACK=120
SendBase=120
X
ut
ACK=120
cumulative ACK
Transport Layer 3-68
TCP ACK generation [RFC 1122, RFC
2581]
ACK=100
timeo
ACK=100
ut
ACK=100
ACK=100
Seq=100, 20 bytes of data
choose x
req_conn(x)
ESTAB
acc_conn(x)
ESTAB
choose x choose x
req_conn(x) req_conn(x)
ESTAB ESTAB
retransmit acc_conn(x) retransmit acc_conn(x)
req_conn( req_conn(
x) x)
ESTAB ESTAB
data(x+1) accept
req_conn(x)
retransmit data(x+1
data(x+1) )
connection connection
client x completes server x completes server
client
terminat forgets x terminat forgets x
es req_conn(x)
es
ESTAB ESTAB
data(x+1) accept
half open connection! data(x+1
(no client!) )
Transport Layer 3-78
TCP 3-way handshake
Socket connectionSocket =
welcomeSocket.accept();
Socket clientSocket =
SYN(x) newSocket("hostname","port
number");
SYNACK(seq=y,ACKnum=x+1)
create new socket for listen SYN(seq=x)
communication back to client
SYN SYN
rcvd sent
SYNACK(seq=y,ACKnum=x+1)
ESTAB ACK(ACKnum=y+1)
ACK(ACKnum=y+1)
LAST_ACK
FINbit=1, seq=y
TIMED_WAIT can no longer
send data
ACKbit=1; ACKnum=y+1
timed wait
for 2*max CLOSED
segment lifetime
CLOSED
R/2
delay
out
Host A
out
sender sends only
when router buffers
available in R/2
A no buffer space!
Host B
Transport Layer 3-88
Causes/costs of congestion:
scenario 2
Idealization: known R/2
loss packets can be
lost, dropped at router when sending at R/2,
due to full buffers some packets are
out
retransmissions but
sender only resends if asymptotic goodput
packet known to be lost is still R/2 (why?)
in R/2
Host B
Transport Layer 3-89
Causes/costs of congestion:
scenario 2
Realistic: duplicates R/2
packets can be lost,
dropped at router due when sending at R/2,
some packets are
to full buffers
out
retransmissions
sender times out including duplicated
that are delivered!
prematurely, sending in R/2
two copies, both of
which are delivered
in
copy
timeo out
ut 'in
Host B
Transport Layer 3-90
Causes/costs of congestion:
scenario 2
Realistic: duplicates R/2
packets can be lost,
dropped at router due when sending at R/2,
some packets are
to full buffers
out
retransmissions
sender times out including duplicated
that are delivered!
prematurely, sending in R/2
two copies, both of
which are delivered
“costs” of congestion:
more work (retrans) for given “goodput”
unneeded retransmissions: link carries multiple
copies of pkt
• decreasing goodput
Host D
Host C
in’ C/2
time
Transport Layer 3-95
TCP Congestion Control:
details
sender sequence number space
cwnd TCP sending rate:
roughly: send
cwnd bytes, wait
last byte last byte RTT for ACKS,
ACKed sent, not- sent
yet then send more
ACKed
(“in-flight bytes cwnd
sender limits
”) transmission: rate ~
~ bytes/sec
RTT
LastByteSent- < cwnd
LastByteAcked
cwnd is dynamic, function of
perceived network congestion
RTT
• initially cwnd = 1 MSS two segm
en ts
• double cwnd every
RTT
• done by incrementing four segm
ents
cwnd for every ACK
received
summary: initial rate
is slow but ramps up time
exponentially fast
Transport Layer 3-97
TCP: detecting, reacting to
loss
loss indicated by timeout:
• cwnd set to 1 MSS;
• window then grows exponentially (as in slow start) to threshold,
then grows linearly
loss indicated by 3 duplicate ACKs: TCP RENO
• dup ACKs indicate network capable of delivering some segments
• cwnd is cut in half window then grows linearly
TCP Tahoe always sets cwnd to 1 (timeout or 3 duplicate acks)
Implementation:
variable ssthresh
on loss event, ssthresh
is set to 1/2 of cwnd
just before loss event
W/2
TCP connection 1
bottleneck
router
capacity R
TCP connection 2
Connection 1 throughput R
Transport Layer 3-104
Fairness (more)
Fairness and UDP Fairness, parallel TCP
multimedia apps connections
often do not use application can open
TCP multiple parallel
connections between
• do not want rate
throttled by two hosts
congestion control web browsers do this
instead use UDP: e.g., link of rate R with
• send audio/video 9 existing
at constant rate, connections:
• new app asks for 1 TCP, gets
tolerate packet rate R/10
loss • new app asks for 11 TCPs,
gets R/2
ECN=00 ECN=11
IP datagram
Transport Layer 3-106
Chapter 3: summary
principles behind transport
layer services:
• multiplexing, next:
demultiplexing leaving the
• reliable data transfer network “edge”
• flow control (application,
• congestion control transport layers)
instantiation, into the network
implementation in the “core”
Internet
• UDP
two network
• TCP layer chapters:
• data plane
• control plane