+ All Categories
Home > Technology > 20080426 networking carzaniga_lecture01-02

20080426 networking carzaniga_lecture01-02

Date post: 05-Dec-2014
Category:
Upload: computer-science-club
View: 1,362 times
Download: 0 times
Share this document with a friend
Description:
 
500
Computer Networks: The Transport Layer Antonio Carzaniga Faculty of Informatics University of Lugano St. Petersburg, Russia April 26, 2008 c 2005–2008 Antonio Carzaniga
Transcript
Page 1: 20080426 networking carzaniga_lecture01-02

Computer Networks:

The Transport Layer

Antonio Carzaniga

Faculty of InformaticsUniversity of Lugano

St. Petersburg, RussiaApril 26, 2008

c© 2005–2008 Antonio Carzaniga

Page 2: 20080426 networking carzaniga_lecture01-02

Outline

Very quick intro to computer networking

The transport layer

◮ reliability

◮ congestion control

◮ brief intro to TCP

c© 2005–2008 Antonio Carzaniga

Page 3: 20080426 networking carzaniga_lecture01-02

Application

webbrowser

webserver

c© 2005–2008 Antonio Carzaniga

Page 4: 20080426 networking carzaniga_lecture01-02

Application

webbrowser

webserver

c© 2005–2008 Antonio Carzaniga

Page 5: 20080426 networking carzaniga_lecture01-02

Application

webbrowser

webserver

GET /carzaniga/ HTTP/1.1

Host: www.inf.unisi.ch

. . .

c© 2005–2008 Antonio Carzaniga

Page 6: 20080426 networking carzaniga_lecture01-02

Application

webbrowser

webserver

HTTP/1.1 200 OK

. . .<html><head>. . . </head><body>. . .

c© 2005–2008 Antonio Carzaniga

Page 7: 20080426 networking carzaniga_lecture01-02

Application

webbrowser

webserver

GET /carzaniga/anto.png HTTP/1.1

Host: www.inf.unisi.ch

. . .

c© 2005–2008 Antonio Carzaniga

Page 8: 20080426 networking carzaniga_lecture01-02

Application

webbrowser

webserver

HTTP/1.1 200 OK

. . .

. . .

c© 2005–2008 Antonio Carzaniga

Page 9: 20080426 networking carzaniga_lecture01-02

Transport

webbrowser

webserver

c© 2005–2008 Antonio Carzaniga

Page 10: 20080426 networking carzaniga_lecture01-02

Transport

webbrowser

webserver

c© 2005–2008 Antonio Carzaniga

Page 11: 20080426 networking carzaniga_lecture01-02

Transport

webbrowser

webserver

c© 2005–2008 Antonio Carzaniga

Page 12: 20080426 networking carzaniga_lecture01-02

Network

webbrowser

webserver

c© 2005–2008 Antonio Carzaniga

Page 13: 20080426 networking carzaniga_lecture01-02

Network

webbrowser

webserver

c© 2005–2008 Antonio Carzaniga

Page 14: 20080426 networking carzaniga_lecture01-02

Network

webbrowser

webserver

c© 2005–2008 Antonio Carzaniga

Page 15: 20080426 networking carzaniga_lecture01-02

Network

c© 2005–2008 Antonio Carzaniga

Page 16: 20080426 networking carzaniga_lecture01-02

Network

c© 2005–2008 Antonio Carzaniga

Page 17: 20080426 networking carzaniga_lecture01-02

Network

c© 2005–2008 Antonio Carzaniga

Page 18: 20080426 networking carzaniga_lecture01-02

Network

c© 2005–2008 Antonio Carzaniga

Page 19: 20080426 networking carzaniga_lecture01-02

Network

c© 2005–2008 Antonio Carzaniga

Page 20: 20080426 networking carzaniga_lecture01-02

Network

c© 2005–2008 Antonio Carzaniga

Page 21: 20080426 networking carzaniga_lecture01-02

Network

c© 2005–2008 Antonio Carzaniga

Page 22: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

c© 2005–2008 Antonio Carzaniga

Page 23: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

c© 2005–2008 Antonio Carzaniga

Page 24: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

c© 2005–2008 Antonio Carzaniga

Page 25: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

c© 2005–2008 Antonio Carzaniga

Page 26: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

c© 2005–2008 Antonio Carzaniga

Page 27: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

c© 2005–2008 Antonio Carzaniga

Page 28: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

c© 2005–2008 Antonio Carzaniga

Page 29: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

c© 2005–2008 Antonio Carzaniga

Page 30: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

Potentially asymmetric paths

c© 2005–2008 Antonio Carzaniga

Page 31: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

Potentially asymmetric paths

c© 2005–2008 Antonio Carzaniga

Page 32: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

Potentially asymmetric paths

c© 2005–2008 Antonio Carzaniga

Page 33: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

Potentially asymmetric paths

c© 2005–2008 Antonio Carzaniga

Page 34: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

Potentially asymmetric paths

c© 2005–2008 Antonio Carzaniga

Page 35: 20080426 networking carzaniga_lecture01-02

Network

Potentially multiple paths for the same source/destination

Potentially asymmetric paths

c© 2005–2008 Antonio Carzaniga

Page 36: 20080426 networking carzaniga_lecture01-02

A “Datagram” Network

c© 2005–2008 Antonio Carzaniga

Page 37: 20080426 networking carzaniga_lecture01-02

A “Datagram” Network

Packet-switched network

c© 2005–2008 Antonio Carzaniga

Page 38: 20080426 networking carzaniga_lecture01-02

A “Datagram” Network

Packet-switched network◮ information is transmitted in discrete units called datagrams

c© 2005–2008 Antonio Carzaniga

Page 39: 20080426 networking carzaniga_lecture01-02

A “Datagram” Network

Packet-switched network◮ information is transmitted in discrete units called datagrams

Connectionless service

c© 2005–2008 Antonio Carzaniga

Page 40: 20080426 networking carzaniga_lecture01-02

A “Datagram” Network

Packet-switched network◮ information is transmitted in discrete units called datagrams

Connectionless service◮ a datagram is a self-contained message◮ treated independently by the network◮ no connection setup/tear-down phase

c© 2005–2008 Antonio Carzaniga

Page 41: 20080426 networking carzaniga_lecture01-02

A “Datagram” Network

Packet-switched network◮ information is transmitted in discrete units called datagrams

Connectionless service◮ a datagram is a self-contained message◮ treated independently by the network◮ no connection setup/tear-down phase

“Best-effort” service

c© 2005–2008 Antonio Carzaniga

Page 42: 20080426 networking carzaniga_lecture01-02

A “Datagram” Network

Packet-switched network◮ information is transmitted in discrete units called datagrams

Connectionless service◮ a datagram is a self-contained message◮ treated independently by the network◮ no connection setup/tear-down phase

“Best-effort” service◮ delivery guarantee: none

c© 2005–2008 Antonio Carzaniga

Page 43: 20080426 networking carzaniga_lecture01-02

A “Datagram” Network

Packet-switched network◮ information is transmitted in discrete units called datagrams

Connectionless service◮ a datagram is a self-contained message◮ treated independently by the network◮ no connection setup/tear-down phase

“Best-effort” service◮ delivery guarantee: none◮ maximum latency guarantee: none

c© 2005–2008 Antonio Carzaniga

Page 44: 20080426 networking carzaniga_lecture01-02

A “Datagram” Network

Packet-switched network◮ information is transmitted in discrete units called datagrams

Connectionless service◮ a datagram is a self-contained message◮ treated independently by the network◮ no connection setup/tear-down phase

“Best-effort” service◮ delivery guarantee: none◮ maximum latency guarantee: none◮ bandwidth guarantee: none

c© 2005–2008 Antonio Carzaniga

Page 45: 20080426 networking carzaniga_lecture01-02

A “Datagram” Network

Packet-switched network◮ information is transmitted in discrete units called datagrams

Connectionless service◮ a datagram is a self-contained message◮ treated independently by the network◮ no connection setup/tear-down phase

“Best-effort” service◮ delivery guarantee: none◮ maximum latency guarantee: none◮ bandwidth guarantee: none◮ in-order delivery guarantee: none

c© 2005–2008 Antonio Carzaniga

Page 46: 20080426 networking carzaniga_lecture01-02

A “Datagram” Network

Packet-switched network◮ information is transmitted in discrete units called datagrams

Connectionless service◮ a datagram is a self-contained message◮ treated independently by the network◮ no connection setup/tear-down phase

“Best-effort” service◮ delivery guarantee: none◮ maximum latency guarantee: none◮ bandwidth guarantee: none◮ in-order delivery guarantee: none◮ congestion indication: none

c© 2005–2008 Antonio Carzaniga

Page 47: 20080426 networking carzaniga_lecture01-02

Transport-Layer Value-Added Service

c© 2005–2008 Antonio Carzaniga

Page 48: 20080426 networking carzaniga_lecture01-02

Transport-Layer Value-Added Service

Transport-layer multiplexing/demultiplexing◮ i.e., connecting applications as opposed to hosts

c© 2005–2008 Antonio Carzaniga

Page 49: 20080426 networking carzaniga_lecture01-02

Transport-Layer Value-Added Service

Transport-layer multiplexing/demultiplexing◮ i.e., connecting applications as opposed to hosts

Reliable data transfer◮ i.e., integrity and possibly ordered delivery

c© 2005–2008 Antonio Carzaniga

Page 50: 20080426 networking carzaniga_lecture01-02

Transport-Layer Value-Added Service

Transport-layer multiplexing/demultiplexing◮ i.e., connecting applications as opposed to hosts

Reliable data transfer◮ i.e., integrity and possibly ordered delivery

Connections◮ i.e., streams◮ can be seen as the same as ordered dalivery

c© 2005–2008 Antonio Carzaniga

Page 51: 20080426 networking carzaniga_lecture01-02

Transport-Layer Value-Added Service

Transport-layer multiplexing/demultiplexing◮ i.e., connecting applications as opposed to hosts

Reliable data transfer◮ i.e., integrity and possibly ordered delivery

Connections◮ i.e., streams◮ can be seen as the same as ordered dalivery

Congestion control◮ i.e., end-to-end traffic (admission) control so as to avoid

destructive congestions within the network

c© 2005–2008 Antonio Carzaniga

Page 52: 20080426 networking carzaniga_lecture01-02

Transport

webbrowser

webserver

c© 2005–2008 Antonio Carzaniga

Page 53: 20080426 networking carzaniga_lecture01-02

Transport

webbrowser

webserver

c© 2005–2008 Antonio Carzaniga

Page 54: 20080426 networking carzaniga_lecture01-02

Transport

webbrowser

webserver

c© 2005–2008 Antonio Carzaniga

Page 55: 20080426 networking carzaniga_lecture01-02

Transport

webbrowser

webserver

unreliable, datagram =⇒ reliable “stream”

c© 2005–2008 Antonio Carzaniga

Page 56: 20080426 networking carzaniga_lecture01-02

Part I

Reliable Streams on Unreliable Networks

c© 2005–2008 Antonio Carzaniga

Page 57: 20080426 networking carzaniga_lecture01-02

Finite-State Machines

c© 2005–2008 Antonio Carzaniga

Page 58: 20080426 networking carzaniga_lecture01-02

Finite-State Machines

A finite-state machine (FSM) is a mathematical abstraction

◮ a.k.a., finite-state automaton (FSA), deterministic finite-stateautomaton (DFA), non-deterministic finite-state automaton (NFA)

c© 2005–2008 Antonio Carzaniga

Page 59: 20080426 networking carzaniga_lecture01-02

Finite-State Machines

A finite-state machine (FSM) is a mathematical abstraction

◮ a.k.a., finite-state automaton (FSA), deterministic finite-stateautomaton (DFA), non-deterministic finite-state automaton (NFA)

Very useful to specify and implement network protocols

c© 2005–2008 Antonio Carzaniga

Page 60: 20080426 networking carzaniga_lecture01-02

Finite-State Machines

A finite-state machine (FSM) is a mathematical abstraction

◮ a.k.a., finite-state automaton (FSA), deterministic finite-stateautomaton (DFA), non-deterministic finite-state automaton (NFA)

Very useful to specify and implement network protocols

Ubiquitous in computer science

◮ theory of formal languages◮ compiler design◮ theory of computation◮ text processing◮ behavior specification◮ . . .

c© 2005–2008 Antonio Carzaniga

Page 61: 20080426 networking carzaniga_lecture01-02

Finite-State Machines

S1 S2

x

x

c© 2005–2008 Antonio Carzaniga

Page 62: 20080426 networking carzaniga_lecture01-02

Finite-State Machines

S1 S2

x

xStates are represented as nodes in a graph

c© 2005–2008 Antonio Carzaniga

Page 63: 20080426 networking carzaniga_lecture01-02

Finite-State Machines

S1 S2

x

xStates are represented as nodes in a graph

Transitions are represented as directed edges in the graph

c© 2005–2008 Antonio Carzaniga

Page 64: 20080426 networking carzaniga_lecture01-02

Finite-State Machines

S1 S2

x

xStates are represented as nodes in a graph

Transitions are represented as directed edges in the graph◮ an edge labeled x going from state S1 to state S2 says that when

the machine is in state S1 and event x occurs, the machineswitches to state S2

c© 2005–2008 Antonio Carzaniga

Page 65: 20080426 networking carzaniga_lecture01-02

Finite-State Machines

S1 S2

x

xStates are represented as nodes in a graph

Transitions are represented as directed edges in the graph◮ an edge labeled x going from state S1 to state S2 says that when

the machine is in state S1 and event x occurs, the machineswitches to state S2

On Off

button-pushed

button-pushed

c© 2005–2008 Antonio Carzaniga

Page 66: 20080426 networking carzaniga_lecture01-02

Finite-State Machines

1 0

reset

reset

set

set

c© 2005–2008 Antonio Carzaniga

Page 67: 20080426 networking carzaniga_lecture01-02

Finite-State Machines

1 0

reset

reset

set

set

unlockedlocked

try-unlock

1s timeout

button-1 button-2

30s timeout

c© 2005–2008 Antonio Carzaniga

Page 68: 20080426 networking carzaniga_lecture01-02

Finite-State Machines

0/0

15/0

0/15

30/0

0/30

40/0

0/40

15/15

30/15

15/30

30/30

40/15

15/40

40/30

30/40

game A

game B

deuce

adv. A

adv. B

a

a

a

a

a

a

a

a

a

a

a

a

a

a

a

ab

a

b

b

b

b

b

b

b

b

b

b

b

b

b

b

b

ab

b

c© 2005–2008 Antonio Carzaniga

Page 69: 20080426 networking carzaniga_lecture01-02

FSMs to Specify Protocols

c© 2005–2008 Antonio Carzaniga

Page 70: 20080426 networking carzaniga_lecture01-02

FSMs to Specify Protocols

States represent the state of a protocol

c© 2005–2008 Antonio Carzaniga

Page 71: 20080426 networking carzaniga_lecture01-02

FSMs to Specify Protocols

States represent the state of a protocol

Transitions are characterized by an event/action label

◮ event: typically consists of an input message or a timeout◮ action: typically consists of an output message

c© 2005–2008 Antonio Carzaniga

Page 72: 20080426 networking carzaniga_lecture01-02

FSMs to Specify Protocols

States represent the state of a protocol

Transitions are characterized by an event/action label

◮ event: typically consists of an input message or a timeout◮ action: typically consists of an output message

E.g., here’s a specification of a “simple conversation protocol”

inputoutput

S C

“Hello!”“Yo”

“Bye.”“Okay. Bye.”

30s“Gotta go. Bye.”

“bla”“aha”

c© 2005–2008 Antonio Carzaniga

Page 73: 20080426 networking carzaniga_lecture01-02

Example

E.g., a subset of a server-side, SMTP-like protocol

S A

accept“220 Ok”

60secclose

R

“RCPT TO”“250 Ok”

T

“MAIL FROM”“250 Ok”

D

“MAIL FROM”“250 Ok”

“RCPT TO”“250 Ok”

30secclose

30secclose

M

“DATA”“354 end with .”

line

60sclose

“.”“250 accepted”

“QUIT”“221 bye”,close

c© 2005–2008 Antonio Carzaniga

Page 74: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Transferap

plic

atio

n

Webbrowser

Webserver

c© 2005–2008 Antonio Carzaniga

Page 75: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Transferap

plic

atio

n

Webbrowser

Webserver

netw

ork

best-effort (i.e., unreliable) network

c© 2005–2008 Antonio Carzaniga

Page 76: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Transferap

plic

atio

n

Webbrowser

Webserver

netw

ork

best-effort (i.e., unreliable) network

tran

spor

t

reliable-transferprotocol

reliable-transferprotocol

c© 2005–2008 Antonio Carzaniga

Page 77: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Transferap

plic

atio

n

Webbrowser

Webserver

netw

ork

best-effort (i.e., unreliable) network

tran

spor

t

reliable-transferprotocol

reliable-transferprotocol

r_send() r_recv()

c© 2005–2008 Antonio Carzaniga

Page 78: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Transferap

plic

atio

n

Webbrowser

Webserver

netw

ork

best-effort (i.e., unreliable) network

tran

spor

t

reliable-transferprotocol

reliable-transferprotocol

r_send() r_recv()

u_send() u_recv()

c© 2005–2008 Antonio Carzaniga

Page 79: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Transferap

plic

atio

n

Webbrowser

Webserver

netw

ork

best-effort (i.e., unreliable) network

tran

spor

t

reliable-transferprotocol

reliable-transferprotocol

r_send() r_recv()

u_send() u_recv()

r_send() r_recv()

u_send() u_recv()

c© 2005–2008 Antonio Carzaniga

Page 80: 20080426 networking carzaniga_lecture01-02

Reliable Data Transfer Model

sender receiver

c© 2005–2008 Antonio Carzaniga

Page 81: 20080426 networking carzaniga_lecture01-02

Reliable Data Transfer Model

sender receiver

reliable-transferprotocol(sender)

