0% found this document useful (0 votes)
22 views60 pages

Transport Layer

Uploaded by

fatoom.warsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views60 pages

Transport Layer

Uploaded by

fatoom.warsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 60

Chapter 3

Transport
Layer
Computer Networking: A
Top-Down Approach
8th edition
Jim Kurose, Keith Ross
Pearson, 2020
Transport Layer: 3-1
Chapter 3: roadmap
 Transport-layer services
 Connectionless transport: UDP
 Principles of reliable data transfer
 Connection-oriented transport: TCP
 Principles of congestion control
 TCP congestion control

Transport Layer: 3-2


Transport services and protocols
application
transport

 provide logical communication mobile


network
network
data link
physical

between application processes national or global ISP

running on different hosts

log
ica
le
 transport protocols actions in end

n d-
systems:

e nd
local or

tra
• sender: breaks application messages regional ISP

nsp
into segments, passes to network layer

ort
home network content
• receiver: reassembles segments into provider
network
messages, passes to application layer application
transport
datacenter
network
network

 two transport protocols available to data link


physical

Internet applications enterprise


network
• TCP, UDP
Transport Layer: 3-3
Transport vs. network layer services and protocols
household analogy:
12 kids in Ann’s house sending
letters to 12 kids in Bill’s house:
 hosts = houses
 processes = kids
 app messages = letters in
envelopes
 transport protocol = Ann and Bill
who demux to in-house siblings
 network-layer protocol = postal
service
Transport Layer: 3-4
Transport vs. network layer services and protocols

 network layer: logical household analogy:


communication between 12 kids in Ann’s house sending
hosts letters to 12 kids in Bill’s house:
 hosts = houses
 transport layer: logical
 processes = kids
communication between
 app messages = letters in
processes envelopes
• relies on, enhances, network  transport protocol = Ann and Bill
layer services who demux to in-house siblings
 network-layer protocol = postal
service
Transport Layer: 3-5
Transport Layer Actions

Sender:
application  is passed an application- app. msg
application
layer message
transport
 determines segment TTh htransport
app. msg
header fields values
network (IP)
 creates segment network (IP)

link
 passes segment to IP link

physical physical

Transport Layer: 3-6


Transport Layer Actions

Receiver:
application  receives segment from IP application
 checks header values
app. msg
transport  extracts application-layer transport
message
network (IP)  demultiplexes message up network (IP)

link to application via socket link

physical physical
Th app. msg

Transport Layer: 3-7


Two principal Internet transport protocols
application
transport

 TCP: Transmission Control Protocol mobile


network
network
data link
physical
national or global ISP
• reliable, in-order delivery

log
• congestion control

ica
le
• flow control

n d-
e nd
• connection setup local or

tra
regional ISP
 UDP: User Datagram Protocol

nsp
ort
home network
• unreliable, unordered delivery content
provider
network
• no-frills extension of “best-effort” IP application
transport
datacenter
network
network

 services not available: data link


physical

• delay guarantees enterprise


network
• bandwidth guarantees
Transport Layer: 3-8
Chapter 3: roadmap
 Transport-layer services
 Connectionless transport: UDP
 Principles of reliable data transfer
 Connection-oriented transport: TCP
 Principles of congestion control
 TCP congestion control

Transport Layer: 3-9


Connectionless transport
UDP: User Datagram Protocol

 “no frills,” “bare bones”


Why is there a UDP?
Internet transport protocol  no connection
establishment (which can
 “best effort” service, UDP add RTT delay)
segments may be:  simple: no connection state
• lost at sender, receiver
• delivered out-of-order to app  small header size
 connectionless:  no congestion control
 UDP can blast away as fast as
• no handshaking between UDP desired!
sender, receiver  can function in the face of
• each UDP segment handled congestion
independently of others
Transport Layer: 3-10
UDP: User Datagram Protocol
 UDP use:
 streaming multimedia apps (loss tolerant, rate sensitive)
 DNS
 SNMP
 HTTP/3

Transport Layer: 3-11


UDP: User Datagram Protocol [RFC 768]

