0% found this document useful (0 votes)
80 views

Transport Layer: Computer Networking: A Top Down Approach

The document summarizes the transport layer in computer networking. It discusses two main transport protocols: TCP, which provides reliable, in-order delivery of data through mechanisms like congestion control and flow control, and UDP, which provides unreliable datagram delivery with no guarantees. It describes how transport protocols multiplex data from multiple applications and demux incoming data to the proper application using port numbers and IP addresses.

Uploaded by

Muhammad Faisal
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

Transport Layer: Computer Networking: A Top Down Approach

The document summarizes the transport layer in computer networking. It discusses two main transport protocols: TCP, which provides reliable, in-order delivery of data through mechanisms like congestion control and flow control, and UDP, which provides unreliable datagram delivery with no guarantees. It describes how transport protocols multiplex data from multiple applications and demux incoming data to the proper application using port numbers and IP addresses.

Uploaded by

Muhammad Faisal
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 66

Transport Layer

Computer
Networking: A Top
Down Approach
6th edition
Jim Kurose, Keith Ross
Addison-Wesley
March 2012

3-1
Outline
 transport-layer  connection-oriented
services transport: TCP
 multiplexing and  segment structure
demultiplexing  reliable data transfer
 connectionless  flow control
transport: UDP  connection management
 principles of congestion
control
 TCP congestion control

3-2
Transport services and protocols
application
transport
 Provide logical communication network
between app processes running data link
physical
on different hosts
 Transport protocols run in end
systems
 send side: breaks app messages
into segments, passes to
network layer
 rcv side: reassembles segments
into messages, passes to app
layer application
 More than one transport protocol transport
network
available to apps data link
physical
 Internet: TCP and UDP

3-3
Transport vs. network layer
 Network layer: logical communication
between hosts

 Transport layer: logical communication


between processes

3-4
Transport layer
Internet transport-layer protocols
application
 Reliable, in-order transport
network

delivery (TCP) data link


physical
network

 congestion control network


data link
data link
physical
physical
 flow control network
data link

 connection setup physical

network

 Unreliable, unordered data link


physical

delivery: UDP network


data link
physical

 Services not available: network


data link
physical
application
transport
network
 delay guarantees data link
physical
network
data link

 bandwidth guarantees physical

3-6
Outline
 transport-layer  connection-oriented
services transport: TCP
 multiplexing and  segment structure
demultiplexing  reliable data transfer
 connectionless  flow control
transport: UDP  connection management
 principles of congestion
control
 TCP congestion control

3-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 P1 P2 application socket


P3 transport P4
process
transport network transport
network link network
link physical link
physical physical

3-8
How demultiplexing works
 Host receives IP
datagrams 32 bits

 each datagram has source IP source port # dest port #


address, destination IP
address other header fields
 each datagram carries one
transport-layer segment
 each segment has source, application
destination port number data
(payload)
 Host uses IP addresses &
port numbers to direct
segment to appropriate TCP/UDP segment format
socket
3-9
Connectionless demux: example
DatagramSocket
DatagramSocket serverSocket = new
DatagramSocket DatagramSocket
mySocket2 = new mySocket1 = new
DatagramSocket (6428); DatagramSocket
(9157); application
(5775);
application application
P1
P3 P4
transport
transport transport
network
network link network
link physical link
physical physical

source port: 6428 source port: ?


dest port: 9157 dest port: ?

source port: 9157 source port: ?


dest port: 6428 dest port: ?
3-10
Connection-oriented demux
 TCP socket identified  Server host may support
by 4-tuple: many simultaneous TCP
 source IP address sockets:
 source port number  each socket identified by
 dest IP address its own 4-tuple
 dest port number  Web servers have
 demux: receiver uses different sockets for
all four values to direct each connecting client
segment to appropriate  non-persistent HTTP will
socket have different socket for
each request

3-11
Connection-oriented demux: example

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

host: IP source IP,port: B,80 host: IP


address A dest IP,port: A,9157 source IP,port: C,5775 address C
dest IP,port: B,80
source IP,port: A,9157
dest IP, port: B,80
source IP,port: C,9157
dest IP,port: B,80
three segments, all destined to IP address: B,
dest port: 80 are demultiplexed to different sockets 3-12
Outline
 transport-layer  connection-oriented