c© 2005–2008 Antonio Carzaniga

Page 82: 20080426 networking carzaniga_lecture01-02

Reliable Data Transfer Model

sender receiver

reliable-transferprotocol(sender)

r_send()

c© 2005–2008 Antonio Carzaniga

Page 83: 20080426 networking carzaniga_lecture01-02

Reliable Data Transfer Model

sender receiver

reliable-transferprotocol(sender)

r_send()

u_send() u_recv()

network

c© 2005–2008 Antonio Carzaniga

Page 84: 20080426 networking carzaniga_lecture01-02

Reliable Data Transfer Model

sender receiver

reliable-transferprotocol(sender)

r_send()

u_send() u_recv()

network

r_recv()

reliable-transferprotocol

(receiver)

u_send() u_recv()

c© 2005–2008 Antonio Carzaniga

Page 85: 20080426 networking carzaniga_lecture01-02

Baseline Protocol

Reliable transport protocol that uses a reliable network(obviously a contrived example)

sender

Sr send(data)u send(data)

c© 2005–2008 Antonio Carzaniga

Page 86: 20080426 networking carzaniga_lecture01-02

Baseline Protocol

Reliable transport protocol that uses a reliable network(obviously a contrived example)

sender

Sr send(data)u send(data)

receiver

Ru recv(data)r recv(data)

c© 2005–2008 Antonio Carzaniga

Page 87: 20080426 networking carzaniga_lecture01-02

Baseline Protocol

Reliable transport protocol that uses a reliable network(obviously a contrived example)

sender

Sr send(data)u send(data)

receiver

Ru recv(data)r recv(data)

c© 2005–2008 Antonio Carzaniga

Page 88: 20080426 networking carzaniga_lecture01-02

Noisy Channel

c© 2005–2008 Antonio Carzaniga

Page 89: 20080426 networking carzaniga_lecture01-02

Noisy Channel

Reliable transport protocol over a network with bit errors

◮ every so often, a bit will be modified during transmission◮ that is, a bit will be “flipped”

◮ however, no packets will be lost

c© 2005–2008 Antonio Carzaniga

Page 90: 20080426 networking carzaniga_lecture01-02

Noisy Channel

Reliable transport protocol over a network with bit errors

◮ every so often, a bit will be modified during transmission◮ that is, a bit will be “flipped”

◮ however, no packets will be lost

How do people deal with such situations?(Think of a phone call over a noisy line)

c© 2005–2008 Antonio Carzaniga

Page 91: 20080426 networking carzaniga_lecture01-02

Noisy Channel

Reliable transport protocol over a network with bit errors

◮ every so often, a bit will be modified during transmission◮ that is, a bit will be “flipped”

◮ however, no packets will be lost

How do people deal with such situations?(Think of a phone call over a noisy line)

◮ error detection: the receiver must be able to know when areceived packet is corrupted (i.e., when it contains flipped bits)

c© 2005–2008 Antonio Carzaniga

Page 92: 20080426 networking carzaniga_lecture01-02

Noisy Channel

Reliable transport protocol over a network with bit errors

◮ every so often, a bit will be modified during transmission◮ that is, a bit will be “flipped”

◮ however, no packets will be lost

How do people deal with such situations?(Think of a phone call over a noisy line)

◮ error detection: the receiver must be able to know when areceived packet is corrupted (i.e., when it contains flipped bits)

◮ receiver feedback: the receiver must be able to alert the senderthat a corrupted packet was received

c© 2005–2008 Antonio Carzaniga

Page 93: 20080426 networking carzaniga_lecture01-02

Noisy Channel

Reliable transport protocol over a network with bit errors

◮ every so often, a bit will be modified during transmission◮ that is, a bit will be “flipped”

◮ however, no packets will be lost

How do people deal with such situations?(Think of a phone call over a noisy line)

◮ error detection: the receiver must be able to know when areceived packet is corrupted (i.e., when it contains flipped bits)

◮ receiver feedback: the receiver must be able to alert the senderthat a corrupted packet was received

◮ retransmission: the sender retransmits corrupted packets

c© 2005–2008 Antonio Carzaniga

Page 94: 20080426 networking carzaniga_lecture01-02

Error Detection

c© 2005–2008 Antonio Carzaniga

Page 95: 20080426 networking carzaniga_lecture01-02

Error Detection

Key idea: sending redundant information

◮ e.g., the sender could repeat the message twice

c© 2005–2008 Antonio Carzaniga

Page 96: 20080426 networking carzaniga_lecture01-02

Error Detection

Key idea: sending redundant information

◮ e.g., the sender could repeat the message twice◮ error iff the receiver hears two different messages

c© 2005–2008 Antonio Carzaniga

Page 97: 20080426 networking carzaniga_lecture01-02

Error Detection

Key idea: sending redundant information

◮ e.g., the sender could repeat the message twice◮ error iff the receiver hears two different messages◮ not very efficient: uses twice the number of bits

c© 2005–2008 Antonio Carzaniga

Page 98: 20080426 networking carzaniga_lecture01-02

Error Detection

Key idea: sending redundant information

◮ e.g., the sender could repeat the message twice◮ error iff the receiver hears two different messages◮ not very efficient: uses twice the number of bits

Error-detection codes

c© 2005–2008 Antonio Carzaniga

Page 99: 20080426 networking carzaniga_lecture01-02

Error Detection

Key idea: sending redundant information

◮ e.g., the sender could repeat the message twice◮ error iff the receiver hears two different messages◮ not very efficient: uses twice the number of bits

Error-detection codes

◮ e.g., the parity bit

c© 2005–2008 Antonio Carzaniga

Page 100: 20080426 networking carzaniga_lecture01-02

Error Detection

Key idea: sending redundant information

◮ e.g., the sender could repeat the message twice◮ error iff the receiver hears two different messages◮ not very efficient: uses twice the number of bits

Error-detection codes

◮ e.g., the parity bit

◮ sender adds one bit that is the xor of all the bits in the message

c© 2005–2008 Antonio Carzaniga

Page 101: 20080426 networking carzaniga_lecture01-02

Error Detection

Key idea: sending redundant information

◮ e.g., the sender could repeat the message twice◮ error iff the receiver hears two different messages◮ not very efficient: uses twice the number of bits

Error-detection codes

◮ e.g., the parity bit

◮ sender adds one bit that is the xor of all the bits in the message◮ receiver computes the xor of all the bits and concludes that there

was an error if the result is not 0 (i.e., if it is 1)

c© 2005–2008 Antonio Carzaniga

Page 102: 20080426 networking carzaniga_lecture01-02

Error Detection

Key idea: sending redundant information

◮ e.g., the sender could repeat the message twice◮ error iff the receiver hears two different messages◮ not very efficient: uses twice the number of bits

Error-detection codes

◮ e.g., the parity bit

◮ sender adds one bit that is the xor of all the bits in the message◮ receiver computes the xor of all the bits and concludes that there

was an error if the result is not 0 (i.e., if it is 1)

Sender:message is 1001011011101000

c© 2005–2008 Antonio Carzaniga

Page 103: 20080426 networking carzaniga_lecture01-02

Error Detection

Key idea: sending redundant information

◮ e.g., the sender could repeat the message twice◮ error iff the receiver hears two different messages◮ not very efficient: uses twice the number of bits

Error-detection codes

◮ e.g., the parity bit

◮ sender adds one bit that is the xor of all the bits in the message◮ receiver computes the xor of all the bits and concludes that there

was an error if the result is not 0 (i.e., if it is 1)

Sender:message is 1001011011101000⇒ send 10010110111010000

c© 2005–2008 Antonio Carzaniga

Page 104: 20080426 networking carzaniga_lecture01-02

Error Detection

Key idea: sending redundant information

◮ e.g., the sender could repeat the message twice◮ error iff the receiver hears two different messages◮ not very efficient: uses twice the number of bits

Error-detection codes

◮ e.g., the parity bit

◮ sender adds one bit that is the xor of all the bits in the message◮ receiver computes the xor of all the bits and concludes that there

was an error if the result is not 0 (i.e., if it is 1)

Sender:message is 1001011011101000⇒ send 10010110111010000

c© 2005–2008 Antonio Carzaniga

Page 105: 20080426 networking carzaniga_lecture01-02

Error Detection

Key idea: sending redundant information

◮ e.g., the sender could repeat the message twice◮ error iff the receiver hears two different messages◮ not very efficient: uses twice the number of bits

Error-detection codes

◮ e.g., the parity bit

◮ sender adds one bit that is the xor of all the bits in the message◮ receiver computes the xor of all the bits and concludes that there

was an error if the result is not 0 (i.e., if it is 1)

Sender:message is 1001011011101000⇒ send 10010110111010000

Receiver:receives 10010110101010000

c© 2005–2008 Antonio Carzaniga

Page 106: 20080426 networking carzaniga_lecture01-02

Error Detection

Key idea: sending redundant information

◮ e.g., the sender could repeat the message twice◮ error iff the receiver hears two different messages◮ not very efficient: uses twice the number of bits

Error-detection codes

◮ e.g., the parity bit

◮ sender adds one bit that is the xor of all the bits in the message◮ receiver computes the xor of all the bits and concludes that there

was an error if the result is not 0 (i.e., if it is 1)

Sender:message is 1001011011101000⇒ send 10010110111010000

Receiver:receives 10010110101010000 ⇒ error!

c© 2005–2008 Antonio Carzaniga

Page 107: 20080426 networking carzaniga_lecture01-02

Noisy Channel

Sender◮ [data]∗ indicates a packet containing data plus an error-detection

code (i.e., a checksum)

c© 2005–2008 Antonio Carzaniga

Page 108: 20080426 networking carzaniga_lecture01-02

Noisy Channel

Sender◮ [data]∗ indicates a packet containing data plus an error-detection

code (i.e., a checksum)

S ACK

r send(data)data pkt = [data]∗

u send(data pkt)

u recv(pkt)and pkt is NACKu send(data pkt)

u recv(pkt)and pkt is ACK

c© 2005–2008 Antonio Carzaniga

Page 109: 20080426 networking carzaniga_lecture01-02

Noisy Channel

Sender◮ [data]∗ indicates a packet containing data plus an error-detection

code (i.e., a checksum)

S ACK

r send(data)data pkt = [data]∗

u send(data pkt)

u recv(pkt)and pkt is NACKu send(data pkt)

u recv(pkt)and pkt is ACK

Receiver

Ru recv(pkt)and pkt is corruptedu send(NACK)

u recv(pkt)and pkt is goodu send(ACK)r recv(pkt)

c© 2005–2008 Antonio Carzaniga

Page 110: 20080426 networking carzaniga_lecture01-02

Noisy Channel

c© 2005–2008 Antonio Carzaniga

Page 111: 20080426 networking carzaniga_lecture01-02

Noisy Channel

This protocol is “synchronous” or “stop-and-wait” for each packet

◮ i.e., the sender must receive a (positive) acknowledgment before itcan take more data from the application layer

c© 2005–2008 Antonio Carzaniga

Page 112: 20080426 networking carzaniga_lecture01-02

Noisy Channel

This protocol is “synchronous” or “stop-and-wait” for each packet

◮ i.e., the sender must receive a (positive) acknowledgment before itcan take more data from the application layer

Does the protocol really work?

c© 2005–2008 Antonio Carzaniga

Page 113: 20080426 networking carzaniga_lecture01-02

Noisy Channel

This protocol is “synchronous” or “stop-and-wait” for each packet

◮ i.e., the sender must receive a (positive) acknowledgment before itcan take more data from the application layer

Does the protocol really work?

What happens if an error occurs within an ACK/NACK packet?

c© 2005–2008 Antonio Carzaniga

Page 114: 20080426 networking carzaniga_lecture01-02

Dealing With Bad ACKs/NACKs

c© 2005–2008 Antonio Carzaniga

Page 115: 20080426 networking carzaniga_lecture01-02

Dealing With Bad ACKs/NACKs

Negative acknowledgments for ACKs and NACKs

1. sender says: “let’s go see Taxi Driver”2. receiver hears: “let’s . . . Taxi . . . ”

c© 2005–2008 Antonio Carzaniga

Page 116: 20080426 networking carzaniga_lecture01-02

Dealing With Bad ACKs/NACKs

Negative acknowledgments for ACKs and NACKs

1. sender says: “let’s go see Taxi Driver”2. receiver hears: “let’s . . . Taxi . . . ”3. receiver says: “Repeat message!”

c© 2005–2008 Antonio Carzaniga

Page 117: 20080426 networking carzaniga_lecture01-02

Dealing With Bad ACKs/NACKs

Negative acknowledgments for ACKs and NACKs

1. sender says: “let’s go see Taxi Driver”2. receiver hears: “let’s . . . Taxi . . . ”3. receiver says: “Repeat message!”4. sender hears: “. . . noise . . . ”

c© 2005–2008 Antonio Carzaniga

Page 118: 20080426 networking carzaniga_lecture01-02

Dealing With Bad ACKs/NACKs

Negative acknowledgments for ACKs and NACKs

1. sender says: “let’s go see Taxi Driver”2. receiver hears: “let’s . . . Taxi . . . ”3. receiver says: “Repeat message!”4. sender hears: “. . . noise . . . ”5. sender says: “Repeat your ACK please!”6. . . .

c© 2005–2008 Antonio Carzaniga

Page 119: 20080426 networking carzaniga_lecture01-02

Dealing With Bad ACKs/NACKs

Negative acknowledgments for ACKs and NACKs

1. sender says: “let’s go see Taxi Driver”2. receiver hears: “let’s . . . Taxi . . . ”3. receiver says: “Repeat message!”4. sender hears: “. . . noise . . . ”5. sender says: “Repeat your ACK please!”6. . . .

Not Good: this protocol doesn’t seem to end

c© 2005–2008 Antonio Carzaniga

Page 120: 20080426 networking carzaniga_lecture01-02

Dealing With Bad ACKs/NACKs

Negative acknowledgments for ACKs and NACKs

1. sender says: “let’s go see Taxi Driver”2. receiver hears: “let’s . . . Taxi . . . ”3. receiver says: “Repeat message!”4. sender hears: “. . . noise . . . ”5. sender says: “Repeat your ACK please!”6. . . .

Not Good: this protocol doesn’t seem to end

Make ACK/NACK packets so redundant that the sender canalways figure out what the message is, even if a few bits arecorrupted

c© 2005–2008 Antonio Carzaniga

Page 121: 20080426 networking carzaniga_lecture01-02

Dealing With Bad ACKs/NACKs

Negative acknowledgments for ACKs and NACKs

1. sender says: “let’s go see Taxi Driver”2. receiver hears: “let’s . . . Taxi . . . ”3. receiver says: “Repeat message!”4. sender hears: “. . . noise . . . ”5. sender says: “Repeat your ACK please!”6. . . .

Not Good: this protocol doesn’t seem to end

Make ACK/NACK packets so redundant that the sender canalways figure out what the message is, even if a few bits arecorrupted

◮ good enough for channels that do not loose messages

c© 2005–2008 Antonio Carzaniga

Page 122: 20080426 networking carzaniga_lecture01-02

Dealing With Bad ACKs/NACKs

Negative acknowledgments for ACKs and NACKs

1. sender says: “let’s go see Taxi Driver”2. receiver hears: “let’s . . . Taxi . . . ”3. receiver says: “Repeat message!”4. sender hears: “. . . noise . . . ”5. sender says: “Repeat your ACK please!”6. . . .

Not Good: this protocol doesn’t seem to end

Make ACK/NACK packets so redundant that the sender canalways figure out what the message is, even if a few bits arecorrupted

◮ good enough for channels that do not loose messages

Assume a NACK and simply retransmit the packet

c© 2005–2008 Antonio Carzaniga

Page 123: 20080426 networking carzaniga_lecture01-02

Dealing With Bad ACKs/NACKs

Negative acknowledgments for ACKs and NACKs

1. sender says: “let’s go see Taxi Driver”2. receiver hears: “let’s . . . Taxi . . . ”3. receiver says: “Repeat message!”4. sender hears: “. . . noise . . . ”5. sender says: “Repeat your ACK please!”6. . . .

Not Good: this protocol doesn’t seem to end

Make ACK/NACK packets so redundant that the sender canalways figure out what the message is, even if a few bits arecorrupted

◮ good enough for channels that do not loose messages

Assume a NACK and simply retransmit the packet◮ good idea, but it introduces duplicate packets (why?)

c© 2005–2008 Antonio Carzaniga

Page 124: 20080426 networking carzaniga_lecture01-02

Dealing With Duplicate Packets

c© 2005–2008 Antonio Carzaniga

Page 125: 20080426 networking carzaniga_lecture01-02

Dealing With Duplicate Packets

The sender adds a sequence number to each packet so that thereceiver can determine whether a packet is a retransmission

1. sender says: “7: let’s go see Taxi Driver”

c© 2005–2008 Antonio Carzaniga

Page 126: 20080426 networking carzaniga_lecture01-02

Dealing With Duplicate Packets

The sender adds a sequence number to each packet so that thereceiver can determine whether a packet is a retransmission

1. sender says: “7: let’s go see Taxi Driver”2. receiver hears: “7: let’s go see Taxi Driver”3. receiver passes “let’s go see Taxi Driver” to application layer4. receiver says: “Got it!” (i.e., ACK)

c© 2005–2008 Antonio Carzaniga

Page 127: 20080426 networking carzaniga_lecture01-02

Dealing With Duplicate Packets

The sender adds a sequence number to each packet so that thereceiver can determine whether a packet is a retransmission

1. sender says: “7: let’s go see Taxi Driver”2. receiver hears: “7: let’s go see Taxi Driver”3. receiver passes “let’s go see Taxi Driver” to application layer4. receiver says: “Got it!” (i.e., ACK)5. sender hears: “. . . noise . . . ”

c© 2005–2008 Antonio Carzaniga

Page 128: 20080426 networking carzaniga_lecture01-02

Dealing With Duplicate Packets

The sender adds a sequence number to each packet so that thereceiver can determine whether a packet is a retransmission