Transport Layer: 3-12


UDP: Transport Layer Actions

SNMP client SNMP server

application application

transport transport
(UDP) (UDP)

network (IP) network (IP)

link link

physical physical

Transport Layer: 3-13


UDP: Transport Layer Actions

SNMP client SNMP server


UDP sender actions:
application  is passed an application- SNMP msg
application
layer message
transport  determines UDP segment UDPhtransport
UDP h SNMP msg

(UDP) header fields values (UDP)

network (IP)
 creates UDP segment network (IP)

link
 passes segment to IP link

physical physical

Transport Layer: 3-14


UDP: Transport Layer Actions

SNMP client SNMP server


UDP receiver actions:
application  receives segment from IP application
 checks UDP checksum
transport transport
SNMP msg header value
(UDP)  extracts application-layer (UDP)

network
UDP h SNMP(IP)
msg message network (IP)
 demultiplexes message up
link to application link

physical physical

Transport Layer: 3-15


UDP segment header
32 bits
source port # dest port #
length checksum

application length, in bytes of


data UDP segment,
(payload) including header

data to/from
UDP segment format application layer

Transport Layer: 3-16


Chapter 3: roadmap
 Transport-layer services
 Connectionless transport: UDP
 Principles of reliable data transfer
 Connection-oriented transport: TCP
 Principles of congestion control
 TCP congestion control

Transport Layer: 3-17


Principles of reliable data transfer

sending receiving
process process
application data data
transport
reliable channel

reliable service abstraction

Note arrows through reliable data transfer channel is just one way – reliably send from sender to receiver

Transport Layer: 3-18


Principles of reliable data transfer

sending receiving sending receiving


process process process process
application data data application data data
transport transport
reliable channel
sender-side of receiver-side
reliable service abstraction reliable data of reliable data
transfer protocol transfer protocol

transport
network
unreliable channel

reliable service implementation

Transport Layer: 3-19


Principles of reliable data transfer

sending receiving
process process
application data data
transport

sender-side of receiver-side
Complexity of reliable data reliable data
transfer protocol
of reliable data
transfer protocol
transfer protocol will depend
(strongly) on characteristics of transport
network
unreliable channel (lose, unreliable channel
corrupt, reorder data?)
reliable service implementation

Transport Layer: 3-20


Principles of reliable data transfer

sending receiving
process process
application data data
transport

sender-side of receiver-side
reliable data of reliable data
Sender, receiver do not know transfer protocol transfer protocol
the “state” of each other, e.g.,
was a message received? transport
network
 unless communicated via a unreliable channel

message
reliable service implementation

Transport Layer: 3-21


Principles of reliable data transfer
 The key point here is that one side does NOT know what is going on at the
other side – it’s as if there’s a curtain between them. Everything they
know about the other can ONLY be learned by sending/receiving
messages.

 Sender process wants to make sure a segment got through. But it can just
somehow magically look through curtain to see if receiver got it. It will be
up to the receiver to let the sender KNOW that it (the receiver) has
correctly received the segment.

 How will the sender and receiver do that – that’s the PROTOCOL.
Transport Layer: 3-22
Chapter 3: roadmap
 Transport-layer services
 Connectionless transport: UDP
 Principles of reliable data transfer
 Connection-oriented transport: TCP
 Principles of congestion control
 TCP congestion control

Transport Layer: 3-23


Connection-oriented transport TCP
 point-to-point:  cumulative ACKs
• one sender, one receiver  pipelining:
 reliable, in-order byte • TCP congestion and flow control
steam: set window size
• no “message boundaries"  connection-oriented:
 full duplex data: • handshaking (exchange of control
• bi-directional data flow in messages) initializes sender,
same connection receiver state before data exchange
• MSS: maximum segment size  flow controlled:
• sender will not overwhelm receiver

Transport Layer: 3-24


TCP segment structure
32 bits

source port # dest port # segment seq #: counting


ACK: seq # of next expected sequence number bytes of data into bytestream
byte; A bit: this is an ACK (not segments!)
acknowledgement number
length (of TCP header) head not
len used C EUAP R SF receive window flow control: # bytes
Internet checksum checksum Urg data pointer receiver willing to accept

