+ All Categories
Home > Documents > 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services:...

1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services:...

Date post: 21-Dec-2015
Category:
View: 218 times
Download: 1 times
Share this document with a friend
Popular Tags:
62
1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor Dan Rubenstein Tues 4:10-6:40, Mudd 1127 Course URL: http://www.cs.columbia.edu/~danr/ EE6761
Transcript
Page 1: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

1

Electrical Engineering E6761Computer Communication Networks

Lecture 3Transport Layer Services:

reliability, connection setup, flow control

Professor Dan RubensteinTues 4:10-6:40, Mudd 1127

Course URL: http://www.cs.columbia.edu/~danr/EE6761

Page 2: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

2

Today

PA#2 – due 10/3 HW#0 – solutions on-line (see week2 on materials

pg) HW#1 – changes, questions? Java for PA#2: Yes – all Java-related questions to

Vasillis, please Transport Layer

e2e argument multiplexing / demultiplexing reliability connection setup / teardown flow control Example protocol: TCP congestion control… next time

Page 3: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

3

Policy Refresh…

Collaboration is O.K. on Homework Programming Assignments Project

How much help should you get? so that next time, you could do similar types

of problems on your own How much help should you give?

enough to get the person moving again Who should you help?

anybody who asks you

Page 4: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

4

Transport services and protocols

provide logical communication between apps’ processes running on different hosts

transport protocols run in end systems transfer info between

processes runs on top of the

network layer, which : transfers info between

network components can delay, reorder or

drop packets

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysicalnetwork

data linkphysical

logical end-end transport

Page 5: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

5

What we’ve seen so far (layered perspective)…

application

transport

network

link

physical

Sockets: application interface to transport

layer

IP addressing (CIDR)

MAC addressing, switches, bridges

hubs, repeaters

DNS

Today: part1 of transport layer details

Page 6: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

6

Transport Layer “view” of the network A “pipe” connects every pair of hosts packets sent into the pipe might

come out the other end quickly come out the other end eventually disappear

Host A Host B

X

Page 7: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

7

Transport-layer protocols

Internet transport services: reliable, in-order unicast

delivery (TCP) congestion flow control connection

setup/teardown unreliable (“best-effort”),

unordered unicast or multicast delivery: UDP

services not available: real-time bandwidth guarantees reliable multicast

application

transportnetworkdata linkphysical

application

transportnetworkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysical

networkdata linkphysicalnetwork

data linkphysical

logical end-end transport

Page 8: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

8

e2e argument [see Saltzer, Reed, Clark article]

Philosophy behind Intenet design: Move complex operations to the edges of the network Why? Not all apps may require complex ops, e.g.,

• reliability (audio, video)• security

Also, some functionality difficult to implement in network core

• duplicates suppression• FIFO ordering

ops often repeated at edge anyways as safety check Implications of e2e argument to the Internet: most complex ops should be performed

toward the top of the protocol stack

Page 9: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

9

e2e argument pros and cons

Pros: reduces network complexity – eases

deployment, network recovery reduces redundant checks since app often

provides checks anyways bugs harder to fix

Cons: network less efficient (e.g., hop-to-hop

reliability would reduce b/w reqmts and delivery delays)

more responsibility lies with the application• longer development cycle, frequent bugs

Page 10: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

10

Multiplexing/demultiplexing

segment - unit of data exchanged between transport layer entities

Demultiplexing: delivering received segments to correct app layer processes

applicationtransportnetwork

MP2

applicationtransportnetwork

receiver

HtHnsegment

segment Mapplicationtransportnetwork

P1M

M MP3 P4

segmentheader

application-layerdata

How hosts handle more than one session simultaneously

sender A sender B

Page 11: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

11

Multiplexing/demultiplexing

multiplexing/demultiplexing in the Internet:

based on sender, receiver port numbers, IP addresses source, dest port #s

in each segment recall: well-known

port numbers for specific applications

gathering data from multiple app processes, enveloping data with header (later used for demultiplexing)

source port # dest port #

32 bits

applicationdata

(message)

other header fields

TCP/UDP segment format

Multiplexing:

Page 12: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

12

Multiplexing/demultiplexing: examples

host A server Bsource port: xdest. port: 23

source port:23dest. port: x

port use: simple telnet app(Note how port 23 at server must be

shared whereas port x at host can be reserved)

Web clienthost A

Webserver B

Web clienthost C

Source IP: CDest IP: B

source port: x

dest. port: 80

Source IP: CDest IP: B

source port: y

dest. port: 80

port use: Web server

Source IP: ADest IP: B

