0% found this document useful (0 votes)
18 views72 pages

Chapter 3 - Transport Layer

Uploaded by

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

Chapter 3 - Transport Layer

Uploaded by

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

Chapter 3

Transport
Layer

A note on the use of these ppt slides:


Computer
We’re making these slides freely available to all (faculty, students, readers).
They’re in PowerPoint form so you see the animations; and can add, modify,
Networking: A
and delete slides (including this one) and slide content to suit your needs.
They obviously represent a lot of work on our part. In return for use, we only
Top Down
ask the following:
 If you use these slides (e.g., in a class) that you mention their source
Approach
(after all, we’d like people to use our book!) 6th edition
 If you post any slides on a www site, that you note that they are adapted Jim Kurose, Keith
from (or perhaps identical to) our slides, and note our copyright of this
material.
Ross
Addison-Wesley
Thanks and enjoy! JFK/KWR
March 2012
All material copyright 1996-2013
J.F Kurose and K.W. Ross, All Rights Reserved

Transport Layer 3-1


Chapter 3 outline
3.1 transport-layer 3.5 connection-
services oriented transport:
3.2 multiplexing TCP
 segment structure
and
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-2
Transport services and
protocols applicatio
n
 provide logical transport

communication between network


data link
app processes running on physical

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

r
t
 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 household analogy:
 network layer:
logical 12 kids in Ann’s house
communication sending letters to 12
kids in Bill’s house:
between hosts  hosts = houses
 transport layer:  processes = kids

logical  app messages =

communication letters in envelopes


between  transport protocol =
Ann and Bill who
processes demux to in-house
 relies on, and siblings
enhances,  network-layer
network layer protocol = postal
services service

Transport Layer 3-4


Internet transport-layer
protocols applicatio
 reliable, in-order n
transport
delivery (TCP) network
data link
network
 congestion control physical

lo
network data link

gi
data link physical
 flow control

ca
physical
network

l en
 connection setup data link

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
physical
 services not data link
physical

available:
 delay guarantees
 bandwidth
guarantees Transport Layer 3-5
HTTP FTP TFTP

Web
Server

TCP

TCP
Email and
TCP TFTP
UDP Server

TCP
UDP

 A single client might have multiple TCP or UDP connections with multiple servers
at the same time.
 As the TCP perform handshaking , it is represented by a two ways arrow.

6
Segmentation and

Reassembly
An Ethernet frame has a maximum frame size or Maximum Transmission Unit (MTU)
of 1,518 bytes.

 When a larger message is to be sent, data must be segmented.


 The maximum size of the frame determines what should the segment size be.
 Each segment is encapsulated in a frame after being addressed and numbered.
Segmentation and
Reassembly

20 octets 20 octets 1460 octets

TCP MSS =1460


Data = 1460 byte

1500 – packet
size

Note : 2346 bytes for


wireless.

8
Chapter 3 outline
3.1 transport-layer 3.5 connection-
services oriented transport:
3.2 multiplexing TCP
 segment structure
and
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-9
Transport Layer
Functions
Prepares the data to be sent over the network layer.

 Uses port number and sequence number to assemble and distinguish between
multiple application segments received at a device.
 This also allows data to be multiplexed on the line.
Multiplexing/demultiplexing
 host receives IP datagrams 32 bits
 each datagram has source IP
address, destination IP address source port # dest port #
 each datagram carries one
transport-layer segment
 each segment has source, other header fields
destination port number
 host uses IP addresses & port
numbers to direct segment to application
appropriate socket
data
(payload)

TCP/UDP segment format

Transport Layer 3-11


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

application P1 P2 application socket


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

Transport Layer 3-12


Connectionless
demultiplexing
 recall: created socket  recall: when creating
has host-local port #: datagram to send
DatagramSocket mySocket1
= new
into UDP socket, must
DatagramSocket(12534); specify
 destination IP address
 destination port #
 when host receives IP datagrams with
UDP segment: same dest. port #,
 checks destination but different source
port # in segment IP addresses and/or
 directs UDP segment source port numbers
will be directed to
to socket with that
port # same socket at dest
Transport Layer 3-13
Connectionless demux:
example
DatagramSocket serverSocket
= new DatagramSocket
DatagramSocket (6428); DatagramSocket
mySocket2 = new mySocket1 = new
DatagramSocket DatagramSocket
(9157); application
(5775);
application P1 application
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: ?
Transport Layer 3-14
Connection-oriented
demux
 TCP socket  server host may
identified by 4- support many
tuple: simultaneous TCP
 source IP address sockets:
 source port number  each socket identified
by its own 4-tuple
 dest IP address
 dest port number
 web servers have
different sockets for
 demux: receiver each connecting