services transport: TCP
 multiplexing and  segment structure
demultiplexing  reliable data transfer
 connectionless  flow control
transport: UDP  connection management
 principles of congestion
control
 TCP congestion control

3-13
UDP: User Datagram Protocol [RFC 768]
 “best effort” service,  UDP use:
UDP segments may be:  streaming multimedia
 lost apps
 delivered out-of-order  DNS
to app  SNMP
 Connectionless:  Reliable transfer over
 no handshaking UDP:
between UDP sender,
receiver  add reliability at
application layer (How?)
 each UDP segment
handled independently  application-specific error
of others recovery!

3-14
UDP: segment header
length, in bytes of
32 bits UDP segment,
source port # dest port # including header

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
UDP segment format  no congestion control:
UDP can blast away as
fast as desired

3-15
Encapsulation & De-capsulation

3-16
Why we need error control at the transport
layer?
UDP checksum
Goal: detect “errors” (e.g., flipped bits) in transmitted
segment
sender: receiver:
 treat segment contents,  compute checksum of
including header fields, received segment
as sequence of 16-bit  check if computed
integers
checksum equals checksum
 checksum: addition field value:
(one’s complement
sum) of segment  NO - error detected
contents  YES - no error
 sender puts checksum
value into UDP
checksum field
3-18
Internet checksum: example
example: add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

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

Note: when adding numbers, a carryout from the most


significant bit needs to be added to the result

3-19
Outline
 transport-layer  connection-oriented
services transport: TCP
 multiplexing and de-  segment structure
multiplexing  reliable data transfer
 connectionless  flow control
transport: UDP  connection management
 principles of congestion
control
 TCP congestion control

3-20
TCP: Overview RFCs: 793,1122,1323, 2018, 2581

 point-to-point:  full duplex data:


 one sender, one receiver  bi-directional data flow
 reliable, in-order byte in same connection
stream:  MSS: maximum segment
size
 no “message
boundaries”  connection-oriented:
 pipelined:  handshaking (exchange
of control msgs) inits
 TCP congestion and sender, receiver state
flow control set window before data exchange
size
 flow controlled:
 sender will not
overwhelm receiver
3-21
TCP segment structure
32 bits
URG: urgent data counting
(generally not used) source port # dest port #
by bytes
sequence number of data
ACK: ACK #
valid acknowledgement number (not segments!)
head not
PSH: push data now len used
UAP R S F receive window
(generally not used) # bytes
checksum Urg data pointer
rcvr willing
RST, SYN, FIN: to accept
options (variable length)
connection estab
(setup, teardown
commands)
application
Internet data
checksum (variable length)
(as in UDP)

3-22
Outline
 transport-layer  connection-oriented
services transport: TCP
 multiplexing and de-  segment structure
multiplexing  connection management
 connectionless  flow control
transport: UDP  reliable data transfer
 principles of congestion
control
 TCP congestion control

3-23
TCP round trip time, timeout
Q: how to set TCP Q: how to estimate RTT?
timeout value?  SampleRTT: measured
time from segment
 longer than RTT transmission until ACK
 but RTT varies receipt
 too short: premature  ignore retransmissions
timeout, unnecessary  SampleRTT will vary, want
retransmissions estimated RTT “smoother”
 average several recent
 too long: slow reaction measurements, not just
to segment loss current SampleRTT

3-24
Connection Management
before exchanging data, sender/receiver “handshake”:
 agree to establish connection (each knowing the other willing
to establish connection)
 agree on connection parameters

3-25
Agreeing to establish a connection

2-way handshake:
Q: will 2-way handshake
always work in
network?
Let’s talk
ESTAB  variable delays
OK
ESTAB  retransmitted messages
(e.g. req_conn(x)) due to
message loss
 can’t “see” other side
choose x
req_conn(x)
ESTAB
acc_conn(x)
ESTAB

3-26
Agreeing to establish a connection
2-way handshake failure scenarios:

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!)
3-27
TCP 3-way handshake

client state server state


LISTEN LISTEN
choose init seq num, x
send TCP SYN msg
SYNSENT SYN(x)
choose init seq num, y
send TCP SYNACK
msg, acking SYN SYN RCVD
SYN(y)
ACK(x)
received SYNACK(x)
ESTAB indicates server is live;
send ACK for SYNACK;
ACK(y)
received ACK(y)
indicates client is live
ESTAB