options (variable
C, E: congestion notification length)
TCP options
application data sent by
RST, SYN, FIN: connection data application into
management (variable length) TCP socket

Transport Layer: 3-25


TCP sequence numbers, ACKs
outgoing segment from sender
Sequence numbers: source port # dest port #
sequence number
• byte stream “number” of acknowledgement number

first byte in segment’s data checksum


rwnd
urg pointer

window size
Acknowledgements: N

• seq # of next byte expected


from other side sender sequence number space

• cumulative ACK sent sent, not- usable not


ACKed yet ACKed but not usable
yet sent
Q: how receiver handles out-of- (“in-flight”)

order segments outgoing segment from receiver

• A: TCP spec doesn’t say, - up


source port # dest port #
sequence number

to implementor acknowledgement number


A rwnd
checksum urg pointer
Transport Layer: 3-26
TCP sequence numbers, ACKs
Host A Host B

User types‘C’
Seq=42, ACK=79, data = ‘C’
host ACKs receipt of‘C’,
echoes back ‘C’
Seq=79, ACK=43, data = ‘C’
The key thing to note here is that the ACK
host ACKs receipt number (43) on the B-to-A segment is one
of echoed ‘C’ more than the sequence number (42) on the
Seq=43, ACK=80
A-toB segment that triggered that ACK

Similarly, the ACK number (80) on the last A-


to-B segment is one more than the sequence
simple telnet scenario number (79) on the B-to-A segment that
triggered that ACK
Transport Layer: 3-27
TCP round trip time, timeout
Q: how to set TCP timeout Q: how to estimate RTT?
value?  SampleRTT:measured time
 longer than RTT, but RTT varies! from segment transmission until
ACK receipt
 too short: premature timeout,
• ignore retransmissions
unnecessary retransmissions
 SampleRTT will vary, want
 too long: slow reaction to estimated RTT “smoother”
segment loss • average several recent
measurements, not just current
SampleRTT

Transport Layer: 3-28


TCP Sender (simplified)
event: data received from event: timeout
application  retransmit segment that
 create segment with seq # caused timeout
 restart timer
 seq # is byte-stream number
of first data byte in segment
event: ACK received
 start timer if not already
running  if ACK acknowledges
• think of timer as for oldest
previously unACKed segments
unACKed segment • update what is known to be
ACKed
• expiration interval:
TimeOutInterval • start timer if there are still
unACKed segments
Transport Layer: 3-29
TCP Receiver: ACK generation [RFC 5681]
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

arrival of in-order segment with immediately send single cumulative


expected seq #. One other ACK, ACKing both in-order segments
segment has ACK pending

arrival of out-of-order segment immediately send duplicate ACK,


higher-than-expect seq. # . indicating seq. # of next expected byte
Gap detected

arrival of segment that immediate send ACK, provided that


partially or completely fills gap segment starts at lower end of gap

Transport Layer: 3-30


Rather than immediately ACKnowledig this segment, many TCP
implementations will wait for half a second for another in-order
segment to arrive, and then generate a single cumulative ACK for both
segments – thus decreasing the amount of ACK traffic. The arrival of
this second in-order segment and the cumulative ACK generation that
covers both segments is the second row in this table.

Transport Layer: 3-31


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
timeout

timeout
Seq=100, 20 bytes of data
ACK=100
X
ACK=100
ACK=120

Seq=92, 8 bytes of data Seq=92, 8


SendBase=100 bytes of data send cumulative
SendBase=120 ACK for 120
ACK=100
ACK=120

SendBase=120

lost ACK scenario premature timeout

Transport Layer: 3-32


TCP: retransmission scenarios
Host A Host B

And in this last example, two segments are


Seq=92, 8 bytes of data
again transmitted, the first ACK is lost but the
Seq=100, 20 bytes of data
second ACK, a cumulative ACK arrives at the
ACK=100
X sender, which then can transmit a third
ACK=120 segment, knowing that the first two have
arrived, even though the ACK for the first
Seq=120, 15 bytes of data
segment was lost.