uses all four values client
to direct segment  non-persistent HTTP
to appropriate will have different
socket socket for each
request
Transport Layer 3-15
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: physical
IP
address
B
host: IP source IP,port: B,80 host: IP
address dest IP,port: A,9157 source IP,port: C,5775 address
A dest IP,port: B,80 C
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 Transport Layer 3-16
Connection-oriented demux:
example
threaded server
application
application application
P4
P3 P2 P3
transport
transport transport
network
network link network
link physical link
physical server: physical
IP
address
B
host: IP source IP,port: B,80 host: IP
address dest IP,port: A,9157 source IP,port: C,5775 address
A dest IP,port: B,80 C
source IP,port: A,9157
dest IP, port: B,80
source IP,port: C,9157
dest IP,port: B,80

Transport Layer 3-17


Port Addressing Types and
Tools
• Well-Known Ports:

 Reserved for common services and applications.

20 – FTP Data 443 – HTTPS


25 – SMTP
21 – FTP Control
69 – TFTP
110 – POP3
23 – Telnet
520 – RIP
194 – IRC
Port Addressing Types and
Tools
• Registered Ports:

 Non-common Optional user processes and applications.


 May also be used as dynamic or private port (next).

1863 – MSN Messenger 1812 – RADIUS

2000 – Cisco VoIP


8008 – Alternate HTTP

5004 – RTP
8080 – Alternate HTTP

5060 – SIP (VoIP)


Port Addressing Types and
Tools
• Dynamic Ports:

 Usually assigned dynamically to client applications initiating a connection.

 Note: Some peer-to-peer file-sharing programs use these ports as Register Ports.
Client Server
Example : Establishing a Telnet
session

Telnet
Client TCP Header

4922 23
2

Telnet Data

 Client sends TCP segment with:


• Destination Port: 23 (Well known port number)
• Source Port: 49222 (Dynamic Port assigned by client)

21
Client Server

Example : Establishing a Telnet


session

Telnet
Server TCP Header

23 49222

Telnet Data

 Server responds with TCP segment with:

• Destination Port: 49222 (Dynamic Port assigned by client)


• Source Port: 23 (Well-known port number)
22
Same client to same server but with
two different HTTP sessions
49888  Client: Same destination port 49890
 Client: Different source ports to
uniquely identify this web session.

C:\netstat -n
Destination Port Connection
Active Connections Source Port State
TCP
Proto Local Address Foreign Address State
or TCP 192.168.1.101:49888 198.133.219.25:80 TIME_WAIT
UDP TCP 192.168.1.101:49890 198.133.219.25:80 TIME_WAIT

23 Source IP Destination IP
Chapter 3 outline
3.1 transport-layer 3.5 connection-
services oriented transport:
3.2 multiplexing TCP
 segment structure
and
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-24
UDP: User Datagram Protocol
[RFC 768]
 “no frills,” “bare bones”  UDP use:
Internet transport  streaming
protocol
multimedia apps
 “best effort” service,
UDP segments may be: (loss tolerant, rate
 lost sensitive)
 delivered out-of-order  DNS
to app  SNMP
 connectionless:  reliable transfer
 no handshaking
between UDP sender, over UDP:
receiver  add reliability at
 each UDP segment application layer
handled  application-specific
independently of error recovery!
others

Transport Layer 3-25


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
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

Transport Layer 3-26


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
integers
 check if computed
 checksum: addition checksum equals
(one’s complement checksum field value:
sum) of segment  NO - error detected
contents  YES - no error detected.
 sender puts checksum But maybe errors
value into UDP nonetheless?
checksum field

Transport Layer 3-27


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

Transport Layer 3-28


Chapter 3 outline
3.1 transport-layer 3.5 connection-
services oriented transport:
3.2 multiplexing TCP
 segment structure
and
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-29
Principles of reliable data
transfer
 important in application, transport, link layers
 top-10 list of important networking topics!

 characteristics of unreliable channel will determine complexity of reliable


data transfer protocol (rdt)

Transport Layer 3-30


Principles of reliable data
transfer
 important in application, transport, link layers
 top-10 list of important networking topics!

 characteristics of unreliable channel will determine complexity of reliable


data transfer protocol (rdt)

Transport Layer 3-31


Principles of reliable data
transfer
 important in application, transport, link layers
 top-10 list of important networking topics!

 characteristics of unreliable channel will determine complexity of reliable


data transfer protocol (rdt)

Transport Layer 3-32


rdt2.0: channel with bit
errors
 underlying channel may flip bits in packet
 checksum to detect bit errors
 the question: how to recover from errors:
 acknowledgements (ACKs): receiver explicitly
tells sender that pkt received OK
 negative acknowledgements (NAKs): receiver
explicitly tells sender that pkt had errors
 sender retransmits pkt on receipt of NAK
How do humansinrecover
new mechanisms from rdt1.0
rdt2.0 (beyond “errors”
):
during conversation?
 error detection
 receiver feedback: control msgs (ACK,NAK) rcvr-