3-28
TCP: closing a 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

3-29
TCP: closing a connection
client state server state
ESTAB ESTAB
clientSocket.close()
FIN_WAIT_1 can no longer FINbit=1, seq=x
send but can
receive data CLOSE_WAIT
ACKbit=1; ACKnum=x+1
can still
FIN_WAIT_2 wait for server send data
close

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

3-30
Outline
 transport-layer  connection-oriented
services transport: TCP
 multiplexing and de-  segment structure
multiplexing  connection management
 connectionless  reliable data transfer
transport: UDP  flow control
 principles of congestion
control
 TCP congestion control

3-31
TCP reliable data transfer
 TCP creates rdt service
on top of IP’s unreliable
service
 pipelined segments
 cumulative acks let’s initially consider
 single retransmission simplified TCP sender:
timer  ignore duplicate acks
 retransmissions  ignore flow control,
triggered by: congestion control
 timeout events
 duplicate acks

3-32
TCP sender events:
data rcvd from app: timeout:
 create segment with  retransmit segment
seq # that caused timeout
 seq # is byte-stream  restart timer
number of first data ack rcvd:
byte in segment  if ack acknowledges
 start timer if not previously unacked
already running segments
 think of timer as for  update what is known
oldest unacked to be ACKed
segment
 start timer if there are
 expiration interval: still unacked segments
TimeOutInterval

3-33
TCP: retransmission scenarios
sender receiver sender receiver
send pkt0 pkt0 send pkt0 pkt0
rcv pkt0 rcv pkt0
ack0 send ack0 ack0 send ack0
rcv ack0 rcv ack0
send pkt1 pkt1 send pkt1 pkt1
rcv pkt1 X
ack1 send ack1 loss
rcv ack1
send pkt0 pkt0
rcv pkt0 timeout
ack0 send ack0 resend pkt1 pkt1
rcv pkt1
ack1 send ack1
rcv ack1
send pkt0 pkt0
(a) no loss rcv pkt0
ack0 send ack0

(b) packet loss


3-34
TCP: retransmission scenarios
sender receiver
sender receiver send pkt0 pkt0
send pkt0 pkt0 rcv pkt0
send ack0
rcv pkt0 ack0
send ack0 rcv ack0
ack0 send pkt1 pkt1
rcv ack0 rcv pkt1
send pkt1 pkt1
send ack1
rcv pkt1 ack1
ack1 send ack1
X
loss timeout
resend pkt1 pkt1
rcv pkt1
timeout
resend pkt1 pkt1 rcv ack1 (detect duplicate)
rcv pkt1 send pkt0
pkt0
send ack1
(detect duplicate) ack1
ack1 send ack1 rcv ack1 rcv pkt0
rcv ack1 send pkt0
ack0 send ack0
send pkt0 pkt0 pkt0
rcv pkt0
rcv pkt0 ack0 (detect duplicate)
ack0 send ack0 send ack0

(c) ACK loss (d) premature timeout/ delayed ACK

3-35
TCP fast retransmit
 time-out period often
relatively long: TCP fast retransmit
 long delay before if sender receives 3
resending lost packet ACKs for same data
 detect lost segments (“triple duplicate ACKs”),
via duplicate ACKs. resend
 sender often sends unacknowledged
many segments back- segment with smallest
to-back seq #
 if segment is lost, there  likely that unacked
will likely be many segment lost, so don’t
duplicate ACKs. wait for timeout

3-36
TCP fast retransmit
Host A Host B

Seq=92, 8 bytes of data


Seq=100, 20 bytes of data
X

ACK=100
timeout

ACK=100
ACK=100
ACK=100
Seq=100, 20 bytes of data

fast retransmit after sender


receipt of triple duplicate ACK
3-37
Outline
 transport-layer  connection-oriented
services transport: TCP
 multiplexing and de-  segment structure
multiplexing  connection management
 connectionless  reliable data transfer
transport: UDP  flow control
 principles of congestion
control
 TCP congestion control

3-38
TCP flow control
 A technique for
assuring that a
transmitting entity Flow Control
does not over-whelm
a receiving entity with Stop-and-Wait Sliding Window
data.
 Stop-and-wait flow