source port: x

dest. port: 80

Q: how does the server know which packets go with which process?

Page 13: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

13

UDP: User Datagram Protocol [RFC 768]

“no frills,” “bare bones” Internet transport protocol

“best effort” service, UDP segments may be: lost delivered out of order

to app connectionless:

no handshaking between UDP sender, receiver

each UDP segment handled independently of others

Why is there a UDP? no connection

establishment (which can add delay)

simple: no connection state at sender, receiver

small segment header no congestion control:

UDP can blast away as fast as desired

Page 14: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

14

UDP: more

often used for streaming multimedia apps loss tolerant rate sensitive

other UDP uses (why?): DNS SNMP

reliable transfer over UDP: add reliability at application layer application-specific

error recovery!

source port # dest port #

32 bits

Applicationdata

(message)

UDP segment format

length checksumLength, in

bytes of UDPsegment,including

header

Page 15: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

15

UDP checksum

Sender: treat segment contents

as sequence of 16-bit integers

checksum: addition (1’s complement sum) of segment contents

sender puts checksum value into UDP checksum field

Receiver: compute checksum of

received segment check if computed checksum

equals checksum field value: NO - error detected YES - no error detected.

But maybe errors nonethless? More later ….

Goal: detect “errors” (e.g., flipped bits) in transmitted segment

Page 16: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

16

Reliable data transfer: getting started

sendside

receiveside

rdt_send(): called from above, (e.g., by app.). Passed data to deliver to receiver upper layer

udt_send(): called by rdt,to transfer packet over unreliable channel to

receiver

rdt_rcv(): called when packet arrives on rcv-side of channel

deliver_data(): called by rdt to deliver data to

upper

Page 17: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

17

Reliable data transfer: getting startedWe’ll: incrementally develop sender, receiver

sides of reliable data transfer protocol (rdt) consider only unidirectional data transfer

but control info will flow in both directions!

use finite state machines (FSM) to specify sender, receiver

state1

state2

event causing state transitionactions taken on state transition

state: when in this “state” next state

uniquely determined by next event

eventactions

Page 18: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

18

FSM example

morningin

Brooklyn

train arrivesboard train

A day in the life of Prof. Rubenstein

local @ station && past 42nd St

switch to local

reach 96th Stget off express

on2,3

wait for1,9

on1,9local arrives

switch to localgo home

sleepworkworkwork

@Columbia

Page 19: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

19

Rdt1.0: reliable transfer over a reliable channel

underlying channel perfectly reliable no bit errors no loss of packets

separate FSMs for sender, receiver: sender sends data into underlying channel receiver read data from underlying channel

Page 20: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

20

Rdt2.0: channel with bit errors

underlying channel may flip bits in packet recall: UDP checksum to detect bit errors

the question: how to recover from errors: acknowledgements (ACKs): receiver explicitly tells

sender that pkt received OK negative acknowledgements (NAKs): receiver

explicitly tells sender that pkt had errors sender retransmits pkt on receipt of NAK

new mechanisms in rdt2.0 (beyond rdt1.0): error detection receiver feedback: control msgs (ACK,NAK) rcvr-

>sender

Page 21: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

21

rdt2.0: FSM specification

sender FSM receiver FSM

Page 22: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

22

rdt2.0: in action (no errors)

sender FSM receiver FSM

Page 23: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

23

rdt2.0: in action (error scenario)

sender FSM receiver FSM

Page 24: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

24

rdt2.0 has a fatal flaw!

What happens if ACK/NAK corrupted?

sender doesn’t know what happened at receiver!

can’t just retransmit: possible duplicate

What to do? sender ACKs/NAKs

receiver’s ACK/NAK? What if sender ACK/NAK lost?

retransmit, but this might cause retransmission of correctly received pkt!

Handling duplicates: sender adds sequence

number to each pkt sender retransmits current

pkt if ACK/NAK garbled receiver discards (doesn’t

deliver up) duplicate pkt

Sender sends one packet, then waits for receiver response

stop and wait

Page 25: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

25

rdt2.1: sender, handles garbled ACK/NAKs

Page 26: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

26

rdt2.1: receiver, handles garbled ACK/NAKs

Note: sender & rcvr must agree on initial seqno

Page 27: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

27

rdt2.1: discussion

Sender: seq # added to pkt two seq. #’s (0,1)

will suffice. Why? must check if

received ACK/NAK corrupted

twice as many states state must

“remember” whether “current” pkt has 0 or 1 seq. #

Receiver: must check if

received packet is duplicate state indicates

whether 0 or 1 is expected pkt seq #

