Académique Documents
Professionnel Documents
Culture Documents
application
transport
network
link
physical
multiplexing/demultiplexing
reliable data transfer
ow control
congestion control
UDP: connectionless
TCP: connection-oriented
TCP congestion control
TCP
connection-oriented, reliable
in-order stream of bytes
congestion control, ow
control, connection setup
users see stream of bytes TCP breaks into segments
UDP
unreliable, unordered
users supply chunks to UDP,
which wraps each chunk into
a segment / datagram
Both TCP and UDP use IP,
which is best-eort - no delay or
bandwidth guarantees
Multiplexing
Goal: put several transport-layer connections over
one network-layer connection
Demultiplexing at rcv host:
delivering received segments
to correct socket
Demultiplexing
32 bits
source port #
dest port #
application data
(message)
TCP/UDP segment format
TCP demultiplexing
RFC 768
The no frills Internet
transport protocol
best eor: UDP segments
may be:
lost
delivered out of order
connectionless
no handshaking between
sender and receiver
each segment handled
independently of others
UDP
32 bits
source port #
dest port #
length
(in bytes of UDP
segment, including
header)
checksum
application data
(message)
UDP checksum
Purpose: to detect errors (e.g., ipped bits) in a
transmitted segment
Sender
treat segment contents as a
sequence of 16-bit integers
checksum: addition (1s
complement sum) of segment
contents
sender puts checksum value into
UDP checksum eld
Receiver
compute checksum of received
segment
check if computed checksum
equals checksum eld value
NO = error detected
YES = no error detected
(but maybe errors anyway?)
wraparound
1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
_________________________________
sum
checksum
1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
rdt_send():
SEND
SIDE
udt_send():
called by
rdt to transfer packet
over unreliable channel
to receiver
deliver_data():
called by
rdt to deliver data to upper
layer
RECV
SIDE
rdt_recv():
called
when packet arrives
on rcv side of
channel
state
1
state
2
event
actions
initial
state
rdt1.0
No bit errors, no packet loss, no packet reordering
SENDER
RECEIVER
rdt2.0
What if channel has bit errors (ipped bits)?
How to recover?
error detectio#
receiver feedback: control messages (ACK, NAK)
retransmissio#
rdt2.0
SENDER
RECEIVER
RECEIVER
data1
data1
ACK
data2
delivered
!
NAK
data2
data2
ACK
data3
NAK
delivered
data3
ACK
data3
delivered
data3
ACK
delivered
If ACK/NAK corrupted
sender doesnt know what
happened at receiver
shouldnt just retransmit:
possible duplicate
Solution:
sender adds sequence number to
each packet
sender retransmits current
packet if ACK/NAK garbled
receiver discards duplicates
Stop and wai$
Sender sends one packet, then
waits for receiver response
rdt2.1 sender
rdt2.1 receiver
rdt2.1
Sender
seq # added
two seq #s (0,1) sucient
must check if received ACK/
NAK is corrupted
2x state
state must remember
whether current packet
has 0 or 1 seq #
Receiver
must check if received packet is
duplicate
state indicates whether 0 or 1
is expected seq #
receiver can not know if its last
ACK/NAK was received OK at
sender
rdt2.1 works!
SENDER
RECEIVER
data1/0
data1
ACK
data2/1
delivered
!
NAK
data2/1
data2
ACK
data3/0
NAK
delivered
data3
ACK
data3/0
ACK
delivered
rdt2.2 sender
duplicate ACK at sender results in the same action as
a NAK: retransmit current packe$
rdt2.2 works!
SENDER
RECEIVER
data1/0
data1
ACK0
data2/1
delivered
!
ACK0
data2/1
data2
ACK1
data3/0
#%$
delivered
data3
ACK0
data3/0
ACK0
delivered
Assume:
Underlying channel can also
lose packets (both data and
ACKs)
checksum, seq #, ACKs,
retransmissions will help, but
not enough
Approach:
sender waits reasonable
amount of time for ACK
retransmits if no ACK
received in this time
if pkt (or ACK) just delayed
(not lost)
retransmission is duplicate, but
seq # handles this
received must specify seq # of
packet being ACKed
requires countdown timer
rdt3.0 sender
rdt3.0 in action
SENDER
timeout
timeout
{
{
{
{
{
RECEIVER
data1/0
data1
ACK0
data2/1
data2/1
data2
ACK1
data3/0
delivered
ACK0
data3/0
ACK0
delivered
data3
delivered
Pipelining
Pipelined protocols
Go-back-N
Sender
k-bit sequence number in packet header
window of up to N, consecutive unACKed packets allowed
ACK(n): ACKs all packets up to, including sequence number n
= cumulative ACK
(this may deceive duplicate ACKs)
timer for each packet in ight
timeout(n): retransmit packet n and all higher sequence #
packets in window
Go-back-N sender
Go-back-N receiver
out-of-order packet:
discard (dont buer), i.e., no
receiver buering
reACK packet with highest
in-order sequence number
go-back-N in action
SENDER
RECEIVER
data1
data2
data3
ACK1
!
ACK2
data4
data3 timeout
data5
ACK2
data3
ACK2
data4
ACK3
ACK4
Selective Repeat
If we lose one packet in go-back-N
Sender window
Selective Repeat
Sender
if next available seq # is in
window, send packet
timeout(n): resend pkt n,
restart timer
ACK(n) in [sendbase, sendbase+N]:
mark packet n as received
if n is smallest unACKed
packet, advance window base
to next unACKed seq #
Need >= 2N sequence numbers
or reuse may confuse
receiver
Receiver
pkt n in [rcvbase, rcvbase+N-1]:
send ACK(n)
if out of order, buer
if in order: deliver (also deliver
any buered, in-order pkts),
advance window to next
not-yet-received pkt
pkt n in [rcvbase, rcvbase+n-1]:
send ACK(n)
even though already ACKed
otherwise
ignore
SR in action
SENDER
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
(window full)
1 2 3 4 5 6 7 8 9 10
(ACK1 received)
1 2 3 4 5 6 7 8 9 10
data3 timeout
RECEIVER
data1
data2
data3
1 2 3 4 5 6 7 8 9 10
ACK1
!
ACK2
data4
data5
data6
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
ACK4
ACK5
data3
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
ACK3
TCP
point-to-point
one sender, one receiver
reliable, in-order byte strea'
no message boundaries
pipelined
TCP congestion control and
ow control set window size
send and receive buers
ow-controlled
sender will not
overwhelm receiver
full-duplex data
bi-directional data ow in
same connection
MSS: maximum segment size
connection-oriented
handshaking initialises sender,
receiver state before data
exchange
dest port #
A = ACK# valid
P = push data (not
often used)
R,S,F = RST, SYN,
FIN = connection
setup/teardown
commands
Internet
checksum (like
UDP)
sequence number
acknowledgement number
head not
UA P R S F
len used
receive window
checksum
counted in bytes
(not segments)
#bytes receiver
willing to accept
Sequence numbers
byte-stream # of rst byte in
segmens data
ACKs
seq # of next byte expected
from other side
cumulative ACK
How does receiver handle outof-order segments?
Spec doesnt say; up to
implementor
Most buer and wait for
missing to be retransmitted
TCP timeout
Timeout = EstimatedRTT + safety margin
(typical = 0.25)
RDT in TCP
Pipelined segments
Cumulative ACKs
Single retransmission timer
Retransmissions triggered by :
timeout events
duplicate ACKs
Timeout:
retransmit segment that caused
timeout
restart timer
ACK received:
If ACK acknowledges
previously-unACKed segments
update what is known to be
ACKed
start timer if there are
outstanding segments
+ length(data)
SendBase-1 = last
cumulativelyACKed byte
e.g.,
application above
sequence number NextSeqNum
running)
SendBase-1 = 71;
y = 73, so receiver
wants 73+
y > SendBase, so
the new data is
ACKed
HOST B
SEQ=92
timeout
, 8 by
tes da
ta
ACK=10
SEQ=92
, 8 by
tes da
ta
ACK=10
SendBase = 100
time
HOST B
SEQ=92
timeout
, 8 by
tes da
ta
SEQ=10
0, 20
bytes
data
0
0
1
K=
AC
SendBase =
120
timeout
SendBase =
100
0
2
1
, A8
CK=bytes
data
SEQ=92
SendBase =
120
time
0
2
1
=
ACK
HOST B
SEQ=92
, 8 by
tes da
ta
SEQ=10
timeout
0, 20
bytes
data
0
0
1
K=
AC
!
AC
0
2
1
K=
SendBase =
120
time
TCP ow control
Flow control: prevent sender from overwhelming receiver
Receiver side of TCP connection has a receive buer
TCP ow control
value is dynamic
RcvWindow
guarantees receive buer will not
overow
close
SERVER
FIN
ACK
FIN
ACK
timed wait
CLIENT
closed
time
close
closed
TCP server
lifecycle
TCP client
lifecycle
PSH = push
URG = urgent
See RFC 793 for more info (also 1122, 1323, 2018, 2581)
Congestion control
What is congestion?
Too many sources sending too much data too fast for
Manifestations
2 senders, 2 receivers
link capacity R
1 router, innite
buers
no retransmissions
AC
BD
nite buers
multihop paths
timeouts/
retransmits
if data cell preceding RM cell has EFCI set, sender sets CI bit in
returned RM cell
TCP AIMD
Multiplicative decrease
Additive increase
halve CongWin after loss event increase CongWin by 1 MSS
every RTT in the absence of
loss events (probing)
TCP sawtooth
HOST B
RTT
1 segment
2 segment
RTT
4 segment
time
CongWin halved
Why?
TCP throughput
High-speed TCP
assume: 1500 byte MSS (common for Ethernet),
100ms RTT, 10Gbps desired throughput
W = 83,333 segments
RT T L
is this realistic?
Fairness
If k TCP sessions share same bottleneck link of
bandwidth R, each should have an average rate of R/*
suppose we are at A
total < R, so both increase
B, total > R, so loss
both decrease window by a
factor of 2
C
total < R, so both increase
etc...
Fairness
multimedia apps often use UDP
What is fair?
Max-min fairness
Give the ow with the lowest rate the largest possible share
Proportional fairness
Pareto-fairness
Per-link fairness
Utility functions/pricing
10million
100000
hosts
hosts
1000
4
100million
hosts
hosts
hosts
1million
hosts
1996
1999
1990
1991
1983
1995
2001
1976
1978
1985
1969
1957
early
1971
60s
------------------------------------------------------Hotmail
debuts.
business.com
End
ofsends Packet-switching
CERN
releases
DNS
RealAudio,
developed.
Lawsuits
close
The
Queen
ISI
TCP
manages
becomes
DNS
Sputnik
First
launched.
IMP
Ray
Tomlinson
Internet2
domain
ARPANET.
sellsdebut.
for
First
First
web
AltaVista
Napster
down.
an e-mail.
root
TCP/IP.
server,
SRI
ARPA
installed
created
at
in WWW.
develops
independently
e-mail.
launched.
Quake
commercial
$7.5m.
ISP Code
server
Netscape
Red,
Nimda
NIC
manages
UCLA
response.
(rst IPO.
host
invented
By
1973
e-mail
by
Paulis
II75%
released.
Napster
(world.std.com).
launches.
(nsoc01.cern.ch).
worms.
registrations.
on
ARPANET).
Baran
(RAND),
of
BitTorrent
symbolic.com
Second host
Donald
ARPANET
Daviesis
introduced.
rsttrac.
registered
installed at SRI.
(NPL,
UK) and
X-Box
debuts
domain.
First host-to-host
Leonard
with integrated
message crashes Kleinrock
(MIT).
Ethernet port.
on G of
LOGIN.
10000
hosts
300million
hosts
1997
1998
2003
1979
1993
1994
2004
1973
1982
1988
1967
1986
1968
1974
------------------------------------------------------------802.11
standard
Google
launches.
Slammer,
Mosaic
First
launched.
MUD
Blaster
e-commerce.
Network
Bob Metcalfe
UCL
DoD
and
adopts
Norway
OSI
Lawrence
NSFNET
Robert
created. First
BBN
starts
work
Vint
Cerf
and
released.
WWW
worms.
developed
grows
Flash
at by Solutions
First
cyberbank.
oers
invents
Ethernet.
model.
connect
Internet
to
proposes
IETF/IRTF
the
on
the
IMP
Bob
Kahn
publish
mobs,
341,634%.
Essex.
blogs
First
online
pizzayear
domain
UCL
becomes 100
ARPANET/
worm
infects
ARPANET
created.
(Interface
A
Protocol
for
become
Doom
popular.
released.
ordering.
registrations.
rst international
Internet
mostNetwork
of
using
the
Message
Packet
Verisign
almost
First spam.
ARPANET
node. ARPANET,
TCP/IP
over
leads
Processor).
Interconnection
destroys DNS
First
banner
toSATNET.
formation
(TCP) ad.of
(Site Finder).
Yahoo!CERT.
launches.
RIAA starts
sueing P2P endusers.