>sender

Transport Layer 3-33


rdt3.0 in
action
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


Transport Layer 3-34
rdt3.0 in
action sender receiver
sender receiver send pkt0 pkt0
send pkt0 pkt0 rcv pkt0
ack0 send ack0
rcv pkt0
send ack0 rcv ack0
ack0 send pkt1 pkt1
rcv ack0 rcv pkt1
send pkt1 pkt1
rcv pkt1 send ack1
ack1 ack1
send ack1
X
loss timeout
resend pkt1 pkt1
rcv pkt1
timeout
resend pkt1 pkt1 rcv ack1 pkt0 (detect duplicate)
rcv pkt1 send pkt0 send ack1
(detect duplicate) ack1
ack1 send ack1 rcv ack1 rcv pkt0
rcv ack1 ack0 send ack0
pkt0 send pkt0 pkt0
send pkt0 rcv pkt0
rcv pkt0 ack0 (detect duplicate)
ack0 send ack0 send ack0

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

Transport Layer 3-35


Performance of rdt3.0
 rdt3.0 is correct, but performance stinks
 e.g.: 1 Gbps link, 15 ms prop. delay, 8000 bit packet:

L 8000 bits
Dtrans = R = 9 = 8 microsecs
10 bits/sec
U sender : utilization – fraction of time sender busy sending

U L/R .008
sender = = = 0.00027
RTT + L / R 30.008

 if RTT=30 msec, 1KB pkt every 30 msec:


33kB/sec thruput over 1 Gbps link
 network protocol limits use of physical
resources!
Transport Layer 3-36
rdt3.0: stop-and-wait
operation
sender receiver
first packet bit transmitted, t = 0
last packet bit transmitted, t = L / R

first packet bit arrives


RTT last packet bit arrives, send
ACK

ACK arrives, send next


packet, t = RTT + L / R

U L/R .008
sender = = = 0.00027
RTT + L / R 30.008

Transport Layer 3-37


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
Transport Layer 3-38
Pipelining: increased
utilization
sender receiver
first packet bit transmitted, t = 0
last bit transmitted, t = L / R

first packet bit arrives


RTT last packet bit arrives, send ACK
last bit of 2nd packet arrives, send ACK
last bit of 3rd packet arrives, send ACK
ACK arrives, send next
packet, t = RTT + L / R
3-packet pipelining increases
utilization by a factor of 3!

U 3 L/R .0024
sender = = = 0.00081
RTT + L / R 30.008

Transport Layer 3-39


Pipelined protocols:
overview
Go-back-N: Selective Repeat:
 sender can have  sender can have up
up to N unacked to N unack’ed
packets in pipeline packets in pipeline
 receiver only sends  rcvr sends individual
cumulative ack ack for each packet
 doesn’t ack packet
if there’s a gap
 sender has timer  sender maintains
for oldest unacked timer for each
packet unacked packet
 when timer expires,  when timer expires,
retransmit all retransmit only that
unacked packets unacked packet
Transport Layer 3-40
GBN in action
sender window (N=4) sender receiver
012345678 send pkt0
012345678 send pkt1
send pkt2 receive pkt0, send ack0
012345678
send pkt3 Xloss receive pkt1, send ack1
012345678
(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

Transport Layer 3-41


Selective repeat
 receiver individually acknowledges all
correctly received pkts
 buffers pkts, as needed, for eventual in-
order delivery to upper layer
 sender only resends pkts for which
ACK not received
 sender timer for each unACKed pkt
 sender window
 N consecutive seq #’s
 limits seq #s of sent, unACKed pkts

Transport Layer 3-42


Selective repeat in action
sender window (N=4) sender receiver
012345678 send pkt0
012345678 send pkt1
send pkt2 receive pkt0, send ack0
012345678
send pkt3 Xloss receive pkt1, send ack1
012345678
(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?

Transport Layer 3-43


Chapter 3 outline
3.1 transport-layer 3.5 connection-
services oriented transport:
3.2 multiplexing TCP
 segment structure
and
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-44
TCP: Overview RFCs: 793,1122,1323,
2018, 2581

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


 one sender, one  bi-directional data flow
receiver in same connection
 MSS: maximum
 reliable, in-order segment size
byte stream:  connection-oriented:
 no “message  handshaking
boundaries” (exchange of control
msgs) inits sender,
 pipelined: receiver state before
 TCP congestion and data exchange
flow control set  flow controlled:
window size  sender will not
overwhelm receiver

Transport Layer 3-45


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)

Transport Layer 3-46


TCP seq. numbers, ACKs
outgoing segment from sender
sequence numbers: source port # dest port #
sequence number
 byte stream “number acknowledgement number
” of first byte in rwnd

segment’s data checksum 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


Q: how receiver handles ACKed yet
ACKed
but not usable
yet sent
out-of-order segments (“in-flight
”)
incoming segment to sender
 A: TCP spec doesn’t
source port # dest port #
say, - up to sequence number
implementor acknowledgement number
A rwnd
checksum urg pointer

Transport Layer 3-47


TCP seq. numbers, ACKs
Host A Host B

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

simple telnet scenario

Transport Layer 3-48


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

RTT: gaia.cs.umass.edu to fantasia.eurecom.fr

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-50
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)