cumulative ACK covers


for earlier lost ACK

Transport Layer: 3-33


TCP fast retransmit
Host A Host B
TCP fast retransmit
if sender receives 3 additional
Seq=92
ACKs for same data (“triple Seq=1
, 8 bytes
of data
duplicate ACKs”), resend unACKed 0 0, 20 b
ytes o
f data
segment with smallest seq # X
 likely that unACKed segment lost,
=100
so don’t wait for timeout ACK

=100

timeout
ACK
CK =100
A
= 10 0
Receipt of three duplicate ACKs ACK

indicates 3 segments received Seq=100, 20 bytes of data

after a missing segment – lost


segment is likely. So retransmit!

Transport Layer: 3-34


TCP flow control
application
Q: What happens if network Application removing
process

layer delivers data faster than data from TCP socket


buffers
application layer removes TCP socket
data from socket buffers? receiver buffers

TCP
code
Network layer
delivering IP datagram
payload into TCP
IP
socket buffers code

from sender

receiver protocol stack

Transport Layer: 3-35


TCP flow control
application
Q: What happens if network Application removing
process

layer delivers data faster than data from TCP socket


buffers
application layer removes TCP socket
data from socket buffers? receiver buffers

TCP
code
Network layer
delivering IP datagram
payload into TCP
IP
socket buffers code

from sender

receiver protocol stack

Transport Layer: 3-36


TCP flow control
application
Q: What happens if network Application removing
process

layer delivers data faster than data from TCP socket


buffers
application layer removes TCP socket
data from socket buffers? receiver buffers

TCP
code

receive window
flow control: # bytes
receiver willing to accept IP
code

from sender

receiver protocol stack

Transport Layer: 3-37


TCP flow control
application
Q: What happens if network Application removing
process

layer delivers data faster than data from TCP socket


buffers
application layer removes TCP socket
data from socket buffers? receiver buffers

TCP
flow control code

receiver controls sender, so


sender won’t overflow IP
code
receiver’s buffer by
transmitting too much, too fast
from sender

receiver protocol stack

Transport Layer: 3-38


TCP flow control
 TCP receiver “advertises” free buffer
space in rwnd field in TCP header to application process
• RcvBuffer size set via socket
options (typical default is 4096 bytes) RcvBuffer buffered data
• many operating systems autoadjust
RcvBuffer
rwnd free buffer space

 sender limits amount of unACKed


(“in-flight”) data to received rwnd TCP segment payloads

 guarantees receive buffer will not TCP receiver-side buffering


overflow

Transport Layer: 3-39


TCP flow control
flow control: # bytes receiver willing to accept

 TCP receiver “advertises” free buffer


space in rwnd field in TCP header
• RcvBuffer size set via socket
receive window
options (typical default is 4096 bytes)
• many operating systems autoadjust
RcvBuffer
 sender limits amount of unACKed
(“in-flight”) data to received rwnd
 guarantees receive buffer will not
overflow
TCP segment format

Transport Layer: 3-40