1. sender says: “7: let’s go see Taxi Driver”2. receiver hears: “7: let’s go see Taxi Driver”3. receiver passes “let’s go see Taxi Driver” to application layer4. receiver says: “Got it!” (i.e., ACK)5. sender hears: “. . . noise . . . ”6. sender (assuming a NACK) says: “7: let’s go see Taxi Driver”

c© 2005–2008 Antonio Carzaniga

Page 129: 20080426 networking carzaniga_lecture01-02

Dealing With Duplicate Packets

The sender adds a sequence number to each packet so that thereceiver can determine whether a packet is a retransmission

1. sender says: “7: let’s go see Taxi Driver”2. receiver hears: “7: let’s go see Taxi Driver”3. receiver passes “let’s go see Taxi Driver” to application layer4. receiver says: “Got it!” (i.e., ACK)5. sender hears: “. . . noise . . . ”6. sender (assuming a NACK) says: “7: let’s go see Taxi Driver”7. receiver hears: “7: let’s go see Taxi Driver”8. receiver ignores the packet

c© 2005–2008 Antonio Carzaniga

Page 130: 20080426 networking carzaniga_lecture01-02

Dealing With Duplicate Packets

The sender adds a sequence number to each packet so that thereceiver can determine whether a packet is a retransmission

1. sender says: “7: let’s go see Taxi Driver”2. receiver hears: “7: let’s go see Taxi Driver”3. receiver passes “let’s go see Taxi Driver” to application layer4. receiver says: “Got it!” (i.e., ACK)5. sender hears: “. . . noise . . . ”6. sender (assuming a NACK) says: “7: let’s go see Taxi Driver”7. receiver hears: “7: let’s go see Taxi Driver”8. receiver ignores the packet

How many bits do we need for the sequence number?

c© 2005–2008 Antonio Carzaniga

Page 131: 20080426 networking carzaniga_lecture01-02

Dealing With Duplicate Packets

The sender adds a sequence number to each packet so that thereceiver can determine whether a packet is a retransmission

1. sender says: “7: let’s go see Taxi Driver”2. receiver hears: “7: let’s go see Taxi Driver”3. receiver passes “let’s go see Taxi Driver” to application layer4. receiver says: “Got it!” (i.e., ACK)5. sender hears: “. . . noise . . . ”6. sender (assuming a NACK) says: “7: let’s go see Taxi Driver”7. receiver hears: “7: let’s go see Taxi Driver”8. receiver ignores the packet

How many bits do we need for the sequence number?

◮ this is a “stop-and-wait” protocol for each packet, so the receiverneeds to distinguish between (1) the next packet and (2) theretransmission of the current packet

c© 2005–2008 Antonio Carzaniga

Page 132: 20080426 networking carzaniga_lecture01-02

Dealing With Duplicate Packets

The sender adds a sequence number to each packet so that thereceiver can determine whether a packet is a retransmission

1. sender says: “7: let’s go see Taxi Driver”2. receiver hears: “7: let’s go see Taxi Driver”3. receiver passes “let’s go see Taxi Driver” to application layer4. receiver says: “Got it!” (i.e., ACK)5. sender hears: “. . . noise . . . ”6. sender (assuming a NACK) says: “7: let’s go see Taxi Driver”7. receiver hears: “7: let’s go see Taxi Driver”8. receiver ignores the packet

How many bits do we need for the sequence number?

◮ this is a “stop-and-wait” protocol for each packet, so the receiverneeds to distinguish between (1) the next packet and (2) theretransmission of the current packet

◮ so, one bit is sufficient

c© 2005–2008 Antonio Carzaniga

Page 133: 20080426 networking carzaniga_lecture01-02

Using Sequence Numbers: Sender

S0 ACK0

S1ACK1

r send(data)data pkt = [0, data]∗

u send(data pkt)u recv(pkt)and (pkt is NACKor pkt is corrupted)u send(data pkt)

u recv(pkt)and pkt is goodand pkt is ACK

r send(data)data pkt = [1, data]∗

u send(data pkt)

u recv(pkt)and (pkt is NACKor pkt is corrupted)u send(data pkt)

u recv(pkt)and pkt is goodand pkt is ACK

c© 2005–2008 Antonio Carzaniga

Page 134: 20080426 networking carzaniga_lecture01-02

Using Sequence Numbers: Receiver

R0

R1

u recv(pkt)and pkt is corruptedu send([NACK]∗)

u recv(pkt)and pkt is goodand seq num(pkt) is 1u send([ACK]∗)

u recv(pkt)and pkt is corruptedu send([NACK]∗)

u recv(pkt)and pkt is goodand seq num(pkt) is 0u send([ACK]∗)

u recv(pkt)and pkt is goodand seq num(pkt) is 0u send([ACK]∗)r recv(pkt)

u recv(pkt)and pkt is goodand seq num(pkt) is 1u send([ACK]∗)r recv(pkt)

c© 2005–2008 Antonio Carzaniga

Page 135: 20080426 networking carzaniga_lecture01-02

Better Use of ACKs

Do we really need both ACKs and NACKs?

c© 2005–2008 Antonio Carzaniga

Page 136: 20080426 networking carzaniga_lecture01-02

Better Use of ACKs

Do we really need both ACKs and NACKs?

Idea: now that we have sequence numbers, the receiver canconvey the semantics of a NACK by sending an ACK for the lastgood packet it received

c© 2005–2008 Antonio Carzaniga

Page 137: 20080426 networking carzaniga_lecture01-02

Better Use of ACKs

Do we really need both ACKs and NACKs?

Idea: now that we have sequence numbers, the receiver canconvey the semantics of a NACK by sending an ACK for the lastgood packet it received

1. sender says: “7: let’s go see Taxi Driver”2. receiver hears: “7: let’s go see Taxi Driver”3. receiver says: “Got it!”4. sender hears: “Got it!”5. sender says: “8: let’s meet at 8:00PM”6. receiver hears: “. . . noise . . . ”

c© 2005–2008 Antonio Carzaniga

Page 138: 20080426 networking carzaniga_lecture01-02

Better Use of ACKs

Do we really need both ACKs and NACKs?

Idea: now that we have sequence numbers, the receiver canconvey the semantics of a NACK by sending an ACK for the lastgood packet it received

1. sender says: “7: let’s go see Taxi Driver”2. receiver hears: “7: let’s go see Taxi Driver”3. receiver says: “Got it!”4. sender hears: “Got it!”5. sender says: “8: let’s meet at 8:00PM”6. receiver hears: “. . . noise . . . ”7. receiver now says: “Got 7” (instead of saying “Please, resend”)8. sender hears: “Got 7”

c© 2005–2008 Antonio Carzaniga

Page 139: 20080426 networking carzaniga_lecture01-02

Better Use of ACKs

Do we really need both ACKs and NACKs?

Idea: now that we have sequence numbers, the receiver canconvey the semantics of a NACK by sending an ACK for the lastgood packet it received

1. sender says: “7: let’s go see Taxi Driver”2. receiver hears: “7: let’s go see Taxi Driver”3. receiver says: “Got it!”4. sender hears: “Got it!”5. sender says: “8: let’s meet at 8:00PM”6. receiver hears: “. . . noise . . . ”7. receiver now says: “Got 7” (instead of saying “Please, resend”)8. sender hears: “Got 7”9. sender knows that the current message is 8, and therefore

repeats: “8: let’s meet at 8:00PM”

c© 2005–2008 Antonio Carzaniga

Page 140: 20080426 networking carzaniga_lecture01-02

ACK-Only Protocol: Sender

S0

c© 2005–2008 Antonio Carzaniga

Page 141: 20080426 networking carzaniga_lecture01-02

ACK-Only Protocol: Sender

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)

c© 2005–2008 Antonio Carzaniga

Page 142: 20080426 networking carzaniga_lecture01-02

ACK-Only Protocol: Sender

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)

S1

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

c© 2005–2008 Antonio Carzaniga

Page 143: 20080426 networking carzaniga_lecture01-02

ACK-Only Protocol: Sender

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)

S1

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

ACK1

r send(data)data pkt = [1, data]∗

u send(data pkt)

c© 2005–2008 Antonio Carzaniga

Page 144: 20080426 networking carzaniga_lecture01-02

ACK-Only Protocol: Sender

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)

S1

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

ACK1

r send(data)data pkt = [1, data]∗

u send(data pkt)

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

c© 2005–2008 Antonio Carzaniga

Page 145: 20080426 networking carzaniga_lecture01-02

ACK-Only Protocol: Sender

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)

S1

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

ACK1

r send(data)data pkt = [1, data]∗

u send(data pkt)

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

u recv(pkt)and (pkt = (ACK, 1)or pkt is corrupted)u send(data pkt)

c© 2005–2008 Antonio Carzaniga

Page 146: 20080426 networking carzaniga_lecture01-02

ACK-Only Protocol: Sender

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)

S1

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

ACK1

r send(data)data pkt = [1, data]∗

u send(data pkt)

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

u recv(pkt)and (pkt = (ACK, 1)or pkt is corrupted)u send(data pkt)

u recv(pkt)and (pkt = (ACK, 0)or pkt is corrupted)u send(data pkt)

c© 2005–2008 Antonio Carzaniga

Page 147: 20080426 networking carzaniga_lecture01-02

ACK-Only Protocol: Receiver

R0

c© 2005–2008 Antonio Carzaniga

Page 148: 20080426 networking carzaniga_lecture01-02

ACK-Only Protocol: Receiver

R0

R1

u recv(pkt)and pkt is goodand seq num(pkt) is 0u send([ACK,0]∗)r recv(pkt)

c© 2005–2008 Antonio Carzaniga

Page 149: 20080426 networking carzaniga_lecture01-02

ACK-Only Protocol: Receiver

R0

R1

u recv(pkt)and pkt is goodand seq num(pkt) is 0u send([ACK,0]∗)r recv(pkt)

u recv(pkt)and pkt is goodand seq num(pkt) is 1u send([ACK,1]∗)r recv(pkt)

c© 2005–2008 Antonio Carzaniga

Page 150: 20080426 networking carzaniga_lecture01-02

ACK-Only Protocol: Receiver

R0

R1

u recv(pkt)and pkt is goodand seq num(pkt) is 0u send([ACK,0]∗)r recv(pkt)

u recv(pkt)and pkt is goodand seq num(pkt) is 1u send([ACK,1]∗)r recv(pkt)

u recv(pkt)and pkt is corruptedu send([ACK,1]∗)

u recv(pkt)and pkt is corruptedu send([ACK,0]∗)

c© 2005–2008 Antonio Carzaniga

Page 151: 20080426 networking carzaniga_lecture01-02

ACK-Only Protocol: Receiver

R0

R1

u recv(pkt)and pkt is goodand seq num(pkt) is 0u send([ACK,0]∗)r recv(pkt)

u recv(pkt)and pkt is goodand seq num(pkt) is 1u send([ACK,1]∗)r recv(pkt)

u recv(pkt)and pkt is corruptedu send([ACK,1]∗)

u recv(pkt)and pkt is corruptedu send([ACK,0]∗)

u recv(pkt)and pkt is goodand seq num(pkt) is 0u send([ACK,0]∗)

u recv(pkt)and pkt is goodand seq num(pkt) is 1u send([ACK,1]∗)

c© 2005–2008 Antonio Carzaniga

Page 152: 20080426 networking carzaniga_lecture01-02

Summary of Principles and Techniques

c© 2005–2008 Antonio Carzaniga

Page 153: 20080426 networking carzaniga_lecture01-02

Summary of Principles and Techniques

Error detection codes (checksums) can be used to detecttransmission errors

c© 2005–2008 Antonio Carzaniga

Page 154: 20080426 networking carzaniga_lecture01-02

Summary of Principles and Techniques

Error detection codes (checksums) can be used to detecttransmission errors

Retransmission allows us to recover from transmission errors

c© 2005–2008 Antonio Carzaniga

Page 155: 20080426 networking carzaniga_lecture01-02

Summary of Principles and Techniques

Error detection codes (checksums) can be used to detecttransmission errors

Retransmission allows us to recover from transmission errors

ACKs and NACKs give feedback to the sender

◮ ACKs and NACKs are also “protected” with an error-detectioncode

c© 2005–2008 Antonio Carzaniga

Page 156: 20080426 networking carzaniga_lecture01-02

Summary of Principles and Techniques

Error detection codes (checksums) can be used to detecttransmission errors

Retransmission allows us to recover from transmission errors

ACKs and NACKs give feedback to the sender

◮ ACKs and NACKs are also “protected” with an error-detectioncode

◮ corrupted ACKs are interpreded as NACKs, possibly generatingduplicate segments

c© 2005–2008 Antonio Carzaniga

Page 157: 20080426 networking carzaniga_lecture01-02

Summary of Principles and Techniques

Error detection codes (checksums) can be used to detecttransmission errors

Retransmission allows us to recover from transmission errors

ACKs and NACKs give feedback to the sender

◮ ACKs and NACKs are also “protected” with an error-detectioncode

◮ corrupted ACKs are interpreded as NACKs, possibly generatingduplicate segments

Sequence numbers allow the receiver to ignore duplicate datasegments

c© 2005–2008 Antonio Carzaniga

Page 158: 20080426 networking carzaniga_lecture01-02

Lossy And Noisy Channel

c© 2005–2008 Antonio Carzaniga

Page 159: 20080426 networking carzaniga_lecture01-02

Lossy And Noisy Channel

Reliable transport protocol over a network that may◮ introduce bit errors

◮ loose packets

c© 2005–2008 Antonio Carzaniga

Page 160: 20080426 networking carzaniga_lecture01-02

Lossy And Noisy Channel

Reliable transport protocol over a network that may◮ introduce bit errors

◮ loose packets

How do people deal with such situations?(Think of radio transmissions over a noisy and shared medium.Also, think about what we just did for noisy channels)

c© 2005–2008 Antonio Carzaniga

Page 161: 20080426 networking carzaniga_lecture01-02

Lossy And Noisy Channel

Reliable transport protocol over a network that may◮ introduce bit errors

◮ loose packets

How do people deal with such situations?(Think of radio transmissions over a noisy and shared medium.Also, think about what we just did for noisy channels)

Detection: the receiver and/or the sender must be able todetermine that a packet was lost (how?)

c© 2005–2008 Antonio Carzaniga

Page 162: 20080426 networking carzaniga_lecture01-02

Lossy And Noisy Channel

Reliable transport protocol over a network that may◮ introduce bit errors

◮ loose packets

How do people deal with such situations?(Think of radio transmissions over a noisy and shared medium.Also, think about what we just did for noisy channels)

Detection: the receiver and/or the sender must be able todetermine that a packet was lost (how?)

ACKs, retransmission, and sequence numbers: lost packets canbe easily treated as corrupted packets

c© 2005–2008 Antonio Carzaniga

Page 163: 20080426 networking carzaniga_lecture01-02

Sender Using Timeouts

S0

c© 2005–2008 Antonio Carzaniga

Page 164: 20080426 networking carzaniga_lecture01-02

Sender Using Timeouts

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

c© 2005–2008 Antonio Carzaniga

Page 165: 20080426 networking carzaniga_lecture01-02

Sender Using Timeouts

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

c© 2005–2008 Antonio Carzaniga

Page 166: 20080426 networking carzaniga_lecture01-02

Sender Using Timeouts

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt = (ACK, 1)or pkt is corrupted)u send(data pkt)start timer()

c© 2005–2008 Antonio Carzaniga

Page 167: 20080426 networking carzaniga_lecture01-02

Sender Using Timeouts

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt = (ACK, 1)or pkt is corrupted)u send(data pkt)start timer()

S1

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

c© 2005–2008 Antonio Carzaniga

Page 168: 20080426 networking carzaniga_lecture01-02

Sender Using Timeouts

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt = (ACK, 1)or pkt is corrupted)u send(data pkt)start timer()

S1

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

ACK1

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

c© 2005–2008 Antonio Carzaniga

Page 169: 20080426 networking carzaniga_lecture01-02

Sender Using Timeouts

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt = (ACK, 1)or pkt is corrupted)u send(data pkt)start timer()

S1

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

ACK1

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

c© 2005–2008 Antonio Carzaniga

Page 170: 20080426 networking carzaniga_lecture01-02

Sender Using Timeouts

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt = (ACK, 1)or pkt is corrupted)u send(data pkt)start timer()

S1

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

ACK1

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt = (ACK, 0)or pkt is corrupted)u send(data pkt)start timer()

c© 2005–2008 Antonio Carzaniga

Page 171: 20080426 networking carzaniga_lecture01-02

Sender Using Timeouts

S0 ACK0

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt = (ACK, 1)or pkt is corrupted)u send(data pkt)start timer()

S1

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

ACK1

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt = (ACK, 0)or pkt is corrupted)u send(data pkt)start timer()

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

c© 2005–2008 Antonio Carzaniga

Page 172: 20080426 networking carzaniga_lecture01-02

Part II

Efficient and Reliable Streams

c© 2005–2008 Antonio Carzaniga

Page 173: 20080426 networking carzaniga_lecture01-02

Quantifying Data Transfer

How do we measure the “speed” and “capacity” of a networkconnection?

c© 2005–2008 Antonio Carzaniga

Page 174: 20080426 networking carzaniga_lecture01-02

Quantifying Data Transfer

How do we measure the “speed” and “capacity” of a networkconnection?

Intuition◮ water moves in a pipeline◮ cars move on a road

c© 2005–2008 Antonio Carzaniga

Page 175: 20080426 networking carzaniga_lecture01-02

Quantifying Data Transfer

How do we measure the “speed” and “capacity” of a networkconnection?

Intuition◮ water moves in a pipeline◮ cars move on a road

Latency

◮ the time it takes for one bit to go through the connection (from oneend to the other)

c© 2005–2008 Antonio Carzaniga

Page 176: 20080426 networking carzaniga_lecture01-02

Quantifying Data Transfer

How do we measure the “speed” and “capacity” of a networkconnection?