note: receiver can not know if its last ACK/NAK received OK at sender

Page 28: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

28

rdt2.2: a NAK-free protocol

same functionality as rdt2.1, using ACKs only

instead of NAK, receiver sends ACK for last pkt received OK receiver must explicitly

include seq # of pkt being ACKed

duplicate ACK at sender results in same action as NAK: retransmit current pkt

senderFSM

!

Page 29: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

29

rdt3.0: channels with errors and loss

New assumption: underlying channel can also lose packets (data or ACKs) checksum, seq. #,

ACKs, retransmissions will be of help, but not enough

Q: how to deal with loss? one possibility: sender

waits until certain data or ACK definitely lost, then retransmits

drawbacks?

Approach: sender waits “reasonable” amount of time for ACK

retransmits if no ACK received in this time

if pkt (or ACK) just delayed (not lost): retransmission will be

duplicate, but use of seq. #’s already handles this

receiver must specify seq # of pkt being ACKed

requires countdown timer

Page 30: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

30

rdt3.0 sender

why not retransmit

pkts at these

events?

Page 31: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

31

rdt3.0 in action

Page 32: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

32

rdt3.0 in action

resend pkt0

Transmitting on those “other” events (2 slides ago)

rcv pkt0(detect

duplicate)send ACK0

causes unneeded retransmission, etc.

would have caused cascade of redundant retransmissions

Page 33: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

33

Performance of rdt3.0

rdt3.0 works, but performance stinks

example: 1 Gbps link, 15 ms e-e prop. delay, 1KB packet:

Ttransmit=8kb/pkt

10**9 b/sec= 8 microsec

Utilization = U = =8 microsec

30.016 msecfraction of time

sender busy sending = 0.00015

1KB pkt every 30 msec -> 33kB/sec thruput over 1 Gbps link network protocol limits use of physical resources!

Host A HostB

15 ms

1 Gbps

Page 34: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

34

Pipelined protocols

Pipelining: sender allows multiple, “in-flight”, yet-to-be-acknowledged pkts range of sequence numbers must be increased buffering at sender and/or receiver

Two generic forms of pipelined protocols: go-Back-N, selective repeat

Page 35: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

35

In-order buffering

Transport layer maintains a per-session buffer pkts possibly placed in buffer out of order (e.g., due

to network loss) pkts are sent up to app (and then removed from

buffer) in order

1 2 4 3 8 6 5 7

App

buffer

time

Page 36: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

36

Go-Back-NSender: k-bit seq # in pkt header “window” of up to N, consecutive unack’ed pkts allowed

Rcvr: ACK(n): ACKs all pkts up to, including seq # n - “cumulative ACK”

may deceive duplicate ACKs (see receiver)

More Sender: timer for each in-flight pkt timeout(n): retransmit pkt n and all higher seq # pkts in window

Page 37: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

37

GBN: receiver extended FSM

sender have N pkts “in transit” roll window past largest ACK on timeout of lowest seqno packet in window, retransmit

current window (and reset timers)receiver simple: ACK-only: always send ACK for correctly-received pkt

with highest in-order seq # may generate duplicate ACKs need only remember expectedseqnum

out-of-order pkt: discard (don’t buffer) -> no receiver buffering! ACK pkt with highest in-order seq #

Page 38: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

38

GBN inaction

Here, N=4

Page 39: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

39

Selective Repeat

receiver individually acknowledges all correctly received pkts buffers pkts, as needed, for eventual in-order

delivery to upper layer

sender only resends pkts for which ACK not received sender maintains timer for each unACKed pkt

sender window N consecutive seq #’s again limits seq #s of sent, unACKed pkts

Page 40: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

40

Selective repeat: sender, receiver windows

Page 41: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

41

Selective repeat

data from above : if next available seq # in

window, send pkt

timeout(n): resend pkt n, restart

timer

ACK(n) in [sendbase,sendbase+N]:

mark pkt n as received if n smallest unACKed

pkt, advance window base to next unACKed seq #

senderpkt n in [rcvbase, rcvbase+N-

1]

send ACK(n) out-of-order: buffer in-order: deliver (also

deliver buffered, in-order pkts), advance window to next not-yet-received pkt

pkt n in [rcvbase-N,rcvbase-1]

ACK(n)

otherwise: ignore

receiver

Page 42: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

42

Selective repeat in action

Page 43: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

43

Selective repeat: dilemma

Example: seq #’s: 0, 1, 2, 3 window size=3

receiver sees no difference in two scenarios!

incorrectly passes duplicate data as new in (a)