TCP connection management
before exchanging data, sender/receiver “handshake”:
 agree to establish connection (each knowing the other willing to establish connection)
 agree on connection parameters (e.g., starting seq #s)

application application

connection state: ESTAB connection state: ESTAB


connection variables: connection Variables:
seq # client-to-server seq # client-to-server
server-to-client server-to-client
rcvBuffer size rcvBuffer size
at server,client at server,client

network network

Transport Layer: 3-41


TCP 3-way handshake
Server state
serverSocket = socket(AF_INET,SOCK_STREAM)
Client state serverSocket.bind((‘’,serverPort))
serverSocket.listen(1)
clientSocket = socket(AF_INET, SOCK_STREAM) connectionSocket, addr = serverSocket.accept()
LISTEN
clientSocket.connect((serverName,serverPort)) LISTEN
choose init seq num, x
send TCP SYN msg
SYNSENT SYNbit=1, Seq=x
choose init seq num, y
send TCP SYNACK
msg, acking SYN SYN RCVD
SYNbit=1, Seq=y
ACKbit=1; ACKnum=x+1
received SYNACK(x)
ESTAB indicates server is live;
send ACK for SYNACK;
this segment may contain ACKbit=1, ACKnum=y+1
client-to-server data
received ACK(y)
indicates client is live
ESTAB

Transport Layer: 3-42


Closing a TCP connection
 client, server each close their side of connection
• send TCP segment with FIN bit = 1
 respond to received FIN with ACK
• on receiving FIN, ACK can be combined with own FIN
 simultaneous FIN exchanges can be handled

Transport Layer: 3-43


Chapter 3: roadmap
 Transport-layer services
 Connectionless transport: UDP
 Principles of reliable data transfer
 Connection-oriented transport: TCP
 Principles of congestion control
 TCP congestion control

Transport Layer: 3-44


Principles of congestion control
Congestion:
 informally: “too many sources sending too much data too fast for
network to handle”
 manifestations:
• long delays (queueing in router buffers)
• packet loss (buffer overflow at routers)
 different from flow control! congestion control:
too many senders,
sending too fast

flow control: one sender


too fast for one receiver
Transport Layer: 3-45
Approaches towards congestion control

End-end congestion control:


 no explicit feedback from
network
 congestion inferred from ACKs
data data
ACKs
observed loss, delay
 approach taken by TCP

Transport Layer: 3-46


Approaches towards congestion control
Network-assisted congestion
control: explicit congestion info
 routers provide direct feedback
to sending/receiving hosts with data data
ACKs
flows passing through congested ACKs

router
 may indicate congestion level or
explicitly set sending rate
 TCP ECN, ATM, DECbit protocols
Transport Layer: 3-47
Chapter 3: roadmap
 Transport-layer services
 Connectionless transport: UDP
 Connection-oriented transport: TCP
 Principles of congestion control
 TCP congestion control

Transport Layer: 3-48


TCP congestion control: AIMD
 approach: senders can increase sending rate until packet loss
(congestion) occurs, then decrease sending rate on loss event
Additive Increase Multiplicative Decrease
increase sending rate by 1 cut sending rate in half at
maximum segment size every each loss event
RTT until loss detected
TCP sender Sending rate

AIMD sawtooth
behavior: probing
for bandwidth

time Transport Layer: 3-49


TCP AIMD: more
Multiplicative decrease detail: sending rate is
 Cut in half on loss detected by triple duplicate ACK (TCP Reno)
 Cut to 1 MSS (maximum segment size) when loss detected by
timeout (TCP Tahoe)

Why AIMD?
 AIMD – a distributed, asynchronous algorithm – has been
shown to:
• optimize congested flow rates network wide!
• have desirable stability properties

Transport Layer: 3-50


TCP congestion control: details
sender sequence number space
cwnd TCP sending behavior:
 roughly: send cwnd bytes,
wait RTT for ACKS, then
send more bytes
last byte
available but cwnd
ACKed sent, but not- TCP rate ~
~ bytes/sec
yet ACKed not used RTT
(“in-flight”) last byte sent

 TCP sender limits transmission: LastByteSent- LastByteAcked < cwnd


 cwnd is dynamically adjusted in response to observed network
congestion (implementing TCP congestion control)
Transport Layer: 3-51
TCP congestion control: details
 Congestion Detection
Using the occurrence of two events:
1- time out (RTO) with no ACK.
2- receiving three duplicates ACKs

 Congestion Policies algorithms


1- Slow Start
Taho TCP
2- Congestion Avoidance
3- Fast Recovery Reno TCP

 TCP versions
1- Taho TCP (treated both events similarly). Transport Layer: 3-52
TCP slow start
Host A Host B
 when connection begins,
increase rate exponentially
until first loss event:
one s e gm
ent

RTT
• initially cwnd = 1 MSS two segm
en ts
• double cwnd every RTT
• done by incrementing cwnd
for every ACK received four segm
ents

 summary: initial rate is


slow, but ramps up
exponentially fast time

Transport Layer: 3-53


TCP: from slow start to congestion avoidance
Q: when should the exponential
increase switch to linear?
X
A: when cwnd gets to 1/2 of its
value before timeout.

Implementation:
 variable ssthresh
 on loss event, ssthresh is set to
1/2 of cwnd just before loss event

* Check out the online interactive exercises for more examples: h ttp://gaia.cs.umass.edu/kurose_ross/interactive/
Transport Layer: 3-54
Summary: TCP congestion control
New
New ACK!
ACK! new ACK
duplicate ACK
dupACKcount++ new ACK .
cwnd = cwnd + MSS (MSS/cwnd)
dupACKcount = 0
cwnd = cwnd+MSS transmit new segment(s), as allowed
dupACKcount = 0
L transmit new segment(s), as allowed
cwnd = 1 MSS
ssthresh = 64 KB cwnd > ssthresh
dupACKcount = 0
slow L congestion
start timeout avoidance
ssthresh = cwnd/2
cwnd = 1 MSS duplicate ACK
timeout dupACKcount = 0 dupACKcount++
ssthresh = cwnd/2 retransmit missing segment
cwnd = 1 MSS
dupACKcount = 0
retransmit missing segment
timeout
New
ACK!
ssthresh = cwnd/2
cwnd = 1 New ACK
dupACKcount = 0
cwnd = ssthresh dupACKcount == 3
dupACKcount == 3 retransmit missing segment dupACKcount = 0
ssthresh= cwnd/2 ssthresh= cwnd/2
cwnd = ssthresh + 3 cwnd = ssthresh + 3
retransmit missing segment
retransmit missing segment
fast
recovery
duplicate ACK
cwnd = cwnd + MSS
transmit new segment(s), as allowed

Transport Layer: 3-55


TCP and the congested “bottleneck link”
 TCP (classic) increase TCP’s sending rate until packet loss occurs at some
router’s output: the bottleneck link

source destination
application application
TCP TCP
network network
link link
physical physical
packet queue almost
never empty, sometimes
overflows packet (loss)

bottleneck link (almost always busy)


Transport Layer: 3-56
TCP and the congested “bottleneck link”
 TCP (classic) increase TCP’s sending rate until packet loss occurs at some
router’s output: the bottleneck link
 understanding congestion: useful to focus on congested bottleneck link

insight: increasing TCP sending rate will


source not increase end-end throughout destination
with congested bottleneck
application application
TCP TCP
network network
link link
physical physical

insight: increasing TCP


sending rate will
increase measured RTT
Goal: “keep the end-end pipe just full, but not fuller”
RTT
Transport Layer: 3-57
Delay-based TCP congestion control
Keeping sender-to-receiver pipe “just full enough, but no fuller”: keep
bottleneck link busy transmitting, but avoid high delays/buffering
# bytes sent in
measured last RTT interval
RTTmeasured throughput =
RTTmeasured
Delay-based approach:
 RTTmin - minimum observed RTT (uncongested path)
 uncongested throughput with congestion window cwnd is cwnd/RTTmin
if measured throughput “very close” to uncongested throughput
increase cwnd linearly /* since path not congested */
else if measured throughput “far below” uncongested throughout
decrease cwnd linearly /* since path is congested */
Transport Layer: 3-58
Delay-based TCP congestion control
 congestion control without inducing/forcing loss
 maximizing throughout (“keeping the just pipe full… ”) while keeping
delay low (“…but not fuller”)
 a number of deployed TCPs take a delay-based approach
 BBR deployed on Google’s (internal) backbone network

Transport Layer: 3-59


Explicit congestion notification (ECN)
TCP deployments often implement network-assisted congestion control:
 two bits in IP header (ToS field) marked by network router to indicate congestion
• policy to determine marking chosen by network operator
 congestion indication carried to destination
 destination sets ECE bit on ACK segment to notify sender of congestion
 involves both IP (IP header ECN bit marking) and TCP (TCP header C,E bit marking)
source TCP ACK segment
destination
application application
ECE=1
TCP TCP
network network
link link
physical physical

ECN=10 ECN=11

IP datagram
Transport Layer: 3-60

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy