Professional Documents
Culture Documents
processes running on
different hosts
lo
gi
ca
transport protocols run in end
enl
d-
systems
en
d
• send side: breaks app
tra
ns
po
messages into
rt
segments, passes to application
segments into
messages, passes to
app layer
Transport Layer 6-4
more than one transport
Transport vs. network layer
network layer: household analogy:
logical
communication 12 kids in Ann’s house sending
letters to 12 kids in Bill’s
between hosts house:
transport layer: hosts = houses
logical processes = kids
communication app messages = letters in
envelopes
between processes transport protocol = Ann
• relies on, enhances, and Bill who demux to in-
network layer house siblings
services network-layer protocol =
postal service
delivery: TCP
data link
physical
network
network data link
• congestion control
lo
data link physical
gi
physical
ca
network
• flow control
l
data link
en
physical
d-
en
• connection setup network
d
data link
tra
physical
unreliable, unordered
ns
po
network
rt
data link
application
physical
• no-frills extension of network
data link
transport
network
data link
“best-effort” IP
physical
physical
services not
available:
• delay guarantees Transport Layer 6-6
Chapter 6 outline
3.1 transport-layer services
3.5 connection-oriented
transport: TCP
3.2 multiplexing and demultiplexing
3.3 connectionless transport:•UDPsegment structure
• reliable data transfer
3.4 principles of reliable data transfer
• flow control
• connection
management
3.6 principles of
congestion control
3.7 TCP congestion
control
Transport Layer 6-7
Multiplexing/demultiplexing
multiplexing at sender:
handle data from multiple demultiplexing at receiver:
sockets, add transport header use header info to deliver
(later used for demultiplexing) received segments to correct
socket
application
application
application P4 P5 P6 application
P3 P2 P3
transport
transport transport
network
network link network
link physical link
physical server: IP physical
address B
length checksum
why is there a UDP?
no connection
application establishment (which can
data add delay)
(payload) simple: no connection state
at sender, receiver
small header size
no congestion control:
UDP segment format
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)
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)
U L/R .008
sender = = = 0.00027
RTT + L / R 30.008
U 3L / R .0024
sender = = = 0.00081
RTT + L / R 30.008
say, - up to A
checksum
rwnd
urg pointer
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
350
300
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 (seconds) Transport Layer 6-62
SampleRTT Estimated RTT
TCP round trip time, timeout
timeout interval: EstimatedRTT plus “safety
margin”
• large variation in EstimatedRTT -> larger safety margin
estimate
DevRTTSampleRTT deviation+ from EstimatedRTT:
= (1-)*DevRTT
*|SampleRTT-EstimatedRTT|
(typically, = 0.25)
SendBase=92
Seq=92, 8 bytes of data Seq=92, 8 bytes of data
timeout
timeout
Seq=100, 20 bytes of data
ACK=100
X
ACK=100
ACK=120
SendBase=120
ACK=100
X
ACK=120
cumulative ACK
Transport Layer 3-69
TCP ACK generation [RFC 1122, RFC 2581]
event at receiver TCP receiver action
arrival of in-order segment with delayed ACK. Wait up to 500ms
expected seq #. All data up to for next segment. If no next segment,
expected seq # already ACKed send ACK
ACK=100
timeout
ACK=100
ACK=100
ACK=100
Seq=100, 20 bytes of data
IP
flow control code
receiver controls sender, so
sender won’t overflow receiver’s
buffer by transmitting too much, from sender
too fast
receiver protocol stack
application application
network network
2-way handshake:
Q: will 2-way
handshake always
Let’s talk work in network?
ESTAB variable delays
OK
ESTAB
retransmitted messages (e.g.
req_conn(x)) due to message
loss
message reordering
choose x can’t “see” other side
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(x) req_conn(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
terminates forgets x terminates forgets x
req_conn(x)
ESTAB ESTAB
data(x+1) accept
half open connection! data(x+1)
(no client!)
Transport Layer 6-79
TCP 3-way handshake
Socket connectionSocket =
welcomeSocket.accept();
L 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)
L
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
Host B
R/2
delay
lout
Host A
lout
sender sends only when
router buffers available
lin R/2
A no buffer space!
Host B
Transport Layer 6-89
Causes/costs of congestion: scenario 2
Idealization: known R/2
lout
retransmissions but
due to full buffers asymptotic goodput
sender only resends if is still R/2 (why?)
Host B
Transport Layer 6-90
Causes/costs of congestion: scenario 2
Realistic: duplicates R/2
packets can be lost, dropped at
router due to full buffers when sending at R/2,
some packets are
lout
sender times out prematurely, retransmissions
including duplicated
sending two copies, both of that are delivered!
which are delivered R/2
lin
lin
timeout
copy lout
l'in
Host B
Transport Layer 6-91
Causes/costs of congestion: scenario 2
Realistic: duplicates R/2
packets can be lost, dropped at
router due to full buffers when sending at R/2,
some packets are
lout
sender times out prematurely, retransmissions
including duplicated
sending two copies, both of that are delivered!
which are delivered R/2
lin
“costs” of congestion:
more work (retrans) for given “goodput”
unneeded retransmissions: link carries multiple copies of pkt
• decreasing goodput
Host D
Host C
lin’ C/2
time
Transport Layer 6-96
TCP Congestion Control: details
sender sequence number space
cwnd TCP sending rate:
roughly: send cwnd
bytes, wait RTT for
last byte
ACKed sent, not-
last byte
sent ACKS, then send
yet ACKed
(“in-flight”) more bytes
cwnd
sender limits rate ~
~
RTT
bytes/sec
transmission:
LastByteSent- < cwnd
LastByteAcked
cwnd is dynamic,
function of perceived Transport Layer 6-97
TCP Slow Start
Host A Host B
when connection
begins, increase rate
exponentially until one s e gm
ent
RTT
first loss event: two segm
• initially cwnd = 1 en ts
MSS
• double cwnd every four segm
ents
RTT
• done by incrementing
cwnd for every ACK
received time
Implementation:
variable ssthresh
on loss event, ssthresh
is set to 1/2 of cwnd just
before loss event
W/2
bottleneck
router
capacity R
TCP connection 2
Connection 1 throughput R
Transport Layer 6-105
Fairness (more)
Fairness and UDP Fairness, parallel TCP
multimedia apps connections
often do not use application can open
TCP multiple parallel
• do not want rate connections between
throttled by two hosts
congestion control
instead use UDP: web browsers do this
• send audio/video at e.g., link of rate R
constant rate, with 9 existing
tolerate packet loss connections:
• new app asks for 1 TCP, gets
rate R/10
TCPs,Layer 6-106
• new app asks for 11Transport
Explicit Congestion Notification (ECN)
network-assisted congestion control:
two bits in IP header (ToS field) marked by network
router to indicate congestion
congestion indication carried to receiving host
receiver (seeing congestion indication in IP datagram) )
sets ECE bit on receiver-to-sender ACK segment to notify
sender of congestion
TCP ACK segment
source destination
application application
ECE=1
transport transport
network network
link link
physical physical
ECN=00 ECN=11
IP datagram
Transport Layer 6-107
Chapter 3 summary
principles behind
transport layer services: next:
• multiplexing, leaving the
demultiplexing network “edge”
• reliable data transfer (application,
• flow control transport layers)
• congestion control
into the network
instantiation, “core”
implementation in the two network
Internet layer chapters:
• UDP
• data plane
• TCP
• control Transport
planeLayer 6-108