Q: what relationship between seq # size and window size?

Page 44: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

44

Go-back-N vs. Selective Repeat

Q: How do bandwidth requirements compare? Let’s do a simple analytical comparison Model:

any packet transmission lost with probability, p ACKs never lost selective repeat:

• sender knows exactly what rcvr needs Go-back-N

• each round, sender transmits block of N pkts• rcvr informs sender of 1st lost pkt• sender sends N pkts starting at 1st point of loss• rcvr dumps any pkts in window after a loss

Page 45: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

45

Selective Repeat Analysis

Each pkt can be “examined” in isolation TSR = # of transmissions of a pkt

P(TSR > i) = pi

E[TSR] = P(TSR=1) + 2 P(TSR=2) + 3P(TSR=3) + …

= P(TSR > 0) + P(TSR > 1) + P(TSR > 2) + P(TSR

> 3) + … = 1 / (1-p) e.g., p = .2, then E[TSR] = 5

Page 46: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

46

Go-Back-N analysis

SN = # pkts arriving prior to loss in window of N

P(SN > i) = (1-p)i+1, 0 ≤ i < N, = 0 for i ≥ N

E[SN] = P(SN > 0) + P(SN > 1) + … + P(SN > N-1)

= ( 1 – p – (1-p)N+1) / p Let SN,j = # of pkts accepted in the jth

transmission

E[TGBN] = avg. # of transmissions of pkt m

N j=1

m

( N) / m j=1

m

( SN,j) / m j=1

= =m

(SN,j) j=1

Page 47: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

47

Go-back-N analysis (cont’d)

as m = N / E[SN]

E[TGBN] =

How does E[TSR] compare with E[TGBN]

Np

1 – p - (1-p)N+1

Page 48: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

48

Go-Back-N vs. Selective Repeat Using our analysis, for various N, p: how

much more efficient is Selective Repeat vs. Go-Back-N?

Page 49: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

49

TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581

full duplex data: bi-directional data flow

in same connection MSS: maximum

segment size

connection-oriented: handshaking (exchange

of control msgs) init’s sender, receiver state before data exchange

flow controlled: sender will not

overwhelm receiver

point-to-point: one sender, one

receiver

reliable, in-order byte steam: no “message

boundaries”

pipelined: TCP congestion and flow

control set window size

send & receive bufferssocketdoor

T C Psend buffer

T C Preceive buffer

socketdoor

segm ent

applicationwrites data

applicationreads data

Page 50: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

50

TCP segment structure

source port # dest port #

32 bits

applicationdata

(variable length)

sequence number

acknowledgement numberrcvr window size

ptr urgent datachecksum

FSRPAUheadlen

notused

Options (variable length)

URG: urgent data (generally not used)

ACK: ACK #valid

PSH: push data now(generally not used)

RST, SYN, FIN:connection estab(setup, teardown

commands)

# bytes rcvr willingto accept

countingby bytes of data(not segments!)

Internetchecksum

(as in UDP)

Page 51: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

51

TCP seq. #’s and ACKsSeq. #’s:

byte stream “number” of first byte in segment’s data

ACKs: seq # of next byte

expected from other side

cumulative ACKQ: how receiver handles

out-of-order segments A: TCP spec

doesn’t say, - up to implementor

Host A Host B

Seq=42, ACK=79, data = ‘C’

Seq=79, ACK=43, data = ‘C’

Seq=43, ACK=80

Usertypes

‘C’

host ACKsreceipt

of echoed‘C’

host ACKsreceipt of

‘C’, echoesback ‘C’

timesimple telnet scenario

Page 52: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

52

TCP: reliable data transfer

simplified sender, assuming

waitfor

event

waitfor

event

event: data received from application above

event: timer timeout for segment with seq # y

event: ACK received,with ACK # y

create, send segment

retransmit segment

ACK processing

•one way data transfer•no flow, congestion control

Page 53: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

53

TCP: reliable data transfer