control
 Sliding window flow
control

3-39
Stop-and-wait operation
 Sender transmits one packet and waits for
receiver’s response.
 Receiver receives frame and replies with
acknowledgement.
 Source waits for ACK before sending next
frame.
 Receiver can stop flow by not send ACK.

3-40
Sliding Window operation
 Allow multiple frames to be in transit.
 Receiver has buffer W long.
 Sender can send up to W frames without ACK.
 Each frame is numbered.
 ACK includes number of next frame expected.

3-41
Sliding window example
Sender Receiver

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

0
1
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

A3 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
3
4
5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
6

A4 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

3-42
Pipelined protocols
pipelining: sender allows multiple, “in-flight”, yet-
to-be-acknowledged pkts
 range of sequence numbers must be increased
 buffering at sender and/or receiver

 two generic forms of pipelined protocols: go-Back-N,


selective repeat
3-43
Pipelined protocols: overview
Go-back-N: Selective Repeat:
 sender can have up to  sender can have up to N
N unacked packets in unack’ed packets in
pipeline pipeline
 receiver only sends  rcvr sends individual ack
cumulative ack for each packet
 doesn’t ack packet if
there’s a gap
 sender has timer for  sender maintains timer
oldest unacked packet for each unacked packet
 when timer expires,  when timer expires,
retransmit all unacked retransmit only that
packets unacked packet

3-44
GBN in action
sender window (N=4) sender receiver
012345678 send pkt0
012345678 send pkt1
012345678 send pkt2 receive pkt0, send ack0
012345678 send pkt3 Xloss receive pkt1, send ack1
(wait)
receive pkt3, discard,
012345678 rcv ack0, send pkt4 (re)send ack1
012345678 rcv ack1, send pkt5 receive pkt4, discard,
(re)send ack1
ignore duplicate ACK receive pkt5, discard,
(re)send ack1
pkt 2 timeout
012345678 send pkt2
012345678 send pkt3
012345678 send pkt4 rcv pkt2, deliver, send ack2
012345678 send pkt5 rcv pkt3, deliver, send ack3
rcv pkt4, deliver, send ack4
rcv pkt5, deliver, send ack5

3-45
Selective Repeat
 Also called selective retransmission.
 Only rejected frames are retransmitted.
 Subsequent frames are accepted by the receiver
and buffered.
 Minimizes retransmission but receiver must
maintain large enough buffer.
 More complex as compared to G-back-n.

3-46
Selective repeat in action
sender window (N=4) sender receiver
012345678 send pkt0
012345678 send pkt1
012345678 send pkt2 receive pkt0, send ack0
012345678 send pkt3 Xloss receive pkt1, send ack1
(wait)
receive pkt3, buffer,
012345678 rcv ack0, send pkt4 send ack3
012345678 rcv ack1, send pkt5 receive pkt4, buffer,
send ack4
record ack3 arrived receive pkt5, buffer,
send ack5
pkt 2 timeout
012345678 send pkt2
012345678 record ack4 arrived
012345678 rcv pkt2; deliver pkt2,
record ack5 arrived
012345678 pkt3, pkt4, pkt5; send ack2

Q: what happens when ack2 arrives?

3-47
sender window receiver window
Selective repeat: (after receipt) (after receipt)

Ambiguity 0123012 pkt0


pkt1
0123012 0123012
pkt2 0123012
example:
0123012
0123012
pkt3
seq #’s: 0, 1, 2, 3
0123012
 X
0123012
 window size=3 pkt0 will accept packet
with seq number 0
(a) no problem
 receiver sees no
difference in two receiver can’t see sender side.
scenarios! receiver behavior identical in both cases!
something’s (very) wrong!
 duplicate data
accepted as new in 0123012 pkt0
(b) 0123012 pkt1 0123012
0123012 pkt2 0123012
X 0123012
Q: what relationship X
between seq # size timeout
retransmit pkt0 X
and window size to 0123012 pkt0
will accept packet
avoid problem in (b)? with seq number 0
(b) oops!
3-48
Outline
 transport-layer  connection-oriented
services transport: TCP
 multiplexing and  segment structure
demultiplexing  reliable data transfer
 connectionless  flow control
transport: UDP  connection management
 principles of congestion
control
 TCP congestion control