TimeoutInterval = EstimatedRTT + 4*DevRTT

estimated RTT “safety margin”

Transport Layer 3-51


Chapter 3 outline
3.1 transport-layer 3.5 connection-
services oriented transport:
3.2 multiplexing TCP
 segment structure
and
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-52
TCP reliable data transfer
 TCP creates rdt
service on top of
IP’s unreliable
service
 pipelined segments let’s initially consider
 cumulative acks simplified TCP
 single sender:
 ignore duplicate acks
retransmission timer
 ignore flow control,
 retransmissions congestion control
triggered by:
 timeout events
 duplicate acks

Transport Layer 3-53


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

Transport Layer 3-54


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

Seq=100, 20 bytes of data


timeo

timeo
ACK=100
ut

ut
X
ACK=100
ACK=120

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


SendBase=100 bytes of data
SendBase=120
ACK=100
ACK=120

SendBase=120

lost ACK scenario premature timeout


Transport Layer 3-55
TCP: retransmission
scenarios
Host A Host B

Seq=92, 8 bytes of data

Seq=100, 20 bytes of data


ACK=100
timeo

X
ut

ACK=120

Seq=120, 15 bytes of data

cumulative ACK
Transport Layer 3-56
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

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-57


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

Transport Layer 3-58


TCP fast
retransmit
Host A Host B

Seq=92, 8 bytes of data


Seq=100, 20 bytes of data
X

ACK=100
timeo

ACK=100
ut

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

fast retransmit after sender


receipt of triple duplicate ACK
Transport Layer 3-59
Chapter 3 outline
3.1 transport-layer 3.5 connection-
services oriented transport:
3.2 multiplexing TCP
 segment structure
and
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-60
TCP flow control
application
application may process
remove data from application
TCP socket buffers ….
TCP socket OS
receiver buffers
… slower than
TCP
receiver is TCP
delivering code
(sender is
sending)
IP
flow control code
receiver controls sender,
so sender won’t overflow
receiver’s buffer by from sender
transmitting too much,
receiver protocol stack
too fast

Transport Layer 3-61


TCP flow control
 receiver “advertises”
free buffer space by to application process
including rwnd value in
TCP header of receiver-
to-sender segments RcvBuffer buffered data
 RcvBuffer size set via
socket options (typical rwnd free buffer space
default is 4096 bytes)
 many operating systems
autoadjust RcvBuffer
TCP segment payloads
 sender limits amount of
unacked (“in-flight”)
data to receiver’s rwnd receiver-side buffering
value
 guarantees receive
buffer will not overflow
Transport Layer 3-62
Chapter 3 outline
3.1 transport-layer 3.5 connection-
services oriented transport:
3.2 multiplexing TCP
 segment structure
and
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-63
Connection Management
before exchanging data, sender/receiver
“handshake”:
 agree to establish connection (each knowing the
other willing to establish connection)
 agree on connection parameters
application application

connection state: connection state:


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

Socket clientSocket = Socket connectionSocket =


newSocket("hostname","port welcomeSocket.accept();
number");
Transport Layer 3-64
TCP 3-way handshake

client state server state


LISTEN 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-65


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

Transport Layer 3-66


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

Transport Layer 3-67


TCP Header UDP Header

Application Header
i.e. (HTTP) header
or + data

68
Some types of data where errors can be tolerated might be send quickly.
TCP/IP Application Layer
Protocols
Application
Layer

20 & 21 80 25 23 69 161 67 & 68 53

Transport
Layer

Internet
Layer

Network
Access
Layer
LAN / WAN

70
Media
Independent

 Transport of IP packets is not limited to any particular medium (Wired


or Wireless).

 The Data Link layer prepares the IP packet for transmission over the
communications medium.
71
Summary: Port Numbers
Port Layer 4
Application Description
Number Protocol
20 FTP TCP File Transfer Protocol – Data

21 FTP TCP File Transfer Protocol – Control Commands

23 TELNET TCP Terminal connection

25 SMTP TCP Simple Mail Transfer Protocol - Email

53 DNS UDP Domain Name System

67,68 DHCP UDP Dynamic Host Configuration Protocol

69 TFTP UDP Trivial File Transfer Protocol

80 HTTP TCP Hypertext Transfer Protocol

You might also like