Intuition◮ water moves in a pipeline◮ cars move on a road

Latency

◮ the time it takes for one bit to go through the connection (from oneend to the other)

Throughput◮ the amount of information that can get into (or out of) the

connection in a time unit◮ at “steady-state” we assume zero accumulation of traffic, therefore

the input throughput is the same as the output throughput

c© 2005–2008 Antonio Carzaniga

Page 177: 20080426 networking carzaniga_lecture01-02

Latency and Throughput

connection

c© 2005–2008 Antonio Carzaniga

Page 178: 20080426 networking carzaniga_lecture01-02

Latency and Throughput

connectionmessage

100 · · · 110

c© 2005–2008 Antonio Carzaniga

Page 179: 20080426 networking carzaniga_lecture01-02

Latency and Throughput

connection

100 · · · 110

t0

c© 2005–2008 Antonio Carzaniga

Page 180: 20080426 networking carzaniga_lecture01-02

Latency and Throughput

connection

t0

100 · · · 110

t1

c© 2005–2008 Antonio Carzaniga

Page 181: 20080426 networking carzaniga_lecture01-02

Latency and Throughput

connection

t0 t1

100 · · · 110

t2

c© 2005–2008 Antonio Carzaniga

Page 182: 20080426 networking carzaniga_lecture01-02

Latency and Throughput

connection

t0 t1

100 · · · 110

t2

n bits︷ ︸︸ ︷

c© 2005–2008 Antonio Carzaniga

Page 183: 20080426 networking carzaniga_lecture01-02

Latency and Throughput

connection

t0 t1

100 · · · 110

t2

n bits︷ ︸︸ ︷

Latency L = t1 − t0 sec

c© 2005–2008 Antonio Carzaniga

Page 184: 20080426 networking carzaniga_lecture01-02

Latency and Throughput

connection

t0 t1

100 · · · 110

t2

n bits︷ ︸︸ ︷

Latency L = t1 − t0 sec

Throughput T =n

t2 − t1bits/sec

c© 2005–2008 Antonio Carzaniga

Page 185: 20080426 networking carzaniga_lecture01-02

Latency and Throughput

connection

t0 t1

100 · · · 110

t2

n bits︷ ︸︸ ︷

Latency L = t1 − t0 sec

Throughput T =n

t2 − t1bits/sec

Transfer time ∆ = L +nT

sec

c© 2005–2008 Antonio Carzaniga

Page 186: 20080426 networking carzaniga_lecture01-02

Examples

How long does it take to tranfer a file between, say, Lugano andSt. Petersburg?

c© 2005–2008 Antonio Carzaniga

Page 187: 20080426 networking carzaniga_lecture01-02

Examples

How long does it take to tranfer a file between, say, Lugano andSt. Petersburg?

How big is this file? And how fast is our connection?

c© 2005–2008 Antonio Carzaniga

Page 188: 20080426 networking carzaniga_lecture01-02

Examples

How long does it take to tranfer a file between, say, Lugano andSt. Petersburg?

How big is this file? And how fast is our connection?

E.g., a (short) e-mail message

S = 4KbL = 500msT = 1Mb/s∆ = ?

c© 2005–2008 Antonio Carzaniga

Page 189: 20080426 networking carzaniga_lecture01-02

Examples

How long does it take to tranfer a file between, say, Lugano andSt. Petersburg?

How big is this file? And how fast is our connection?

E.g., a (short) e-mail message

S = 4KbL = 500msT = 1Mb/s∆ = 500ms + 4ms = 504ms

c© 2005–2008 Antonio Carzaniga

Page 190: 20080426 networking carzaniga_lecture01-02

Examples

How about a big file? (E.g., a CD)

c© 2005–2008 Antonio Carzaniga

Page 191: 20080426 networking carzaniga_lecture01-02

Examples

How about a big file? (E.g., a CD)

S = 400MbL = 500msT = 1Mb/s∆ = ?

c© 2005–2008 Antonio Carzaniga

Page 192: 20080426 networking carzaniga_lecture01-02

Examples

How about a big file? (E.g., a CD)

S = 400MbL = 500msT = 1Mb/s∆ = 500ms + 400s = 400.5s = 6′40′′

c© 2005–2008 Antonio Carzaniga

Page 193: 20080426 networking carzaniga_lecture01-02

Examples

How about a big file? (E.g., a CD)

S = 400MbL = 500msT = 1Mb/s∆ = 500ms + 400s = 400.5s = 6′40′′

How about a bigger file? (E.g., 10 DVDs)

c© 2005–2008 Antonio Carzaniga

Page 194: 20080426 networking carzaniga_lecture01-02

Examples

How about a big file? (E.g., a CD)

S = 400MbL = 500msT = 1Mb/s∆ = 500ms + 400s = 400.5s = 6′40′′

How about a bigger file? (E.g., 10 DVDs)

S = 40GbL = 500msT = 1Mb/s∆ = ?

c© 2005–2008 Antonio Carzaniga

Page 195: 20080426 networking carzaniga_lecture01-02

Examples

How about a big file? (E.g., a CD)

S = 400MbL = 500msT = 1Mb/s∆ = 500ms + 400s = 400.5s = 6′40′′

How about a bigger file? (E.g., 10 DVDs)

S = 40GbL = 500msT = 1Mb/s∆ = ǫ + 40000s = 11h 6′40′′

c© 2005–2008 Antonio Carzaniga

Page 196: 20080426 networking carzaniga_lecture01-02

Examples

How about flying to St. Petersburgh?

c© 2005–2008 Antonio Carzaniga

Page 197: 20080426 networking carzaniga_lecture01-02

Examples

How about flying to St. Petersburgh?

◮ assuming you can carry more or less 100 DVDs in your backpack◮ assuming it takes you four seconds to take the DVDs out of your

backpack

c© 2005–2008 Antonio Carzaniga

Page 198: 20080426 networking carzaniga_lecture01-02

Examples

How about flying to St. Petersburgh?

◮ assuming you can carry more or less 100 DVDs in your backpack◮ assuming it takes you four seconds to take the DVDs out of your

backpack

S = 40GbL = ?T =∆ =

c© 2005–2008 Antonio Carzaniga

Page 199: 20080426 networking carzaniga_lecture01-02

Examples

How about flying to St. Petersburgh?

◮ assuming you can carry more or less 100 DVDs in your backpack◮ assuming it takes you four seconds to take the DVDs out of your

backpack

S = 40GbL = 6hT = ?∆ =

c© 2005–2008 Antonio Carzaniga

Page 200: 20080426 networking carzaniga_lecture01-02

Examples

How about flying to St. Petersburgh?

◮ assuming you can carry more or less 100 DVDs in your backpack◮ assuming it takes you four seconds to take the DVDs out of your

backpack

S = 40GbL = 6hT = 100Gb/s∆ = ?

c© 2005–2008 Antonio Carzaniga

Page 201: 20080426 networking carzaniga_lecture01-02

Examples

How about flying to St. Petersburgh?

◮ assuming you can carry more or less 100 DVDs in your backpack◮ assuming it takes you four seconds to take the DVDs out of your

backpack

S = 40GbL = 6hT = 100Gb/s∆ = 6h

c© 2005–2008 Antonio Carzaniga

Page 202: 20080426 networking carzaniga_lecture01-02

Examples

How about flying to St. Petersburgh?

◮ assuming you can carry more or less 100 DVDs in your backpack◮ assuming it takes you four seconds to take the DVDs out of your

backpack

S = 40GbL = 6hT = 100Gb/s∆ = 6h

If you need to transfer 10 DVDs from Lugano to St.Petersburg and time is of the essence (and you have plentyof money). . . then you’re better off talking a plane rather thanusing the Internet

c© 2005–2008 Antonio Carzaniga

Page 203: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Tranfer

c© 2005–2008 Antonio Carzaniga

Page 204: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Tranfer

S0 ACK0

S1ACK1

u recv(pkt)

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 1))

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

u recv(pkt)

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 0))

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

c© 2005–2008 Antonio Carzaniga

Page 205: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Tranfer

S0 ACK0

S1ACK1

u recv(pkt)

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 1))

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

u recv(pkt)

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 0))

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

c© 2005–2008 Antonio Carzaniga

Page 206: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Tranfer

S0 ACK0

S1ACK1

u recv(pkt)

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 1))

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

u recv(pkt)

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 0))

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

c© 2005–2008 Antonio Carzaniga

Page 207: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Tranfer

S0 ACK0

S1ACK1

u recv(pkt)

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 1))

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

u recv(pkt)

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 0))

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

c© 2005–2008 Antonio Carzaniga

Page 208: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Tranfer

S0 ACK0

S1ACK1

u recv(pkt)

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 1))

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

u recv(pkt)

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 0))

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

c© 2005–2008 Antonio Carzaniga

Page 209: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Tranfer

S0 ACK0

S1ACK1

u recv(pkt)

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 1))

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

u recv(pkt)

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 0))

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

c© 2005–2008 Antonio Carzaniga

Page 210: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Tranfer

S0 ACK0

S1ACK1

u recv(pkt)

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 1))

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

u recv(pkt)

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 0))

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

c© 2005–2008 Antonio Carzaniga

Page 211: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Tranfer

S0 ACK0

S1ACK1

u recv(pkt)

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 1))

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

u recv(pkt)

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 0))

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

c© 2005–2008 Antonio Carzaniga

Page 212: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Tranfer

S0 ACK0

S1ACK1

u recv(pkt)

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 1))

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

u recv(pkt)

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 0))

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

c© 2005–2008 Antonio Carzaniga

Page 213: 20080426 networking carzaniga_lecture01-02

Back to Reliable Data Tranfer

S0 ACK0

S1ACK1

u recv(pkt)

r send(data)data pkt = [0, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 1))

u recv(pkt)and pkt is goodand pkt = (ACK, 0)

u recv(pkt)

r send(data)data pkt = [1, data]∗

u send(data pkt)start timer()

timeoutu send(data pkt)start timer()

u recv(pkt)and (pkt is corruptedor pkt = (ACK, 0))

u recv(pkt)and pkt is goodand pkt = (ACK, 1)

c© 2005–2008 Antonio Carzaniga

Page 214: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiverr send(pkt1)

c© 2005–2008 Antonio Carzaniga

Page 215: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiverr send(pkt1)

u send([pkt1,0])

c© 2005–2008 Antonio Carzaniga

Page 216: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiverr send(pkt1)

u send([pkt1,0]) [pkt1 ,0]

c© 2005–2008 Antonio Carzaniga

Page 217: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiverr send(pkt1)

u send([pkt1,0]) [pkt1 ,0]

u send([ACK,0])

r recv(pkt1)

c© 2005–2008 Antonio Carzaniga

Page 218: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiverr send(pkt1)

u send([pkt1,0]) [pkt1 ,0]

u send([ACK,0])

r recv(pkt1)[ACK,0]

c© 2005–2008 Antonio Carzaniga

Page 219: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiverr send(pkt1)

u send([pkt1,0]) [pkt1 ,0]

u send([ACK,0])

r recv(pkt1)[ACK,0]r send(pkt2)

c© 2005–2008 Antonio Carzaniga

Page 220: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiverr send(pkt1)

u send([pkt1,0]) [pkt1 ,0]

u send([ACK,0])

r recv(pkt1)[ACK,0]r send(pkt2)

u send([pkt2,1])

c© 2005–2008 Antonio Carzaniga

Page 221: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiverr send(pkt1)

u send([pkt1,0]) [pkt1 ,0]

u send([ACK,0])

r recv(pkt1)[ACK,0]r send(pkt2)

u send([pkt2,1]) [pkt2 ,1]

c© 2005–2008 Antonio Carzaniga

Page 222: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiverr send(pkt1)

u send([pkt1,0]) [pkt1 ,0]

u send([ACK,0])

r recv(pkt1)[ACK,0]r send(pkt2)

u send([pkt2,1]) [pkt2 ,1]

u send([ACK,1])

r recv(pkt2)

c© 2005–2008 Antonio Carzaniga

Page 223: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiverr send(pkt1)

u send([pkt1,0]) [pkt1 ,0]

u send([ACK,0])

r recv(pkt1)[ACK,0]r send(pkt2)

u send([pkt2,1]) [pkt2 ,1]

u send([ACK,1])

r recv(pkt2)[ACK,1]

c© 2005–2008 Antonio Carzaniga

Page 224: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiver

[pkt1 ,0]

[ACK,0]

[pkt2 ,1]

[ACK,1]

c© 2005–2008 Antonio Carzaniga

Page 225: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiver

[pkt1 ,0]

[ACK,0]

[pkt2 ,1]

[ACK,1]

c© 2005–2008 Antonio Carzaniga

Page 226: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiver

[pkt1 ,0]

[ACK,0]

[pkt2 ,1]

[ACK,1]

L

c© 2005–2008 Antonio Carzaniga

Page 227: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiver

[pkt1 ,0]

[ACK,0]

[pkt2 ,1]

[ACK,1]

L

Spkt1 /T

c© 2005–2008 Antonio Carzaniga

Page 228: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiver

[pkt1 ,0]

[ACK,0]

[pkt2 ,1]

[ACK,1]

L

Spkt1 /T

L

c© 2005–2008 Antonio Carzaniga

Page 229: 20080426 networking carzaniga_lecture01-02

Network Usage

sender receiver

[pkt1 ,0]

[ACK,0]

[pkt2 ,1]

[ACK,1]

L

Spkt1 /T

L

utilizationfactor

U =Spkt/T

2L+Spkt/T

c© 2005–2008 Antonio Carzaniga

Page 230: 20080426 networking carzaniga_lecture01-02

Improving Network Usage

How do we achieve a better utilization factor?

c© 2005–2008 Antonio Carzaniga

Page 231: 20080426 networking carzaniga_lecture01-02

Improving Network Usage

How do we achieve a better utilization factor?

sender receiver

[pkt1 ,0]

[ACK,0]

c© 2005–2008 Antonio Carzaniga

Page 232: 20080426 networking carzaniga_lecture01-02

Improving Network Usage

How do we achieve a better utilization factor?

sender receiver

[pkt1 ,0]

[ACK,0]

[ACK,1]

[pkt2 ,1]

c© 2005–2008 Antonio Carzaniga

Page 233: 20080426 networking carzaniga_lecture01-02

Improving Network Usage

How do we achieve a better utilization factor?

sender receiver

[pkt1 ,0]

[ACK,0]

[ACK,1]

[pkt2 ,1]

· · ·

· · ·

c© 2005–2008 Antonio Carzaniga

Page 234: 20080426 networking carzaniga_lecture01-02

Improving Network Usage

How do we achieve a better utilization factor?

sender receiver

[pkt1 ,0]

[ACK,0]

[ACK,1]

[pkt2 ,1]

· · ·

· · ·

[ACK,w − 1]

[pktw ,w − 1]

c© 2005–2008 Antonio Carzaniga

Page 235: 20080426 networking carzaniga_lecture01-02

Go-Back-N

Idea: the sender transmits multiple packets without waiting for anacknowledgement

c© 2005–2008 Antonio Carzaniga

Page 236: 20080426 networking carzaniga_lecture01-02

Go-Back-N

Idea: the sender transmits multiple packets without waiting for anacknowledgement

The sender has up to W unacknowledged packets in the pipeline◮ the sender’s state machine gets very complex◮ we represent the sender’s state with its queue of

acknowledgements

c© 2005–2008 Antonio Carzaniga

Page 237: 20080426 networking carzaniga_lecture01-02

Go-Back-N

Idea: the sender transmits multiple packets without waiting for anacknowledgement

The sender has up to W unacknowledged packets in the pipeline◮ the sender’s state machine gets very complex◮ we represent the sender’s state with its queue of

acknowledgements

c© 2005–2008 Antonio Carzaniga

Page 238: 20080426 networking carzaniga_lecture01-02

Go-Back-N

Idea: the sender transmits multiple packets without waiting for anacknowledgement

The sender has up to W unacknowledged packets in the pipeline◮ the sender’s state machine gets very complex◮ we represent the sender’s state with its queue of

acknowledgements

acknowledged pending available unavailable

c© 2005–2008 Antonio Carzaniga

Page 239: 20080426 networking carzaniga_lecture01-02

Go-Back-N

Idea: the sender transmits multiple packets without waiting for anacknowledgement

The sender has up to W unacknowledged packets in the pipeline◮ the sender’s state machine gets very complex◮ we represent the sender’s state with its queue of

acknowledgements

acknowledged pending available unavailable

first pendingacknowledgement

(base)

c© 2005–2008 Antonio Carzaniga

Page 240: 20080426 networking carzaniga_lecture01-02

Go-Back-N

Idea: the sender transmits multiple packets without waiting for anacknowledgement

The sender has up to W unacknowledged packets in the pipeline◮ the sender’s state machine gets very complex◮ we represent the sender’s state with its queue of

acknowledgements

acknowledged pending available unavailable

first pendingacknowledgement

(base)

next availablesequence number

(next seq num)

c© 2005–2008 Antonio Carzaniga

Page 241: 20080426 networking carzaniga_lecture01-02

Go-Back-N

Idea: the sender transmits multiple packets without waiting for anacknowledgement

The sender has up to W unacknowledged packets in the pipeline◮ the sender’s state machine gets very complex◮ we represent the sender’s state with its queue of

acknowledgements

acknowledged pending available unavailable

first pendingacknowledgement

(base)

next availablesequence number

(next seq num)

window size (W )c© 2005–2008 Antonio Carzaniga

Page 242: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

base

sliding window

next seq num

c© 2005–2008 Antonio Carzaniga

Page 243: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

base

sliding window

next seq num

r send(pkt1)

c© 2005–2008 Antonio Carzaniga

Page 244: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

base

sliding window

next seq num

r send(pkt1)◮ u send([pkt1,next seq num])

c© 2005–2008 Antonio Carzaniga

Page 245: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

base

sliding window

next seq num

r send(pkt1)◮ u send([pkt1,next seq num])◮ next seq num ← next seq num + 1