3-49
Principles of congestion control
congestion:
 informally: “too many sources sending too much
data too fast for network to handle”
 different from flow control!
 manifestations:
 lost packets (buffer overflow at routers)
 long delays (queueing in router buffers)
 a top-10 problem!

3-50
Causes/costs of congestion: scenario 1
original data: lin throughput: lout
 two senders, two
receivers Host A

 one router, infinite unlimited shared


buffers output link buffers

 output link capacity: R


 no retransmission
Host B

3-51
Causes/costs of congestion: scenario 2
 one router, finite buffers
 sender retransmission of timed-out packet
 application-layer input = application-layer output: lin =
lout
 transport-layer input includes retransmissions

lin : original data


lout
l'in: original data, plus
retransmitted data

Host A

finite shared output


Host B
link buffers
3-52
Causes/costs of congestion: scenario 2

idealization: perfect
knowledge
 sender sends only when
router buffers available

lin : original data


lout
copy l'in: original data, plus
retransmitted data

A free buffer space!

finite shared output


Host B
link buffers
3-53
Causes/costs of congestion: scenario 2
Idealization: known loss
packets can be lost,
dropped at router due
to full buffers
 sender only resends if
packet known to be lost

lin : original data


lout
copy l'in: original data, plus
retransmitted data

A
no buffer space!

Host B
3-54
Causes/costs of congestion: scenario 2
Idealization: known loss
packets can be lost,
dropped at router due
to full buffers
 sender only resends if
packet known to be lost

lin : original data


lout
l'in: original data, plus
retransmitted data

A
free buffer space!

Host B
3-55
Causes/costs of congestion: scenario 2
Realistic: duplicates
 packets can be lost, dropped
at router due to full buffers
 sender times out prematurely,
sending two copies, both of
which are delivered

lin
timeout
copy l'in lout

A
free buffer space!

Host B
3-56
Causes/costs of congestion: scenario 2
Realistic: duplicates
 packets can be lost, dropped
at router due to full buffers
 sender times out prematurely,
sending 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

3-57
Causes/costs of congestion: scenario 3

 four senders Q: what happens as lin and lin’


increase ?
 multihop paths
A: as red lin’ increases, all arriving
 timeout/retransmit blue pkts at upper queue are
dropped, blue throughput g 0
Host A
lin : original data lout
Host B
l'in: original data, plus
retransmitted data
finite shared output
link buffers

Host D
Host C

3-58
Causes/costs of congestion: scenario 3

another “cost” of congestion:


 when packet dropped, any “upstream
transmission capacity used for that packet was
wasted!

3-59
Approaches towards congestion control

two broad approaches towards congestion control:

end-end congestion network-assisted


control: congestion control:
 no explicit feedback  routers provide
from network feedback to end systems
 congestion inferred  single bit indicating
from end-system congestion (SNA,
observed loss, delay DECbit, TCP/IP ECN,
 approach taken by ATM)
TCP  explicit rate for
sender to send at

3-60
Outline
 transport-layer  connection-oriented
services transport: TCP
 multiplexing and  segment structure
demultiplexing  reliable data transfer
 connectionless  flow control
transport: UDP  connection management
 principles of congestion
control
 TCP congestion control

3-61
TCP congestion control: additive increase
multiplicative decrease

 approach: sender increases transmission rate (window


size), probing for usable bandwidth, until loss occurs
 additive increase: increase cwnd by 1 MSS every
RTT until loss detected
 multiplicative decrease: cut cwnd in half after loss
additively increase window size …
…. until loss occurs (then cut window in half)
congestion window size
cwnd: TCP sender

AIMD saw tooth


behavior: probing
for bandwidth

time
3-62
TCP Slow Start
Host A Host B
 when connection begins,
increase rate
exponentially until first
loss event:

RTT
 initially cwnd = 1 MSS
 double cwnd every RTT
 done by incrementing
cwnd for every ACK
received
 summary: initial rate is
slow but ramps up
exponentially fast time

3-63
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)

3-64
TCP: switching from slow start
Q: when should the
exponential
increase switch to
linear?
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

3-65
Summary
 principles behind
transport layer services:
 multiplexing,
demultiplexing
 reliable data transfer
 flow control
 congestion control
 instantiation,
implementation in the
Internet
 UDP
 TCP
3-66

You might also like