00 sendbase = initial_sequence number 01 nextseqnum = initial_sequence number 0203 loop (forever) { 04 switch(event) 05 event: data received from application above 06 create TCP segment with sequence number nextseqnum 07 start timer for segment nextseqnum 08 pass segment to IP 09 nextseqnum = nextseqnum + length(data) 10 event: timer timeout for segment with sequence number y 11 retransmit segment with sequence number y 12 compute new timeout interval for segment y 13 restart timer for sequence number y 14 event: ACK received, with ACK field value of y 15 if (y > sendbase) { /* cumulative ACK of all data up to y */ 16 cancel all timers for segments with sequence numbers < y 17 sendbase = y 18 } 19 else { /* a duplicate ACK for already ACKed segment */ 20 increment number of duplicate ACKs received for y 21 if (number of duplicate ACKS received for y == 3) { 22 /* TCP fast retransmit */ 23 resend segment with sequence number y 24 restart timer for segment y 25 } 26 } /* end of loop forever */

SimplifiedTCPsender

Similar to GBN,but some slightdifferences…

Page 54: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

54

TCP ACK generation [RFC 1122, RFC 2581]

Event

in-order segment arrival, no gaps,everything else already ACKed

in-order segment arrival, no gaps,one delayed ACK pending

out-of-order segment arrivalhigher-than-expect seq. #gap detected

arrival of segment that partially or completely fills gap

TCP Receiver action

delayed ACK. Wait up to 500msfor next segment. If no next segment,send ACK

immediately send singlecumulative ACK

send duplicate ACK, indicating seq. #of next expected byte

immediate ACK if segment startsat lower end of gap

Page 55: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

55

TCP: retransmission scenarios

Host A

Seq=92, 8 bytes data

ACK=100

loss

tim

eout

time lost ACK scenario

Host B

X

Seq=92, 8 bytes data

ACK=100

Host A

Seq=100, 20 bytes data

ACK=100

Seq=

92

tim

eout

time premature timeout,cumulative ACKs

Host B

Seq=92, 8 bytes data

ACK=120

Seq=92, 8 bytes data

Seq=

10

0 t

imeou

t

ACK=120

Page 56: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

56

TCP Flow Controlreceiver: explicitly

informs sender of (dynamically changing) amount of free buffer space RcvWindow field

in TCP segmentsender: keeps the

amount of transmitted, unACKed data less than most recently received RcvWindow

sender won’t overrun

receiver’s buffers bytransmitting too

much, too fast

flow control

receiver buffering

RcvBuffer = size or TCP Receive Buffer

RcvWindow = amount of spare room in Buffer

Page 57: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

57

TCP Round Trip Time and TimeoutQ: how to set TCP

timeout value? longer than RTT

note: RTT will vary too short: premature

timeout unnecessary

retransmissions too long: slow

reaction to segment loss

Q: how to estimate RTT? SampleRTT: measured time

from segment transmission until ACK receipt ignore retransmissions,

cumulatively ACKed segments

SampleRTT will vary, want estimated RTT “smoother” use several recent

measurements, not just current SampleRTT

Page 58: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

58

TCP Round Trip Time and TimeoutEstimatedRTT = (1-x)*EstimatedRTT + x*SampleRTT

Exponential weighted moving average influence of given sample decreases exponentially fast typical value of x: 0.1

Setting the timeout EstimtedRTT plus “safety margin” large variation in EstimatedRTT -> larger safety margin

Timeout = EstimatedRTT + 4*Deviation

Deviation = (1-x)*Deviation + x*|SampleRTT-EstimatedRTT|

Page 59: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

59

TCP Connection Management

Recall: TCP sender, receiver establish “connection” before exchanging data segments

initialize TCP variables: seq. #s buffers, flow control

info (e.g. RcvWindow) client: connection initiator Socket clientSocket = new

Socket("hostname","port

number"); server: contacted by client Socket connectionSocket =

welcomeSocket.accept();

Three way handshake:

Step 1: client end system sends TCP SYN control segment to server specifies initial seq #

Step 2: server end system receives SYN, replies with SYNACK control segment

ACKs received SYN allocates buffers specifies server->

receiver initial seq. #Initial seqnos in both directions chosen randomly. Why?

Page 60: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

60

TCP Connection Management (cont.)

Closing a connection:

client closes socket: clientSocket.close();

Step 1: client end system sends TCP FIN control segment to server

Step 2: server receives FIN, replies with ACK. Closes connection, sends FIN.

client

FIN

server

ACK

ACK

FIN

close

close

closed

tim

ed w

ait

Page 61: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

61

TCP Connection Management (cont.)

Step 3: client receives FIN, replies with ACK.

Enters “timed wait” - will respond with ACK to received FINs

Step 4: server, receives ACK. Connection closed.

Note: with small modification, can handle simultaneous FINs.

client

FIN

server

ACK

ACK

FIN

closing

closing

closed

tim

ed w

ait

closed

Page 62: 1 Electrical Engineering E6761 Computer Communication Networks Lecture 3 Transport Layer Services: reliability, connection setup, flow control Professor.

62

TCP Connection Management (cont)

TCP clientlifecycle

TCP serverlifecycle


Recommended