c© 2005–2008 Antonio Carzaniga

Page 246: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

base

sliding window

next seq num

A

r send(pkt1)◮ u send([pkt1,next seq num])◮ next seq num ← next seq num + 1

u recv([ACK,A])

c© 2005–2008 Antonio Carzaniga

Page 247: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

base

sliding window

next seq num

A

r send(pkt1)◮ u send([pkt1,next seq num])◮ next seq num ← next seq num + 1

u recv([ACK,A])◮ base← A + 1

c© 2005–2008 Antonio Carzaniga

Page 248: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

base

sliding window

next seq num

A

r send(pkt1)◮ u send([pkt1,next seq num])◮ next seq num ← next seq num + 1

u recv([ACK,A])◮ base← A + 1◮ notice that acknewledgements are “cumulative”

c© 2005–2008 Antonio Carzaniga

Page 249: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

c© 2005–2008 Antonio Carzaniga

Page 250: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

The sender remembers the first sequence number that has notyet been acknowledged

◮ or the highest acknowledged sequence number

The sender remembers the first available sequence number

◮ or the highest used sequence number (i.e., sent to the receiver)

The sender responds to three types of events

c© 2005–2008 Antonio Carzaniga

Page 251: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

The sender remembers the first sequence number that has notyet been acknowledged

◮ or the highest acknowledged sequence number

The sender remembers the first available sequence number

◮ or the highest used sequence number (i.e., sent to the receiver)

The sender responds to three types of events◮ r send(): invocation from the application layer: send more data if a

sequence number is available

c© 2005–2008 Antonio Carzaniga

Page 252: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

The sender remembers the first sequence number that has notyet been acknowledged

◮ or the highest acknowledged sequence number

The sender remembers the first available sequence number

◮ or the highest used sequence number (i.e., sent to the receiver)

The sender responds to three types of events◮ r send(): invocation from the application layer: send more data if a

sequence number is available◮ ACK: receipt of an acknowledgement: shift the window (it’s a

“cumulative” ACK)

c© 2005–2008 Antonio Carzaniga

Page 253: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

The sender remembers the first sequence number that has notyet been acknowledged

◮ or the highest acknowledged sequence number

The sender remembers the first available sequence number

◮ or the highest used sequence number (i.e., sent to the receiver)

The sender responds to three types of events◮ r send(): invocation from the application layer: send more data if a

sequence number is available◮ ACK: receipt of an acknowledgement: shift the window (it’s a

“cumulative” ACK)◮ timeout: “Go-Back-N.” I.e., resend all the packets that have been

sent but not acknowledged

c© 2005–2008 Antonio Carzaniga

Page 254: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

initbase← 1next seq num← 1

c© 2005–2008 Antonio Carzaniga

Page 255: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

initbase← 1next seq num← 1

r send(data)if (next seq num < base + W ) {

pkt[next seq num]← [next seq num, data]∗

u send(pkt[next seq num])if (next seq num = base) {

start timer()}next seq num← next seq num + 1

} else {refuse data(data) // block the sender

}

c© 2005–2008 Antonio Carzaniga

Page 256: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

u recv(pkt) and pkt is corrupted

c© 2005–2008 Antonio Carzaniga

Page 257: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

u recv(pkt) and pkt is corrupted

u recv(ACK,ack num)base← ack num + 1 // resume the senderif (next seq num = base) {

stop timer()} else {

start timer()}

c© 2005–2008 Antonio Carzaniga

Page 258: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Sender

u recv(pkt) and pkt is corrupted

u recv(ACK,ack num)base← ack num + 1 // resume the senderif (next seq num = base) {

stop timer()} else {

start timer()}

timeoutstart timer()foreach i in base . . . next seq num− 1 {

u send(pkt[i])}

c© 2005–2008 Antonio Carzaniga

Page 259: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Receiver

c© 2005–2008 Antonio Carzaniga

Page 260: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Receiver

Simple: as in the stop-and-wait case, the receiver maintains acounter representing the expected sequence number

c© 2005–2008 Antonio Carzaniga

Page 261: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Receiver

Simple: as in the stop-and-wait case, the receiver maintains acounter representing the expected sequence number

The receiver waits for a (good) data packet with the expectedsequence number

c© 2005–2008 Antonio Carzaniga

Page 262: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Receiver

Simple: as in the stop-and-wait case, the receiver maintains acounter representing the expected sequence number

The receiver waits for a (good) data packet with the expectedsequence number

◮ acknowledges the expected sequence number

c© 2005–2008 Antonio Carzaniga

Page 263: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Receiver

Simple: as in the stop-and-wait case, the receiver maintains acounter representing the expected sequence number

The receiver waits for a (good) data packet with the expectedsequence number

◮ acknowledges the expected sequence number◮ delivers the data to the application

c© 2005–2008 Antonio Carzaniga

Page 264: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Receiver

initexpected seq num← 1ackpkt ← [ACK , 0]∗

c© 2005–2008 Antonio Carzaniga

Page 265: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Receiver

initexpected seq num← 1ackpkt ← [ACK , 0]∗

u recv([data, seq num]) and goodand seq num = expected seq numr recv(data)ackpkt ← [ACK , expected seq num]∗

expected seq num← expected seq num + 1u send(ackpkt)

c© 2005–2008 Antonio Carzaniga

Page 266: 20080426 networking carzaniga_lecture01-02

Sliding Window Protocol: Receiver

initexpected seq num← 1ackpkt ← [ACK , 0]∗

u recv([data, seq num]) and goodand seq num = expected seq numr recv(data)ackpkt ← [ACK , expected seq num]∗

expected seq num← expected seq num + 1u send(ackpkt)

u recv([data, seq num])and (corrupted or seq num 6= expected seq num)u send(ackpkt)

c© 2005–2008 Antonio Carzaniga

Page 267: 20080426 networking carzaniga_lecture01-02

Comments

Concepts

c© 2005–2008 Antonio Carzaniga

Page 268: 20080426 networking carzaniga_lecture01-02

Comments

Concepts

◮ sequence numbers

c© 2005–2008 Antonio Carzaniga

Page 269: 20080426 networking carzaniga_lecture01-02

Comments

Concepts

◮ sequence numbers◮ sliding window

c© 2005–2008 Antonio Carzaniga

Page 270: 20080426 networking carzaniga_lecture01-02

Comments

Concepts

◮ sequence numbers◮ sliding window◮ cumulative acknowledgements

c© 2005–2008 Antonio Carzaniga

Page 271: 20080426 networking carzaniga_lecture01-02

Comments

Concepts

◮ sequence numbers◮ sliding window◮ cumulative acknowledgements◮ checksums, timeouts, and sender-initiated retransmission

c© 2005–2008 Antonio Carzaniga

Page 272: 20080426 networking carzaniga_lecture01-02

Comments

Concepts

◮ sequence numbers◮ sliding window◮ cumulative acknowledgements◮ checksums, timeouts, and sender-initiated retransmission

Advantages: simple

c© 2005–2008 Antonio Carzaniga

Page 273: 20080426 networking carzaniga_lecture01-02

Comments

Concepts

◮ sequence numbers◮ sliding window◮ cumulative acknowledgements◮ checksums, timeouts, and sender-initiated retransmission

Advantages: simple

◮ the sender maintains two counters and a one timer◮ the receiver maintains one counter

c© 2005–2008 Antonio Carzaniga

Page 274: 20080426 networking carzaniga_lecture01-02

Comments

Concepts

◮ sequence numbers◮ sliding window◮ cumulative acknowledgements◮ checksums, timeouts, and sender-initiated retransmission

Advantages: simple

◮ the sender maintains two counters and a one timer◮ the receiver maintains one counter

Disadvantages: not optimal, not adaptive

c© 2005–2008 Antonio Carzaniga

Page 275: 20080426 networking carzaniga_lecture01-02

Comments

Concepts

◮ sequence numbers◮ sliding window◮ cumulative acknowledgements◮ checksums, timeouts, and sender-initiated retransmission

Advantages: simple

◮ the sender maintains two counters and a one timer◮ the receiver maintains one counter

Disadvantages: not optimal, not adaptive◮ the sender can fill the window without filling the pipeline

c© 2005–2008 Antonio Carzaniga

Page 276: 20080426 networking carzaniga_lecture01-02

Comments

Concepts

◮ sequence numbers◮ sliding window◮ cumulative acknowledgements◮ checksums, timeouts, and sender-initiated retransmission

Advantages: simple

◮ the sender maintains two counters and a one timer◮ the receiver maintains one counter

Disadvantages: not optimal, not adaptive◮ the sender can fill the window without filling the pipeline◮ the receiver may buffer out-of-order packets. . .

c© 2005–2008 Antonio Carzaniga

Page 277: 20080426 networking carzaniga_lecture01-02

Performance Analysis

What is a good value for W?

c© 2005–2008 Antonio Carzaniga

Page 278: 20080426 networking carzaniga_lecture01-02

Performance Analysis

What is a good value for W?

◮ W that achieves the maximum utilization of the connection

c© 2005–2008 Antonio Carzaniga

Page 279: 20080426 networking carzaniga_lecture01-02

Performance Analysis

What is a good value for W?

◮ W that achieves the maximum utilization of the connection

S = streamL = 500msT = 1Mb/s

W = ?

c© 2005–2008 Antonio Carzaniga

Page 280: 20080426 networking carzaniga_lecture01-02

Performance Analysis

What is a good value for W?

◮ W that achieves the maximum utilization of the connection

S = streamL = 500msT = 1Mb/s

W = ?

The problem may seem a bit underspecified. What is the(average) packet size?

Spkr = 1KbL = 500msT = 1Mb/s

W = 2L×TSpkt

= 1000

c© 2005–2008 Antonio Carzaniga

Page 281: 20080426 networking carzaniga_lecture01-02

Performance Analysis

The RTT–throughput product (2L× T ) is the crucial factor

c© 2005–2008 Antonio Carzaniga

Page 282: 20080426 networking carzaniga_lecture01-02

Performance Analysis

The RTT–throughput product (2L× T ) is the crucial factor

◮ W × Spkt ≤ 2L× T

◮ why W × Spkt > 2L× T doesn’t make much sense?

c© 2005–2008 Antonio Carzaniga

Page 283: 20080426 networking carzaniga_lecture01-02

Performance Analysis

The RTT–throughput product (2L× T ) is the crucial factor

◮ W × Spkt ≤ 2L× T

◮ why W × Spkt > 2L× T doesn’t make much sense?

◮ maximum channel utilization when W × Spkt = 2L× T

◮ 2L× T can be thought of as the capacity of a connection

c© 2005–2008 Antonio Carzaniga

Page 284: 20080426 networking carzaniga_lecture01-02

Problems with Go-Back-N

Let’s consider a fully utilized connection

c© 2005–2008 Antonio Carzaniga

Page 285: 20080426 networking carzaniga_lecture01-02

Problems with Go-Back-N

Let’s consider a fully utilized connection

Spkr = 1KbL = 500msT = 1Mb/s

W = T×LSpkt

= 1000

c© 2005–2008 Antonio Carzaniga

Page 286: 20080426 networking carzaniga_lecture01-02

Problems with Go-Back-N

Let’s consider a fully utilized connection

Spkr = 1KbL = 500msT = 1Mb/s

W = T×LSpkt

= 1000

What happens if the first packet (or acknowledgement) is lost?

c© 2005–2008 Antonio Carzaniga

Page 287: 20080426 networking carzaniga_lecture01-02

Problems with Go-Back-N

Let’s consider a fully utilized connection

Spkr = 1KbL = 500msT = 1Mb/s

W = T×LSpkt

= 1000

What happens if the first packet (or acknowledgement) is lost?

Sender retransmits the entire content of its buffers

c© 2005–2008 Antonio Carzaniga

Page 288: 20080426 networking carzaniga_lecture01-02

Problems with Go-Back-N

Let’s consider a fully utilized connection

Spkr = 1KbL = 500msT = 1Mb/s

W = T×LSpkt

= 1000

What happens if the first packet (or acknowledgement) is lost?

Sender retransmits the entire content of its buffers

◮ W × Spkt = 2L× T = 1Mb◮ retransmitting 1Mb to recover 1Kb worth of data isn’t exactly the

best solution. Not to mention conjestions. . .

c© 2005–2008 Antonio Carzaniga

Page 289: 20080426 networking carzaniga_lecture01-02

Problems with Go-Back-N

Let’s consider a fully utilized connection

Spkr = 1KbL = 500msT = 1Mb/s

W = T×LSpkt

= 1000

What happens if the first packet (or acknowledgement) is lost?

Sender retransmits the entire content of its buffers

◮ W × Spkt = 2L× T = 1Mb◮ retransmitting 1Mb to recover 1Kb worth of data isn’t exactly the

best solution. Not to mention conjestions. . .

Is there a better way to deal with retransmissions?

c© 2005–2008 Antonio Carzaniga

Page 290: 20080426 networking carzaniga_lecture01-02

Selective Repeat

Idea: have the sender retransmit only those packets that itsuspects were lost or corrupted

c© 2005–2008 Antonio Carzaniga

Page 291: 20080426 networking carzaniga_lecture01-02

Selective Repeat

Idea: have the sender retransmit only those packets that itsuspects were lost or corrupted

◮ sender maintains a vector of acknowledgement flags

c© 2005–2008 Antonio Carzaniga

Page 292: 20080426 networking carzaniga_lecture01-02

Selective Repeat

Idea: have the sender retransmit only those packets that itsuspects were lost or corrupted

◮ sender maintains a vector of acknowledgement flags

◮ receiver maintains a vector of acknowledged falgs

c© 2005–2008 Antonio Carzaniga

Page 293: 20080426 networking carzaniga_lecture01-02

Selective Repeat

Idea: have the sender retransmit only those packets that itsuspects were lost or corrupted

◮ sender maintains a vector of acknowledgement flags

◮ receiver maintains a vector of acknowledged falgs

◮ in fact, receiver maintains a buffer of out-of-order packets

c© 2005–2008 Antonio Carzaniga

Page 294: 20080426 networking carzaniga_lecture01-02

Selective Repeat

Idea: have the sender retransmit only those packets that itsuspects were lost or corrupted

◮ sender maintains a vector of acknowledgement flags

◮ receiver maintains a vector of acknowledged falgs

◮ in fact, receiver maintains a buffer of out-of-order packets

◮ sender maintains a timer for each pending packet

c© 2005–2008 Antonio Carzaniga

Page 295: 20080426 networking carzaniga_lecture01-02

Selective Repeat

Idea: have the sender retransmit only those packets that itsuspects were lost or corrupted

◮ sender maintains a vector of acknowledgement flags

◮ receiver maintains a vector of acknowledged falgs

◮ in fact, receiver maintains a buffer of out-of-order packets

◮ sender maintains a timer for each pending packet

◮ sender resends a packet when its timer expires

c© 2005–2008 Antonio Carzaniga

Page 296: 20080426 networking carzaniga_lecture01-02

Selective Repeat

Idea: have the sender retransmit only those packets that itsuspects were lost or corrupted

◮ sender maintains a vector of acknowledgement flags

◮ receiver maintains a vector of acknowledged falgs

◮ in fact, receiver maintains a buffer of out-of-order packets

◮ sender maintains a timer for each pending packet

◮ sender resends a packet when its timer expires

◮ sender slides the window when the lowest pending sequencenumber is acknowledged

c© 2005–2008 Antonio Carzaniga

Page 297: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

c© 2005–2008 Antonio Carzaniga

Page 298: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

r send(pkt1)

c© 2005–2008 Antonio Carzaniga

Page 299: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

r send(pkt1)◮ u send([pkt1,next seq num])◮ start timer(next seq num)

c© 2005–2008 Antonio Carzaniga

Page 300: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

r send(pkt1)◮ u send([pkt1,next seq num])◮ start timer(next seq num)◮ next seq num ← next seq num + 1

c© 2005–2008 Antonio Carzaniga

Page 301: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

A

r send(pkt1)◮ u send([pkt1,next seq num])◮ start timer(next seq num)◮ next seq num ← next seq num + 1

u recv([ACK,A])

c© 2005–2008 Antonio Carzaniga

Page 302: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

A

r send(pkt1)◮ u send([pkt1,next seq num])◮ start timer(next seq num)◮ next seq num ← next seq num + 1

u recv([ACK,A])

◮ acks[A]← 1 // remember that A was ACK’d

c© 2005–2008 Antonio Carzaniga

Page 303: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

A

r send(pkt1)◮ u send([pkt1,next seq num])◮ start timer(next seq num)◮ next seq num ← next seq num + 1

u recv([ACK,A])

◮ acks[A]← 1 // remember that A was ACK’d◮ acknewledgements are no longer “cumulative”

c© 2005–2008 Antonio Carzaniga

Page 304: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Receiver

c© 2005–2008 Antonio Carzaniga

Page 305: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Receiver

received acceptable not usable

rcv base

sliding window

c© 2005–2008 Antonio Carzaniga

Page 306: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Receiver

received acceptable not usable

rcv base

sliding window

X1

u recv([pkt1,X1]) and rcv base ≤ X1 < rcv base + W

c© 2005–2008 Antonio Carzaniga

Page 307: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Receiver

received acceptable not usable

rcv base

sliding window

X1

u recv([pkt1,X1]) and rcv base ≤ X1 < rcv base + W◮ buffer [X1]← pkt1◮ u send([ACK ,X1]∗) // no longer a “cumulative” ACK

c© 2005–2008 Antonio Carzaniga

Page 308: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Receiver

received acceptable not usable

rcv base

sliding window

c© 2005–2008 Antonio Carzaniga

Page 309: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Receiver

received acceptable not usable

rcv base

sliding window

X2

u recv([pkt2,X2]) and rcv base ≤ X2 < rcv base + W◮ buffer [X2]← pkt2◮ u send([ACK ,X2]∗)

c© 2005–2008 Antonio Carzaniga

Page 310: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Receiver

received acceptable not usable

rcv base

sliding window

X2

u recv([pkt2,X2]) and rcv base ≤ X2 < rcv base + W◮ buffer [X2]← pkt2◮ u send([ACK ,X2]∗)◮ if (X2 = rcv base) {

c© 2005–2008 Antonio Carzaniga

Page 311: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Receiver

received acceptable not usable

rcv base

sliding window

X2 B

u recv([pkt2,X2]) and rcv base ≤ X2 < rcv base + W◮ buffer [X2]← pkt2◮ u send([ACK ,X2]∗)◮ if (X2 = rcv base) {

B ← first missing seq num()foreach i in rcv base . . .B − 1 {

r recv(buffer [i]) }

c© 2005–2008 Antonio Carzaniga

Page 312: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Receiver

received acceptable not usable

rcv base

sliding window

u recv([pkt2,X2]) and rcv base ≤ X2 < rcv base + W◮ buffer [X2]← pkt2◮ u send([ACK ,X2]∗)◮ if (X2 = rcv base) {

B ← first missing seq num()foreach i in rcv base . . .B − 1 {

r recv(buffer [i]) }rcv base← B }

c© 2005–2008 Antonio Carzaniga

Page 313: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

c© 2005–2008 Antonio Carzaniga

Page 314: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

c© 2005–2008 Antonio Carzaniga

Page 315: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

T

Timeout for sequence number T

c© 2005–2008 Antonio Carzaniga

Page 316: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

T

Timeout for sequence number T◮ u send([pkt[T ], T ]∗)

c© 2005–2008 Antonio Carzaniga

Page 317: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

c© 2005–2008 Antonio Carzaniga

Page 318: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

A

u recv([ACK,A])

c© 2005–2008 Antonio Carzaniga

Page 319: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

A

u recv([ACK,A])◮ acks[A]← 1

c© 2005–2008 Antonio Carzaniga

Page 320: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

A

u recv([ACK,A])◮ acks[A]← 1◮ if (A = base) {

c© 2005–2008 Antonio Carzaniga

Page 321: 20080426 networking carzaniga_lecture01-02

Selective Repeat: Sender

base

sliding window

next seq num

u recv([ACK,A])◮ acks[A]← 1◮ if (A = base) {

base← first missing ack num() }

c© 2005–2008 Antonio Carzaniga

Page 322: 20080426 networking carzaniga_lecture01-02

Part III

Congestion Control

c© 2005–2008 Antonio Carzaniga

Page 323: 20080426 networking carzaniga_lecture01-02

Understanding Congestion

A router behaves a lot like a kitchen sink

c© 2005–2008 Antonio Carzaniga

Page 324: 20080426 networking carzaniga_lecture01-02

Understanding Congestion

A router behaves a lot like a kitchen sink

max throughputT

c© 2005–2008 Antonio Carzaniga

Page 325: 20080426 networking carzaniga_lecture01-02

Understanding Congestion

A router behaves a lot like a kitchen sink

λ1 = T /2

throughput = T /2

max throughputT

c© 2005–2008 Antonio Carzaniga

Page 326: 20080426 networking carzaniga_lecture01-02

Understanding Congestion

A router behaves a lot like a kitchen sink

λ1 = T /2 λ2 = T /2

throughput = T

max throughputT

c© 2005–2008 Antonio Carzaniga

Page 327: 20080426 networking carzaniga_lecture01-02

Understanding Congestion

A router behaves a lot like a kitchen sink

λ1 = T /2 λ2 = T /2

throughput = T

λ3 = T /2

max throughputT

c© 2005–2008 Antonio Carzaniga

Page 328: 20080426 networking carzaniga_lecture01-02

Understanding Congestion

A router behaves a lot like a kitchen sink

λ1 = T /2 λ2 = T /2

throughput = T

λ3 = T /2

max throughputT

c© 2005–2008 Antonio Carzaniga

Page 329: 20080426 networking carzaniga_lecture01-02

Understanding Congestion

A router behaves a lot like a kitchen sink

λ1 = T /2 λ2 = T /2

throughput = T

λ3 = T /2

max throughputT

c© 2005–2008 Antonio Carzaniga

Page 330: 20080426 networking carzaniga_lecture01-02

Understanding Congestion

A router behaves a lot like a kitchen sink

λ1 = T /2 λ2 = T /2

throughput = T

λ3 = T /2

max throughputT

c© 2005–2008 Antonio Carzaniga

Page 331: 20080426 networking carzaniga_lecture01-02

Understanding Congestion

A router behaves a lot like a kitchen sink

λ1 = T /2 λ2 = T /2

throughput = T

λ3 = T /2

max throughputT

c© 2005–2008 Antonio Carzaniga

Page 332: 20080426 networking carzaniga_lecture01-02

Queuing Delay

c© 2005–2008 Antonio Carzaniga

Page 333: 20080426 networking carzaniga_lecture01-02

Queuing Delay

Total latency is the sum of link latency, processing time, and thetime that a packet spends in the input queue

L = ∆TX + ∆CPU + ∆q where ∆q = |q|/T

c© 2005–2008 Antonio Carzaniga

Page 334: 20080426 networking carzaniga_lecture01-02

Queuing Delay

Total latency is the sum of link latency, processing time, and thetime that a packet spends in the input queue

L = ∆TX + ∆CPU + ∆q where ∆q = |q|/T

Ideal case: constant input data rate

λin < T

In this case the ∆q = 0, because |q| = 0

c© 2005–2008 Antonio Carzaniga

Page 335: 20080426 networking carzaniga_lecture01-02

Queuing Delay

Total latency is the sum of link latency, processing time, and thetime that a packet spends in the input queue

L = ∆TX + ∆CPU + ∆q where ∆q = |q|/T

Ideal case: constant input data rate

λin < T

In this case the ∆q = 0, because |q| = 0

Extreme case: constant input data rate

λin > T

In this case |q| = (λin − T )t and therefore

∆q =λin − T

Tt

c© 2005–2008 Antonio Carzaniga

Page 336: 20080426 networking carzaniga_lecture01-02

Queuing Delay

c© 2005–2008 Antonio Carzaniga

Page 337: 20080426 networking carzaniga_lecture01-02

Queuing Delay

Steady-state queuing delay

∆q =

{

0 λin < Tλin−T

T t λin > T

c© 2005–2008 Antonio Carzaniga

Page 338: 20080426 networking carzaniga_lecture01-02

Queuing Delay

Steady-state queuing delay

∆q =

{

0 λin < Tλin−T

T t λin > T

∆q

λinT

ideal input flowλin constant

c© 2005–2008 Antonio Carzaniga

Page 339: 20080426 networking carzaniga_lecture01-02

Queuing Delay

Steady-state queuing delay

∆q =

{

0 λin < Tλin−T

T t λin > T

∆q

λinT

ideal input flowλin constant

∆q

λinT

realistic input flowλin variable

c© 2005–2008 Antonio Carzaniga

Page 340: 20080426 networking carzaniga_lecture01-02

Queuing Delay

c© 2005–2008 Antonio Carzaniga

Page 341: 20080426 networking carzaniga_lecture01-02

Queuing Delay

Conclusion: as the input rate λin approaches the maximumthroughput T , packets will experience very long delays

c© 2005–2008 Antonio Carzaniga

Page 342: 20080426 networking carzaniga_lecture01-02

Queuing Delay

Conclusion: as the input rate λin approaches the maximumthroughput T , packets will experience very long delays

More realistic assumptions and models◮ finite queue length (buffers) in routers◮ effects of retransmission overhead

c© 2005–2008 Antonio Carzaniga

Page 343: 20080426 networking carzaniga_lecture01-02

Queuing Delay

Conclusion: as the input rate λin approaches the maximumthroughput T , packets will experience very long delays

More realistic assumptions and models◮ finite queue length (buffers) in routers◮ effects of retransmission overhead

λout

λin

T

c© 2005–2008 Antonio Carzaniga

Page 344: 20080426 networking carzaniga_lecture01-02

Queuing Delay

Conclusion: as the input rate λin approaches the maximumthroughput T , packets will experience very long delays

More realistic assumptions and models◮ finite queue length (buffers) in routers◮ effects of retransmission overhead

λout

λin

T

congestion

c© 2005–2008 Antonio Carzaniga

Page 345: 20080426 networking carzaniga_lecture01-02

What to Do?

What to do when the network is congested and queues are full?

λ1 = T /2 λ2 = T /2

λ3 = T /2

max throughputT

throughput = T

c© 2005–2008 Antonio Carzaniga

Page 346: 20080426 networking carzaniga_lecture01-02

What to Do?

What to do when the network is congested and queues are full?

λ1 = T /2

max throughputT

throughput = T

c© 2005–2008 Antonio Carzaniga

Page 347: 20080426 networking carzaniga_lecture01-02

What to Do?

What to do when the network is congested and queues are full?

λ1 = T /2

max throughputT

throughput = T

c© 2005–2008 Antonio Carzaniga

Page 348: 20080426 networking carzaniga_lecture01-02

What to Do?

What to do when the network is congested and queues are full?

λ1 = T /2

max throughputT

throughput = T

c© 2005–2008 Antonio Carzaniga

Page 349: 20080426 networking carzaniga_lecture01-02

What to Do?

What to do when the network is congested and queues are full?

λ1 = T /2

max throughputT

throughput = T

c© 2005–2008 Antonio Carzaniga

Page 350: 20080426 networking carzaniga_lecture01-02

Part IV

Brief Overview of TCP

c© 2005–2008 Antonio Carzaniga

Page 351: 20080426 networking carzaniga_lecture01-02

Transmission Control Protocol

The Internet’s primary transport protocol◮ defined in RFC 793, RFC 1122, RFC 1323, RFC 2018, and

RFC 2581

c© 2005–2008 Antonio Carzaniga

Page 352: 20080426 networking carzaniga_lecture01-02

Transmission Control Protocol

The Internet’s primary transport protocol◮ defined in RFC 793, RFC 1122, RFC 1323, RFC 2018, and

RFC 2581

Connection-oriented service◮ endpoints “shake hands” to establish a connection◮ not a circuit-switched connection, nor a virtual circuit

c© 2005–2008 Antonio Carzaniga

Page 353: 20080426 networking carzaniga_lecture01-02

Transmission Control Protocol

The Internet’s primary transport protocol◮ defined in RFC 793, RFC 1122, RFC 1323, RFC 2018, and

RFC 2581

Connection-oriented service◮ endpoints “shake hands” to establish a connection◮ not a circuit-switched connection, nor a virtual circuit

Full-duplex service◮ both endpoints can both send and receiver, at the same time

c© 2005–2008 Antonio Carzaniga

Page 354: 20080426 networking carzaniga_lecture01-02

Preliminary Definitions

c© 2005–2008 Antonio Carzaniga

Page 355: 20080426 networking carzaniga_lecture01-02

Preliminary Definitions

TCP segment: envelope for TCP data

◮ TCP data are sent within TCP segments◮ TCP segments are usually sent within an IP packet

c© 2005–2008 Antonio Carzaniga

Page 356: 20080426 networking carzaniga_lecture01-02

Preliminary Definitions

TCP segment: envelope for TCP data

◮ TCP data are sent within TCP segments◮ TCP segments are usually sent within an IP packet

Maximum segment size (MSS): maximum amount of applicationdata transmitted in a single segment

◮ typically related to the MTU of the connection, to avoidnetwork-level fragmentation (we’ll talk about all of this later)

c© 2005–2008 Antonio Carzaniga

Page 357: 20080426 networking carzaniga_lecture01-02

Preliminary Definitions

TCP segment: envelope for TCP data

◮ TCP data are sent within TCP segments◮ TCP segments are usually sent within an IP packet

Maximum segment size (MSS): maximum amount of applicationdata transmitted in a single segment

◮ typically related to the MTU of the connection, to avoidnetwork-level fragmentation (we’ll talk about all of this later)

Maximum transmission unit (MTU): largest link-layer frameavailable to the sender host

◮ path MTU: largest link-layer frame that can be sent on all linksfrom the sender host to the receiver host

c© 2005–2008 Antonio Carzaniga

Page 358: 20080426 networking carzaniga_lecture01-02

TCP Segment Format

0 31

source port destination port

sequence number

acknowledgment number

hdrlen unused U A P R S F receive window

Internet checksum urgent data pointer

options field

data

c© 2005–2008 Antonio Carzaniga

Page 359: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

c© 2005–2008 Antonio Carzaniga

Page 360: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

Source and destination ports: (16-bit each) application identifiers

c© 2005–2008 Antonio Carzaniga

Page 361: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

Source and destination ports: (16-bit each) application identifiers

Sequence number: (32-bit) used to implement reliable datatransfer

Acknowledgment number: (32-bit) used to implement reliabledata transfer

c© 2005–2008 Antonio Carzaniga

Page 362: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

Source and destination ports: (16-bit each) application identifiers

Sequence number: (32-bit) used to implement reliable datatransfer

Acknowledgment number: (32-bit) used to implement reliabledata transfer

Receive window: (16-bit) size of the “window” on the receiver end

c© 2005–2008 Antonio Carzaniga

Page 363: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

Source and destination ports: (16-bit each) application identifiers

Sequence number: (32-bit) used to implement reliable datatransfer

Acknowledgment number: (32-bit) used to implement reliabledata transfer

Receive window: (16-bit) size of the “window” on the receiver end

Header length: (4-bit) size of the TCP header in 32-bit words

c© 2005–2008 Antonio Carzaniga

Page 364: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

Source and destination ports: (16-bit each) application identifiers

Sequence number: (32-bit) used to implement reliable datatransfer

Acknowledgment number: (32-bit) used to implement reliabledata transfer

Receive window: (16-bit) size of the “window” on the receiver end

Header length: (4-bit) size of the TCP header in 32-bit words

Optional and variable-length options field: may be used tonegotiate protocol parameters

c© 2005–2008 Antonio Carzaniga

Page 365: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

c© 2005–2008 Antonio Carzaniga

Page 366: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

ACK flag: (1-bit) signals that the value contained in theacknowledgment number represents a valid acknowledgment

c© 2005–2008 Antonio Carzaniga

Page 367: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

ACK flag: (1-bit) signals that the value contained in theacknowledgment number represents a valid acknowledgment

SYN flag: (1-bit) used during connection setup and shutdown

c© 2005–2008 Antonio Carzaniga

Page 368: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

ACK flag: (1-bit) signals that the value contained in theacknowledgment number represents a valid acknowledgment

SYN flag: (1-bit) used during connection setup and shutdown

RST flag: (1-bit) used during connection setup and shutdown

c© 2005–2008 Antonio Carzaniga

Page 369: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

ACK flag: (1-bit) signals that the value contained in theacknowledgment number represents a valid acknowledgment

SYN flag: (1-bit) used during connection setup and shutdown

RST flag: (1-bit) used during connection setup and shutdown

FIN flag: (1-bit) used during connection shutdown

c© 2005–2008 Antonio Carzaniga

Page 370: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

ACK flag: (1-bit) signals that the value contained in theacknowledgment number represents a valid acknowledgment

SYN flag: (1-bit) used during connection setup and shutdown

RST flag: (1-bit) used during connection setup and shutdown

FIN flag: (1-bit) used during connection shutdown

PSH flag: (1-bit) “push” flag, used to solicit the receiver to passthe data to the application immediately

c© 2005–2008 Antonio Carzaniga

Page 371: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

ACK flag: (1-bit) signals that the value contained in theacknowledgment number represents a valid acknowledgment

SYN flag: (1-bit) used during connection setup and shutdown

RST flag: (1-bit) used during connection setup and shutdown

FIN flag: (1-bit) used during connection shutdown

PSH flag: (1-bit) “push” flag, used to solicit the receiver to passthe data to the application immediately

URG flag: (1-bit) “urgent” flag, used to inform the receiver thatthe sender has marked some data as “urgent”. The location ofthis urgent data is marked by the urgent data pointer field

c© 2005–2008 Antonio Carzaniga

Page 372: 20080426 networking carzaniga_lecture01-02

TCP Header Fields

ACK flag: (1-bit) signals that the value contained in theacknowledgment number represents a valid acknowledgment

SYN flag: (1-bit) used during connection setup and shutdown

RST flag: (1-bit) used during connection setup and shutdown

FIN flag: (1-bit) used during connection shutdown

PSH flag: (1-bit) “push” flag, used to solicit the receiver to passthe data to the application immediately

URG flag: (1-bit) “urgent” flag, used to inform the receiver thatthe sender has marked some data as “urgent”. The location ofthis urgent data is marked by the urgent data pointer field

Checksum: (16-bit) used to detect transmission errors

c© 2005–2008 Antonio Carzaniga

Page 373: 20080426 networking carzaniga_lecture01-02

Sequence Numbers

c© 2005–2008 Antonio Carzaniga

Page 374: 20080426 networking carzaniga_lecture01-02

Sequence Numbers

Sequence numbers are associated with bytes in the data stream◮ not with segments, as we have used them before

c© 2005–2008 Antonio Carzaniga

Page 375: 20080426 networking carzaniga_lecture01-02

Sequence Numbers

Sequence numbers are associated with bytes in the data stream◮ not with segments, as we have used them before

The sequence number in a TCP segment indicates thesequence number of the first byte carried by that segment

c© 2005–2008 Antonio Carzaniga

Page 376: 20080426 networking carzaniga_lecture01-02

Sequence Numbers

Sequence numbers are associated with bytes in the data stream◮ not with segments, as we have used them before

The sequence number in a TCP segment indicates thesequence number of the first byte carried by that segment

application data stream4Kb

c© 2005–2008 Antonio Carzaniga

Page 377: 20080426 networking carzaniga_lecture01-02

Sequence Numbers

Sequence numbers are associated with bytes in the data stream◮ not with segments, as we have used them before

The sequence number in a TCP segment indicates thesequence number of the first byte carried by that segment

application data stream4Kb

MSS=1024b

c© 2005–2008 Antonio Carzaniga

Page 378: 20080426 networking carzaniga_lecture01-02

Sequence Numbers

Sequence numbers are associated with bytes in the data stream◮ not with segments, as we have used them before

The sequence number in a TCP segment indicates thesequence number of the first byte carried by that segment

application data stream4Kb

MSS=1024b

c© 2005–2008 Antonio Carzaniga

Page 379: 20080426 networking carzaniga_lecture01-02

Sequence Numbers

Sequence numbers are associated with bytes in the data stream◮ not with segments, as we have used them before

The sequence number in a TCP segment indicates thesequence number of the first byte carried by that segment

application data stream4Kb

MSS=1024b

1. . . . . . 1024 1025. . . 2048 2049. . . 3072 3073. . . 4096

c© 2005–2008 Antonio Carzaniga

Page 380: 20080426 networking carzaniga_lecture01-02

Sequence Numbers

Sequence numbers are associated with bytes in the data stream◮ not with segments, as we have used them before

The sequence number in a TCP segment indicates thesequence number of the first byte carried by that segment

application data stream4Kb

MSS=1024b

1. . . . . . 1024 1025. . . 2048 2049. . . 3072 3073. . . 4096

a TCP segment

c© 2005–2008 Antonio Carzaniga

Page 381: 20080426 networking carzaniga_lecture01-02

Sequence Numbers

Sequence numbers are associated with bytes in the data stream◮ not with segments, as we have used them before

The sequence number in a TCP segment indicates thesequence number of the first byte carried by that segment

application data stream4Kb

MSS=1024b

1. . . . . . 1024 1025. . . 2048 2049. . . 3072 3073. . . 4096

a TCP segment

2049

c© 2005–2008 Antonio Carzaniga

Page 382: 20080426 networking carzaniga_lecture01-02

Sequence Numbers

Sequence numbers are associated with bytes in the data stream◮ not with segments, as we have used them before

The sequence number in a TCP segment indicates thesequence number of the first byte carried by that segment

application data stream4Kb

MSS=1024b

1. . . . . . 1024 1025. . . 2048 2049. . . 3072 3073. . . 4096

a TCP segment

2049

sequence number

c© 2005–2008 Antonio Carzaniga

Page 383: 20080426 networking carzaniga_lecture01-02

Acknowledgment Numbers

c© 2005–2008 Antonio Carzaniga

Page 384: 20080426 networking carzaniga_lecture01-02

Acknowledgment Numbers

An acknowledgment number represents the first sequencenumber not yet seen by the receiver

◮ TCP acknowledgments are cumulative

c© 2005–2008 Antonio Carzaniga

Page 385: 20080426 networking carzaniga_lecture01-02

Acknowledgment Numbers

An acknowledgment number represents the first sequencenumber not yet seen by the receiver

◮ TCP acknowledgments are cumulative

A B

c© 2005–2008 Antonio Carzaniga

Page 386: 20080426 networking carzaniga_lecture01-02

Acknowledgment Numbers

An acknowledgment number represents the first sequencenumber not yet seen by the receiver

◮ TCP acknowledgments are cumulative

A B

[Seq# = 1200, . . .], size(data) = 1000

c© 2005–2008 Antonio Carzaniga

Page 387: 20080426 networking carzaniga_lecture01-02

Acknowledgment Numbers

An acknowledgment number represents the first sequencenumber not yet seen by the receiver

◮ TCP acknowledgments are cumulative

A B

[Seq# = 1200, . . .], size(data) = 1000

[Seq# = 2200, . . .], size(data) = 500

c© 2005–2008 Antonio Carzaniga

Page 388: 20080426 networking carzaniga_lecture01-02

Acknowledgment Numbers

An acknowledgment number represents the first sequencenumber not yet seen by the receiver

◮ TCP acknowledgments are cumulative

A B

[Seq# = 1200, . . .], size(data) = 1000

[Seq# = 2200, . . .], size(data) = 500

[Seq# = . . . ,Ack# = 2700]

c© 2005–2008 Antonio Carzaniga

Page 389: 20080426 networking carzaniga_lecture01-02

Sequence Numbers and ACK Numbers

c© 2005–2008 Antonio Carzaniga

Page 390: 20080426 networking carzaniga_lecture01-02

Sequence Numbers and ACK Numbers

Notice that a TCP connection consists of is a full-duplex link◮ therefore, there are two streams◮ two different sequence numbers

c© 2005–2008 Antonio Carzaniga

Page 391: 20080426 networking carzaniga_lecture01-02

Sequence Numbers and ACK Numbers

Notice that a TCP connection consists of is a full-duplex link◮ therefore, there are two streams◮ two different sequence numbers

E.g., consider a simple “Echo” application:A B

c© 2005–2008 Antonio Carzaniga

Page 392: 20080426 networking carzaniga_lecture01-02

Sequence Numbers and ACK Numbers

Notice that a TCP connection consists of is a full-duplex link◮ therefore, there are two streams◮ two different sequence numbers

E.g., consider a simple “Echo” application:A B

[Seq# = 100,Data =“C”]

c© 2005–2008 Antonio Carzaniga

Page 393: 20080426 networking carzaniga_lecture01-02

Sequence Numbers and ACK Numbers

Notice that a TCP connection consists of is a full-duplex link◮ therefore, there are two streams◮ two different sequence numbers

E.g., consider a simple “Echo” application:A B

[Seq# = 100,Data =“C”]

[Ack# = 101,Seq# = 200,Data =“C”]

c© 2005–2008 Antonio Carzaniga

Page 394: 20080426 networking carzaniga_lecture01-02

Sequence Numbers and ACK Numbers

Notice that a TCP connection consists of is a full-duplex link◮ therefore, there are two streams◮ two different sequence numbers

E.g., consider a simple “Echo” application:A B

[Seq# = 100,Data =“C”]

[Ack# = 101,Seq# = 200,Data =“C”]

[Seq# = 101,Ack# = 201,Data =“i”]

c© 2005–2008 Antonio Carzaniga

Page 395: 20080426 networking carzaniga_lecture01-02

Sequence Numbers and ACK Numbers

Notice that a TCP connection consists of is a full-duplex link◮ therefore, there are two streams◮ two different sequence numbers

E.g., consider a simple “Echo” application:A B

[Seq# = 100,Data =“C”]

[Ack# = 101,Seq# = 200,Data =“C”]

[Seq# = 101,Ack# = 201,Data =“i”]

[Seq# = 201,Ack# = 102,Data =“i”]

c© 2005–2008 Antonio Carzaniga

Page 396: 20080426 networking carzaniga_lecture01-02

Sequence Numbers and ACK Numbers

Notice that a TCP connection consists of is a full-duplex link◮ therefore, there are two streams◮ two different sequence numbers

E.g., consider a simple “Echo” application:A B

[Seq# = 100,Data =“C”]

[Ack# = 101,Seq# = 200,Data =“C”]

[Seq# = 101,Ack# = 201,Data =“i”]

[Seq# = 201,Ack# = 102,Data =“i”]

Acknowledgments are “piggybacked” on data segments

c© 2005–2008 Antonio Carzaniga

Page 397: 20080426 networking carzaniga_lecture01-02

Reliability and Timeout

TCP provides reliable data transfer using a timer to detect lostsegments

◮ timeout without an ACK→ lost packet→ retransmission

c© 2005–2008 Antonio Carzaniga

Page 398: 20080426 networking carzaniga_lecture01-02

Reliability and Timeout

TCP provides reliable data transfer using a timer to detect lostsegments

◮ timeout without an ACK→ lost packet→ retransmission

How long to wait for acknowledgments?

c© 2005–2008 Antonio Carzaniga

Page 399: 20080426 networking carzaniga_lecture01-02

Reliability and Timeout

TCP provides reliable data transfer using a timer to detect lostsegments

◮ timeout without an ACK→ lost packet→ retransmission

How long to wait for acknowledgments?

Retransmission timeouts should be larger than the round-triptime RTT = 2L

◮ as close as possible to the RTT

c© 2005–2008 Antonio Carzaniga

Page 400: 20080426 networking carzaniga_lecture01-02

Reliability and Timeout

TCP provides reliable data transfer using a timer to detect lostsegments

◮ timeout without an ACK→ lost packet→ retransmission

How long to wait for acknowledgments?

Retransmission timeouts should be larger than the round-triptime RTT = 2L

◮ as close as possible to the RTT

TCP controls its timeout by continuously estimating the currentRTT

c© 2005–2008 Antonio Carzaniga

Page 401: 20080426 networking carzaniga_lecture01-02

Round-Trip Time Estimation

c© 2005–2008 Antonio Carzaniga

Page 402: 20080426 networking carzaniga_lecture01-02

Round-Trip Time Estimation

RTT is measured using ACKs

◮ only for packets transmitted once

Given a single sample S at any given time

Exponential weighted moving average (EWMA)

RTT = (1−α)RTT′+αS

c© 2005–2008 Antonio Carzaniga

Page 403: 20080426 networking carzaniga_lecture01-02

Round-Trip Time Estimation

RTT is measured using ACKs

◮ only for packets transmitted once

Given a single sample S at any given time

Exponential weighted moving average (EWMA)

RTT = (1−α)RTT′+αS

◮ RFC 2988 recommends α = 0.125

c© 2005–2008 Antonio Carzaniga

Page 404: 20080426 networking carzaniga_lecture01-02

Round-Trip Time Estimation

RTT is measured using ACKs

◮ only for packets transmitted once

Given a single sample S at any given time

Exponential weighted moving average (EWMA)

RTT = (1−α)RTT′+αS

◮ RFC 2988 recommends α = 0.125

TCP also measures the variability of RTT

DevRTT = (1−β)DevRTT′+ β|RTT

′− S|

c© 2005–2008 Antonio Carzaniga

Page 405: 20080426 networking carzaniga_lecture01-02

Round-Trip Time Estimation

RTT is measured using ACKs

◮ only for packets transmitted once

Given a single sample S at any given time

Exponential weighted moving average (EWMA)

RTT = (1−α)RTT′+αS

◮ RFC 2988 recommends α = 0.125

TCP also measures the variability of RTT

DevRTT = (1−β)DevRTT′+ β|RTT

′− S|

◮ RFC 2988 recommends β = 0.25

c© 2005–2008 Antonio Carzaniga

Page 406: 20080426 networking carzaniga_lecture01-02

Timeout Value

c© 2005–2008 Antonio Carzaniga

Page 407: 20080426 networking carzaniga_lecture01-02

Timeout Value

The timeout interval T must be larger than the RTT◮ so as to avoid unnecessary retransmission

However, T should not be too far from RTT◮ so as to detect (and retransmit) lost segments as quickly as

possible

c© 2005–2008 Antonio Carzaniga

Page 408: 20080426 networking carzaniga_lecture01-02

Timeout Value

The timeout interval T must be larger than the RTT◮ so as to avoid unnecessary retransmission

However, T should not be too far from RTT◮ so as to detect (and retransmit) lost segments as quickly as

possible

TCP sets its timeouts using the estimated RTT (RTT ) and thevariability estimate DevRTT :

T = RTT + 4DevRTT

c© 2005–2008 Antonio Carzaniga

Page 409: 20080426 networking carzaniga_lecture01-02

Reliable Data Transfer (Sender)

A simplified TCP sender

r send(data)if (timer not running)

start timer()u send([data,next seq num])next seq num← next seq num + length(data)

c© 2005–2008 Antonio Carzaniga

Page 410: 20080426 networking carzaniga_lecture01-02

Reliable Data Transfer (Sender)

A simplified TCP sender

r send(data)if (timer not running)

start timer()u send([data,next seq num])next seq num← next seq num + length(data)

timeoutu send(pending segment with smallest sequence number)start timer()

c© 2005–2008 Antonio Carzaniga

Page 411: 20080426 networking carzaniga_lecture01-02

Reliable Data Transfer (Sender)

A simplified TCP sender

r send(data)if (timer not running)

start timer()u send([data,next seq num])next seq num← next seq num + length(data)

timeoutu send(pending segment with smallest sequence number)start timer()

u recv([ACK,y ])if (y > base)

base← yif (∃ pending segments)

start timer()else . . .

c© 2005–2008 Antonio Carzaniga

Page 412: 20080426 networking carzaniga_lecture01-02

Acknowledgment Generation (Receiver)

c© 2005–2008 Antonio Carzaniga

Page 413: 20080426 networking carzaniga_lecture01-02

Acknowledgment Generation (Receiver)

Arrival of in-order segment with expected sequence number; alldata up to expected sequence number already acknowledged

c© 2005–2008 Antonio Carzaniga

Page 414: 20080426 networking carzaniga_lecture01-02

Acknowledgment Generation (Receiver)

Arrival of in-order segment with expected sequence number; alldata up to expected sequence number already acknowledged

◮ Delayed ACK: wait 500ms for another in-order segment. If thatdoesn’t happen, send ACK

c© 2005–2008 Antonio Carzaniga

Page 415: 20080426 networking carzaniga_lecture01-02

Acknowledgment Generation (Receiver)

Arrival of in-order segment with expected sequence number; alldata up to expected sequence number already acknowledged

◮ Delayed ACK: wait 500ms for another in-order segment. If thatdoesn’t happen, send ACK

Arrival of in-order segment with expected sequence number.One other in-order segment waiting for ACK (see above)

c© 2005–2008 Antonio Carzaniga

Page 416: 20080426 networking carzaniga_lecture01-02

Acknowledgment Generation (Receiver)

Arrival of in-order segment with expected sequence number; alldata up to expected sequence number already acknowledged

◮ Delayed ACK: wait 500ms for another in-order segment. If thatdoesn’t happen, send ACK

Arrival of in-order segment with expected sequence number.One other in-order segment waiting for ACK (see above)

◮ Cumulative ACK: immediately send cumulative ACK (for bothsegments)

c© 2005–2008 Antonio Carzaniga

Page 417: 20080426 networking carzaniga_lecture01-02

Acknowledgment Generation (Receiver)

Arrival of in-order segment with expected sequence number; alldata up to expected sequence number already acknowledged

◮ Delayed ACK: wait 500ms for another in-order segment. If thatdoesn’t happen, send ACK

Arrival of in-order segment with expected sequence number.One other in-order segment waiting for ACK (see above)

◮ Cumulative ACK: immediately send cumulative ACK (for bothsegments)

Arrival of out of order segment with higher-than-expectedsequence number (gap detected)

c© 2005–2008 Antonio Carzaniga

Page 418: 20080426 networking carzaniga_lecture01-02

Acknowledgment Generation (Receiver)

Arrival of in-order segment with expected sequence number; alldata up to expected sequence number already acknowledged

◮ Delayed ACK: wait 500ms for another in-order segment. If thatdoesn’t happen, send ACK

Arrival of in-order segment with expected sequence number.One other in-order segment waiting for ACK (see above)

◮ Cumulative ACK: immediately send cumulative ACK (for bothsegments)

Arrival of out of order segment with higher-than-expectedsequence number (gap detected)

◮ Duplicate ACK: immediately send duplicate ACK

c© 2005–2008 Antonio Carzaniga

Page 419: 20080426 networking carzaniga_lecture01-02

Acknowledgment Generation (Receiver)

Arrival of in-order segment with expected sequence number; alldata up to expected sequence number already acknowledged

◮ Delayed ACK: wait 500ms for another in-order segment. If thatdoesn’t happen, send ACK

Arrival of in-order segment with expected sequence number.One other in-order segment waiting for ACK (see above)

◮ Cumulative ACK: immediately send cumulative ACK (for bothsegments)

Arrival of out of order segment with higher-than-expectedsequence number (gap detected)

◮ Duplicate ACK: immediately send duplicate ACK

Arrival of segment that (partially or completely) fills a gap in thereceived data

c© 2005–2008 Antonio Carzaniga

Page 420: 20080426 networking carzaniga_lecture01-02

Acknowledgment Generation (Receiver)

Arrival of in-order segment with expected sequence number; alldata up to expected sequence number already acknowledged

◮ Delayed ACK: wait 500ms for another in-order segment. If thatdoesn’t happen, send ACK

Arrival of in-order segment with expected sequence number.One other in-order segment waiting for ACK (see above)

◮ Cumulative ACK: immediately send cumulative ACK (for bothsegments)

Arrival of out of order segment with higher-than-expectedsequence number (gap detected)

◮ Duplicate ACK: immediately send duplicate ACK

Arrival of segment that (partially or completely) fills a gap in thereceived data

◮ Immediate ACK: immediately send ACK if the packet start at thelower end of the gap

c© 2005–2008 Antonio Carzaniga

Page 421: 20080426 networking carzaniga_lecture01-02

Reaction to ACKs (Sender)

c© 2005–2008 Antonio Carzaniga

Page 422: 20080426 networking carzaniga_lecture01-02

Reaction to ACKs (Sender)

u recv([ACK,y ])if (y > base)

base← yif (∃ pending segments)

start timer()

c© 2005–2008 Antonio Carzaniga

Page 423: 20080426 networking carzaniga_lecture01-02

Reaction to ACKs (Sender)

u recv([ACK,y ])if (y > base)

base← yif (∃ pending segments)

start timer()else

ack counter [y ]← ack counter [y ] + 1if (ack counter [y ] = 3)

u send(segment with sequence number y)

c© 2005–2008 Antonio Carzaniga

Page 424: 20080426 networking carzaniga_lecture01-02

Connection Setup

c© 2005–2008 Antonio Carzaniga

Page 425: 20080426 networking carzaniga_lecture01-02

Connection Setup

Three-way handshake

c© 2005–2008 Antonio Carzaniga

Page 426: 20080426 networking carzaniga_lecture01-02

Connection Setup

Three-way handshake

client server

c© 2005–2008 Antonio Carzaniga

Page 427: 20080426 networking carzaniga_lecture01-02

Connection Setup

Three-way handshake

client server

[SYN ,Seq# = cli init seq]

c© 2005–2008 Antonio Carzaniga

Page 428: 20080426 networking carzaniga_lecture01-02

Connection Setup

Three-way handshake

client server

[SYN ,Seq# = cli init seq]

[SYN ,ACK ,Ack# = cli init seq + 1,Seq# = srv init seq]

c© 2005–2008 Antonio Carzaniga

Page 429: 20080426 networking carzaniga_lecture01-02

Connection Setup

Three-way handshake

client server

[SYN ,Seq# = cli init seq]

[SYN ,ACK ,Ack# = cli init seq + 1,Seq# = srv init seq]

[ACK ,Seq# = cli init seq + 1,Ack# = srv init seq + 1]

c© 2005–2008 Antonio Carzaniga

Page 430: 20080426 networking carzaniga_lecture01-02

Connection Shutdown

“This is it.”“Okay, Bye now.”

“Bye.”

c© 2005–2008 Antonio Carzaniga

Page 431: 20080426 networking carzaniga_lecture01-02

Connection Shutdown

“This is it.”“Okay, Bye now.”

“Bye.”

client server

c© 2005–2008 Antonio Carzaniga

Page 432: 20080426 networking carzaniga_lecture01-02

Connection Shutdown

“This is it.”“Okay, Bye now.”

“Bye.”

client server

[FIN]

c© 2005–2008 Antonio Carzaniga

Page 433: 20080426 networking carzaniga_lecture01-02

Connection Shutdown

“This is it.”“Okay, Bye now.”

“Bye.”

client server

[FIN]

[ACK ]

c© 2005–2008 Antonio Carzaniga

Page 434: 20080426 networking carzaniga_lecture01-02

Connection Shutdown

“This is it.”“Okay, Bye now.”

“Bye.”

client server

[FIN]

[ACK ]

[FIN]

c© 2005–2008 Antonio Carzaniga

Page 435: 20080426 networking carzaniga_lecture01-02

Connection Shutdown

“This is it.”“Okay, Bye now.”

“Bye.”

client server

[FIN]

[ACK ]

[FIN]

[ACK ]

c© 2005–2008 Antonio Carzaniga

Page 436: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Client)

CLOSED

c© 2005–2008 Antonio Carzaniga

Page 437: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Client)

CLOSED

SYN SENT

applicationopens connectionsend SYN

c© 2005–2008 Antonio Carzaniga

Page 438: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Client)

CLOSED

SYN SENT

applicationopens connectionsend SYN

ESTABLISHED

receive SYN,ACKsend ACK

c© 2005–2008 Antonio Carzaniga

Page 439: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Client)

CLOSED

SYN SENT

applicationopens connectionsend SYN

ESTABLISHED

receive SYN,ACKsend ACK

FIN WAIT 1

applicationcloses connectionsend FIN

c© 2005–2008 Antonio Carzaniga

Page 440: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Client)

CLOSED

SYN SENT

applicationopens connectionsend SYN

ESTABLISHED

receive SYN,ACKsend ACK

FIN WAIT 1

applicationcloses connectionsend FIN

FIN WAIT 2

receive ACK

c© 2005–2008 Antonio Carzaniga

Page 441: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Client)

CLOSED

SYN SENT

applicationopens connectionsend SYN

ESTABLISHED

receive SYN,ACKsend ACK

FIN WAIT 1

applicationcloses connectionsend FIN

FIN WAIT 2

receive ACK

TIME WAIT

receive FINsend ACK

c© 2005–2008 Antonio Carzaniga

Page 442: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Client)

CLOSED

SYN SENT

applicationopens connectionsend SYN

ESTABLISHED

receive SYN,ACKsend ACK

FIN WAIT 1

applicationcloses connectionsend FIN

FIN WAIT 2

receive ACK

TIME WAIT

receive FINsend ACK

wait 30 seconds

c© 2005–2008 Antonio Carzaniga

Page 443: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Server)

CLOSED

c© 2005–2008 Antonio Carzaniga

Page 444: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Server)

CLOSED

LISTEN

applicationopens server socket

c© 2005–2008 Antonio Carzaniga

Page 445: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Server)

CLOSED

LISTEN

applicationopens server socket

SYN RCVD

receive SYNsend SYN,ACK

c© 2005–2008 Antonio Carzaniga

Page 446: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Server)

CLOSED

LISTEN

applicationopens server socket

SYN RCVD

receive SYNsend SYN,ACK

ESTABLISHED

receive ACK

c© 2005–2008 Antonio Carzaniga

Page 447: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Server)

CLOSED

LISTEN

applicationopens server socket

SYN RCVD

receive SYNsend SYN,ACK

ESTABLISHED

receive ACK

CLOSE WAIT

receive FINsend ACK

c© 2005–2008 Antonio Carzaniga

Page 448: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Server)

CLOSED

LISTEN

applicationopens server socket

SYN RCVD

receive SYNsend SYN,ACK

ESTABLISHED

receive ACK

CLOSE WAIT

receive FINsend ACK

LAST ACK

send FIN

c© 2005–2008 Antonio Carzaniga

Page 449: 20080426 networking carzaniga_lecture01-02

The TCP State Machine (Server)

CLOSED

LISTEN

applicationopens server socket

SYN RCVD

receive SYNsend SYN,ACK

ESTABLISHED

receive ACK

CLOSE WAIT

receive FINsend ACK

LAST ACK

send FIN

receive ACK

c© 2005–2008 Antonio Carzaniga

Page 450: 20080426 networking carzaniga_lecture01-02

Part V

Congestion Control in TCP

c© 2005–2008 Antonio Carzaniga

Page 451: 20080426 networking carzaniga_lecture01-02

Congestion Control (in TCP)

c© 2005–2008 Antonio Carzaniga

Page 452: 20080426 networking carzaniga_lecture01-02

Congestion Control (in TCP)

Approach: the sender limits its output rate according to thestatus of the network

◮ the sender output rate becomes (part of) the input rate for thenetwork (λin)

c© 2005–2008 Antonio Carzaniga

Page 453: 20080426 networking carzaniga_lecture01-02

Congestion Control (in TCP)

Approach: the sender limits its output rate according to thestatus of the network

◮ the sender output rate becomes (part of) the input rate for thenetwork (λin)

Issues

c© 2005–2008 Antonio Carzaniga

Page 454: 20080426 networking carzaniga_lecture01-02

Congestion Control (in TCP)

Approach: the sender limits its output rate according to thestatus of the network

◮ the sender output rate becomes (part of) the input rate for thenetwork (λin)

Issues

◮ how does the sender “measure” the status of the network?◮ i.e., how does the sender detect congestion?

c© 2005–2008 Antonio Carzaniga

Page 455: 20080426 networking carzaniga_lecture01-02

Congestion Control (in TCP)

Approach: the sender limits its output rate according to thestatus of the network

◮ the sender output rate becomes (part of) the input rate for thenetwork (λin)

Issues

◮ how does the sender “measure” the status of the network?◮ i.e., how does the sender detect congestion?

◮ how does the sender effectively limit its output rate?

c© 2005–2008 Antonio Carzaniga

Page 456: 20080426 networking carzaniga_lecture01-02

Congestion Control (in TCP)

Approach: the sender limits its output rate according to thestatus of the network

◮ the sender output rate becomes (part of) the input rate for thenetwork (λin)

Issues

◮ how does the sender “measure” the status of the network?◮ i.e., how does the sender detect congestion?

◮ how does the sender effectively limit its output rate?

◮ how should the sender “modulate” its output rate?◮ i.e., what algorithm should the sender use to decrease or increase

its output rate?

c© 2005–2008 Antonio Carzaniga

Page 457: 20080426 networking carzaniga_lecture01-02

Detecting Congestion

c© 2005–2008 Antonio Carzaniga

Page 458: 20080426 networking carzaniga_lecture01-02

Detecting Congestion

If all traffic is correctly acknowledged, then the sender assumes(quite correctly) that there is no congestion

c© 2005–2008 Antonio Carzaniga

Page 459: 20080426 networking carzaniga_lecture01-02

Detecting Congestion

If all traffic is correctly acknowledged, then the sender assumes(quite correctly) that there is no congestion

Congestion means that queue overflow in one or more routersbetween the sender and the receiver

◮ the visible effect is that some segments are dropped

c© 2005–2008 Antonio Carzaniga

Page 460: 20080426 networking carzaniga_lecture01-02

Detecting Congestion

If all traffic is correctly acknowledged, then the sender assumes(quite correctly) that there is no congestion

Congestion means that queue overflow in one or more routersbetween the sender and the receiver

◮ the visible effect is that some segments are dropped

Therefore the server assumes that the network is congestedwhen it detects a segment loss

◮ time out (i.e., no ACK)◮ multiple acknowledgements (i.e., NACK)

c© 2005–2008 Antonio Carzaniga

Page 461: 20080426 networking carzaniga_lecture01-02

Congestion Window

The sender maintains a congestion window W

c© 2005–2008 Antonio Carzaniga

Page 462: 20080426 networking carzaniga_lecture01-02

Congestion Window

The sender maintains a congestion window W

The congestion window limits the amount of bytes that thesender pushes into the network before blocking waiting foracknowledgments

c© 2005–2008 Antonio Carzaniga

Page 463: 20080426 networking carzaniga_lecture01-02

Congestion Window

The sender maintains a congestion window W

The congestion window limits the amount of bytes that thesender pushes into the network before blocking waiting foracknowledgments

LastByteSent − LastByteAcked ≤ W

where

W = min (CongestionWindow ,ReceiverWindow)

c© 2005–2008 Antonio Carzaniga

Page 464: 20080426 networking carzaniga_lecture01-02

Congestion Window

The sender maintains a congestion window W

The congestion window limits the amount of bytes that thesender pushes into the network before blocking waiting foracknowledgments

LastByteSent − LastByteAcked ≤ W

where

W = min (CongestionWindow ,ReceiverWindow)

The resulting maximum output rate is roughly

λ =W2L

c© 2005–2008 Antonio Carzaniga

Page 465: 20080426 networking carzaniga_lecture01-02

Congestion Control

How does TCP “modulate” its output rate?

c© 2005–2008 Antonio Carzaniga

Page 466: 20080426 networking carzaniga_lecture01-02

Congestion Control

How does TCP “modulate” its output rate?

Additive-increase and multiplicative-decrease

c© 2005–2008 Antonio Carzaniga

Page 467: 20080426 networking carzaniga_lecture01-02

Congestion Control

How does TCP “modulate” its output rate?

Additive-increase and multiplicative-decrease

Slow start

c© 2005–2008 Antonio Carzaniga

Page 468: 20080426 networking carzaniga_lecture01-02

Congestion Control

How does TCP “modulate” its output rate?

Additive-increase and multiplicative-decrease

Slow start

Reaction to timeout events

c© 2005–2008 Antonio Carzaniga

Page 469: 20080426 networking carzaniga_lecture01-02

Additive-Increase/Multiplicative-Decrease

c© 2005–2008 Antonio Carzaniga

Page 470: 20080426 networking carzaniga_lecture01-02

Additive-Increase/Multiplicative-Decrease

How W is reduced: at every loss event, TCP halves thecongestion window

c© 2005–2008 Antonio Carzaniga

Page 471: 20080426 networking carzaniga_lecture01-02

Additive-Increase/Multiplicative-Decrease

How W is reduced: at every loss event, TCP halves thecongestion window

◮ e.g., suppose the window size W is currently 20Kb, and a loss isdetected

◮ TCP reduces W to 10Kb

c© 2005–2008 Antonio Carzaniga

Page 472: 20080426 networking carzaniga_lecture01-02

Additive-Increase/Multiplicative-Decrease

How W is reduced: at every loss event, TCP halves thecongestion window

◮ e.g., suppose the window size W is currently 20Kb, and a loss isdetected

◮ TCP reduces W to 10Kb

How W is increased: at every (good) acknowledgment, TCPincrements W by 1MSS/W , so as to increase W by MSS everyround-trip time 2L. This process is called congestion avoidance

c© 2005–2008 Antonio Carzaniga

Page 473: 20080426 networking carzaniga_lecture01-02

Additive-Increase/Multiplicative-Decrease

How W is reduced: at every loss event, TCP halves thecongestion window

◮ e.g., suppose the window size W is currently 20Kb, and a loss isdetected

◮ TCP reduces W to 10Kb

How W is increased: at every (good) acknowledgment, TCPincrements W by 1MSS/W , so as to increase W by MSS everyround-trip time 2L. This process is called congestion avoidance

◮ e.g., suppose W = 14600 and MSS = 1460, then the senderincreases W to 16060 after 10 acknowledgments

c© 2005–2008 Antonio Carzaniga

Page 474: 20080426 networking carzaniga_lecture01-02

Additive-Increase/Multiplicative-Decrease

Window size W over time

W

Time

c© 2005–2008 Antonio Carzaniga

Page 475: 20080426 networking carzaniga_lecture01-02

Slow Start

What is the initial value of W?

c© 2005–2008 Antonio Carzaniga

Page 476: 20080426 networking carzaniga_lecture01-02

Slow Start

What is the initial value of W?

The initial value of W is MSS, which is quite low for modernnetworks

c© 2005–2008 Antonio Carzaniga

Page 477: 20080426 networking carzaniga_lecture01-02

Slow Start

What is the initial value of W?

The initial value of W is MSS, which is quite low for modernnetworks

In order to get quickly to a good throughput level, TCP increasesits sending rate exponentially for its first growth phase

c© 2005–2008 Antonio Carzaniga

Page 478: 20080426 networking carzaniga_lecture01-02

Slow Start

What is the initial value of W?

The initial value of W is MSS, which is quite low for modernnetworks

In order to get quickly to a good throughput level, TCP increasesits sending rate exponentially for its first growth phase

After experiencing the first loss, TCP cuts W in half andproceeds with its linear push

c© 2005–2008 Antonio Carzaniga

Page 479: 20080426 networking carzaniga_lecture01-02

Slow Start

What is the initial value of W?

The initial value of W is MSS, which is quite low for modernnetworks

In order to get quickly to a good throughput level, TCP increasesits sending rate exponentially for its first growth phase

After experiencing the first loss, TCP cuts W in half andproceeds with its linear push

This process is called slow start, because of the small initialvalue of W

c© 2005–2008 Antonio Carzaniga

Page 480: 20080426 networking carzaniga_lecture01-02

Timeouts vs. NACKs

As we know, three duplicate ACKs are interpreted as a NACK

c© 2005–2008 Antonio Carzaniga

Page 481: 20080426 networking carzaniga_lecture01-02

Timeouts vs. NACKs

As we know, three duplicate ACKs are interpreted as a NACK

Both timeouts and NACKs signal a loss, but they say differentthings about the status of the network

c© 2005–2008 Antonio Carzaniga

Page 482: 20080426 networking carzaniga_lecture01-02

Timeouts vs. NACKs

As we know, three duplicate ACKs are interpreted as a NACK

Both timeouts and NACKs signal a loss, but they say differentthings about the status of the network

A timeout indicates congestion

c© 2005–2008 Antonio Carzaniga

Page 483: 20080426 networking carzaniga_lecture01-02

Timeouts vs. NACKs

As we know, three duplicate ACKs are interpreted as a NACK

Both timeouts and NACKs signal a loss, but they say differentthings about the status of the network

A timeout indicates congestion

Three (duplicate) ACKs suggest that the network is still able todeliver segments along that path

c© 2005–2008 Antonio Carzaniga

Page 484: 20080426 networking carzaniga_lecture01-02

Timeouts vs. NACKs

As we know, three duplicate ACKs are interpreted as a NACK

Both timeouts and NACKs signal a loss, but they say differentthings about the status of the network

A timeout indicates congestion

Three (duplicate) ACKs suggest that the network is still able todeliver segments along that path

So, TCP reacts differently to a timeout and to a triple duplicateACKs

c© 2005–2008 Antonio Carzaniga

Page 485: 20080426 networking carzaniga_lecture01-02

Timeouts vs. NACKs

Assuming the current window size is W = W

c© 2005–2008 Antonio Carzaniga

Page 486: 20080426 networking carzaniga_lecture01-02

Timeouts vs. NACKs

Assuming the current window size is W = W

Timeout

◮ go back to W = MSS

◮ run slow start until W reaches W/2

◮ then proceed with congestion avoidance

c© 2005–2008 Antonio Carzaniga

Page 487: 20080426 networking carzaniga_lecture01-02

Timeouts vs. NACKs

Assuming the current window size is W = W

Timeout

◮ go back to W = MSS

◮ run slow start until W reaches W/2

◮ then proceed with congestion avoidance

NACK

◮ cut W in half: W = W/2

◮ run congestion avoidance, ramping up W linearly

◮ This is called fast recovery

c© 2005–2008 Antonio Carzaniga

Page 488: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

c© 2005–2008 Antonio Carzaniga

Page 489: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

MSS

c© 2005–2008 Antonio Carzaniga

Page 490: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

MSS

NACK

c© 2005–2008 Antonio Carzaniga

Page 491: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

MSS

NACK

c© 2005–2008 Antonio Carzaniga

Page 492: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

MSS

NACK

timeout

c© 2005–2008 Antonio Carzaniga

Page 493: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

MSS

NACK

timeout

c© 2005–2008 Antonio Carzaniga

Page 494: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

MSS

NACK

timeout

c© 2005–2008 Antonio Carzaniga

Page 495: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

MSS

NACK

timeout

c© 2005–2008 Antonio Carzaniga

Page 496: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

MSS

NACK

timeout

NACK

c© 2005–2008 Antonio Carzaniga

Page 497: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

MSS

NACK

timeout

NACK

NACK

c© 2005–2008 Antonio Carzaniga

Page 498: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

MSS

NACK

timeout

NACK

NACK

c© 2005–2008 Antonio Carzaniga

Page 499: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

MSS

NACK

timeout

NACK

NACK

c© 2005–2008 Antonio Carzaniga

Page 500: 20080426 networking carzaniga_lecture01-02

Sender Behavior

W

Time

MSS

NACK

timeout

NACK

NACK

SS CA SS CA CA CA

SS=slow start CA=congestion avoidance

c© 2005–2008 Antonio Carzaniga


Recommended