CMPE 252A: Computer Networks SET 5:

75
1 CMPE 252A: Computer Networks SET 5: Link Control Protocols

description

CMPE 252A: Computer Networks SET 5:. Link Control Protocols. Internet Example. HOST. P. R. link-level frames exchanged among link interfaces. Logical Link Control. MAC protocol provides best effort service. - PowerPoint PPT Presentation

Transcript of CMPE 252A: Computer Networks SET 5:

Page 1: CMPE 252A: Computer Networks SET 5:

1

CMPE 252A: Computer Networks

SET 5:

Link Control Protocols

Page 2: CMPE 252A: Computer Networks SET 5:

2

Internet Example

R

P

HOST

link-level frames exchanged among link interfaces

Page 3: CMPE 252A: Computer Networks SET 5:

3

Logical Link Control

MAC protocol provides best effort service.

LLC bridges the gap between service expected by network layer and service provided by MAC layer.

LLC uses the header information in MAC frames if LLC runs over a multiple access link.

Page 4: CMPE 252A: Computer Networks SET 5:

4

Functions at The Link Layer:Point-to-Point Link

Framing and synchronization Distinguish each frame

Error checking Detect or correct errors incurred over link

Retransmission strategy Link management

Deciding when a link exists or does not Flow control

Pace the sender to avoid congestion at receiver No need to name sender and receiver

Page 5: CMPE 252A: Computer Networks SET 5:

5

Functions at The Link Layer:Multiple Access Link

MAC: Framing and synchronization Error checking Naming within LANs (with MAC addresses) Sharing of medium Flow control (in some cases)

LLC: Retransmission strategy Link management (deciding when a link exists or does not) Flow control (in some cases)

Page 6: CMPE 252A: Computer Networks SET 5:

6

Types of Service LLC Can Provide

Unacknowledged connectionless service: Datagram transmission, no connection exists, no error checking, framing is the only service provided (e.g., SLIP).

Acknowledged connectionless service: No connections, each frame is ACKed individually. This service can be provided as part of the MAC itself

(e.g., IEEE 802.11) Connection-Oriented Service: Data exchanged

within a connection, provides net layer with a virtual reliable packet stream (e.g., HDLC, PPP)

Page 7: CMPE 252A: Computer Networks SET 5:

7

Framing of Bits Physical layer provides raw stream of bits to the link

layer. The objective is for the receiver to understand the

packets (frames) sent by the sender when bits may get corrupted over the channel.

Some approaches: Character count, not used because it does not

work well with transmission errors. Character- or byte-oriented framing (e.g., BISYNC,

IMP-IMP, SLIP, and PPP) Bit-oriented framing: HDLC Physical-layer coding violations: Used when

encoding on the PHY contains redundancy. Example: Data 1 = 10, and Data 0 = 01; then frame

control can be a sequence of “11 and 00”

Page 8: CMPE 252A: Computer Networks SET 5:

8

Character-Oriented Framing A frame starts and ends with a predefined sequence of control

bytes or characters, and the occurrence of such sequence in the packet payload is avoided by byte stuffing.

Consider the ARPANET IMP-IMP protocol:

SY

N

DLE

STX packet payload (header and data)

CR

C

CR

C

CR

C

ETX

DLE

SY

N

SYN = synchronizationDLE = data link escapeSTX = packet start

Character stuffing:If DLE occurs in packet data, sender substitutes DLE with DLE DLEReceiver substitutes DLE DLE in packet payload with DLE In PPP, flag is 01111110 and such pattern in payload is preceded by 01111101

Page 9: CMPE 252A: Computer Networks SET 5:

9

Bit-Oriented Framing The same procedure is used with bits, bits are stuffed to break the occurrence of control flags. Bit stuffing consists of adding a bit after the occurrence of a bit pattern equal to the control flag used to frame the packet. Assume the control flag is 01111110 If flag pattern occurs in payload, sender must transmit something different and receiver must be able to get original data. HOW?...Sender inserts a 0 after 5 1’s, and receiver deletes any 0 received after five 1’s in a bit sequence, and the frame is

ended if after 5 1’s “10” is detected.

01111110 01111110

flag flag

…..101101010011111010 110001011111010011….

payload with bit stuffing

Receiver then deletes stuffed 0 in any sequence ...1111101 and obtains original data: …..1011010100111111011000101111110011….

…..1011010100111111011000101111110011….Original data:

Page 10: CMPE 252A: Computer Networks SET 5:

10

Error Control

Majority of protocols use error detection coding because it requires fewer overhead bits than error correction coding.

However, error detection is effective only if the bandwidth-delay product of the link is small, i.e., if feedback regarding errors in received packets can be given quickly to the sender, before it sends too many bits.

Error detection code used by almost all networks is the cyclic redundancy code (CRC)

Page 11: CMPE 252A: Computer Networks SET 5:

11

CRC CRC codes detect errors by adding a few bits (redundancy bits

or CRC bits) to each packet. The attractive features of CRC are that only a few redundancy

bits are needed to protect many bits of information, and it can be implemented with very simple hardware.

A message of m bits is transmitted with r redundancy bits as a transmitted string T = M.R

With the message bits being the most significant bits transmitted, and given that R occupies r bit positions, we have

RMT r +⋅≡ 2 M R

r+m-1 r r-1 0 bits

Page 12: CMPE 252A: Computer Networks SET 5:

12

CRC The procedure to choose R to protect M is

remarkably simple. A string G of r+1 bits called the generator is agreed

upon. R is chosen so that T = A xG for some A => If the received string T’ is not a multiple

of G, then an error has been detected! T’ equals the (modulo 2) addition of T and an

error pattern E, such that a 0 in the pattern indicates no error in that bit position.

Now we have:

ER2'

2

e, therefor;2

++⋅≡

+×=⋅

×=+⋅≡

r

r

r

MTalso

RGAM

GARMTR is the remainder of dividing by G theshifted M

Page 13: CMPE 252A: Computer Networks SET 5:

13

CRC Therefore, to protect M, the sender:

Computes R by dividing M (shifted r bit positions) by G

Transmits M followed by R When the receiver obtains T’ :

It divides T’ by G Decides that there is an error if the remainder

of the division is not 0 The trick is then choosing a G for which the

likelihood that T’ contains an error string E that is divisible by G is very small.

Page 14: CMPE 252A: Computer Networks SET 5:

14

CRC The choice of G is done such that:

First and last bit of G are 1: This ensures that all single bit errors are detected.

G is a factor of (x+1): To detect any odd number of errors.

G has a factor with at least three terms: To detect double-bit errors.

Code detects all burst of errors with fewer than r bits and most other burst errors.

e.g., Ethernet uses “CRC-32”

Page 15: CMPE 252A: Computer Networks SET 5:

15

Functions at The Link Layer MAC:

Framing Error checking Naming within LANs (with MAC addresses) Sharing of medium Flow control (in some cases)

LLC: Retransmission strategy Link management (deciding when a link exists or does not) Flow control (in some cases)

Page 16: CMPE 252A: Computer Networks SET 5:

16

Retransmission Strategies Called Automatic Repeat Request (ARQ)

algorithms or protocols. Design Issues:

How does a receiver ask for a retransmission? How does the sender know when to retransmit? How are packets associated with requests for

retransmissions? Performance and correctness. We will assume point-to-point links for

simplicity.

Page 17: CMPE 252A: Computer Networks SET 5:

17

ARQ Assumptions

The protocol operates at the link layer.

One sender and one receiver. Links and nodes behave in FIFO order. Nodes execute ARQ protocol correctly. Session between sender and receiver

is already initialized and is permanent. All errors are detected correctly and

framing is done perfectly.

Page 18: CMPE 252A: Computer Networks SET 5:

18

Generic ARQ Scheme in FIFO Channels

SENDER INITIATED

SENDER RECEIVERSEQ. # CRC

PACKET

ACK

TIMEOUT

retransmitif no ACK

acknowledge packetif no errors

time time

Page 19: CMPE 252A: Computer Networks SET 5:

19

Generic ARQ SchemeRECEIVER INITIATED

SENDER RECEIVER

SEQ. # CRC

PACKET

ACK/POLL

TIMEOUT

retransmitif asked

acknowledge packet if no errors; poll

time time

POLL

Page 20: CMPE 252A: Computer Networks SET 5:

20

Requirements in ARQ Sender labels each packet it sends using a

linear sequence-number space. Receiver ACKs each packet it receives

without errors and numbers each ACK with the sequence number of the corresponding packet.

Sender times out after not receiving an ACK for the packet within some finite amount of time, and retransmits the packet then.

Sender sends up to a certain number on un-ACKed packets.

Page 21: CMPE 252A: Computer Networks SET 5:

21

Stop-and-Wait ARQ Sender transmits packets labeled 1, 2,….. Receiver ACKs every packet received

correctly and ACK specified the packet being acknowledged (or next expected packet).

Receiver passes copy of packet correctly received to the network layer and drops packets with errors.

Sender retransmits copy of packet if no ACK arrives within a timeout interval.

Sender and receiver are initialized to start sending and receiving packet 1.

Page 22: CMPE 252A: Computer Networks SET 5:

22

Stop-and-Wait Protocol (SWP)

Sender’s algorithm:1. Initialize packet number (PN) to 0 [or1 for

example].2. Wait until packet is received from network layer;

assign PN to packet.3. Transmit (or retransmit) packet in frame with PN

as its sequence number.4. Start timeout timer and wait for ACK from receiver.5. If error-free ACK specifying PN is received within

timeout interval then set PN = PN+1 and repeat Step 2.

else repeat Step 3

Page 23: CMPE 252A: Computer Networks SET 5:

23

Stop-and-Wait Protocol

Receiver’s algorithm:1. Initialize next packet (NP) to 0 [or 1 for example]

and repeat Step 2 forever2. If ( packet is received ) then

if (error in packet) then discard packet else do

if ( PN=NP ) then give packet to network layer and

set NP = NP+1 send ACK containing PN (or NP)

Page 24: CMPE 252A: Computer Networks SET 5:

24

Efficiency of SWP

Consider the case in which no errors occur.

timeSENDER

RECEIVER

PACKET

P

τ Q

ACK

A τ

S=minimum time between successive packet transmissions

Q

Processing delay

Page 25: CMPE 252A: Computer Networks SET 5:

25

Efficiency of SWP

From the diagram we have: )(2 τ+++= QAPSHowever, packets and ACKs may be lost or corrupted in the channel and it takes much longer to send a packet successfully.

timeSENDER

RECEIVER

X = total time to transmit a packet and its ACK correctly

x

timeout timeout

ACK

X

processing ACKprocessing

processing

S

Page 26: CMPE 252A: Computer Networks SET 5:

26

Efficiency of SWP Let p be the probability that a packet or its ACK is

not sent correctly over the link. This implicitly assumes that each attempt to

succeed sending a packet is independent of others. We have again the geometric random variable! The number of transmissions needed for success is

of course 1/(1-p). All the failed transmissions incur one timeout of

time, and all of these occur with probability p. The last transmission incurs S seconds and occurs

with probability 1-p.

Page 27: CMPE 252A: Computer Networks SET 5:

27

Efficiency of SWP We can apply a simple graphical method.

start end

no transmission error

S, 1-p

errorT, p

T = timeoutS = P+A+2Q+2τ

p

pTSXE

XETpSpXE

−+=

++−=

1}{

}){()1(}{

Efficiency = η =packet time

E{X}=

P

E{X} pTSp

Pp

+−−

=)1(

)1(η

0 ;)2)(1(

)1(=

+++−−

≈ QpTAPp

Ppτ

ηToo much overhead over noisy links or links with large b-d products!

Page 28: CMPE 252A: Computer Networks SET 5:

28

Selective Repeat ARQ Motivation: SWP leaves sender idle for long periods of

time waiting for ACKs. Solution: Allow sender to transmit multiple packets while

waiting for the ACK of a given packet. Requirements:

Sender and receiver can buffer a number (W ) of packets Sender labels packets using consecutive numbers 1, 2,…. Receiver buffers packets received without error, ACKs them, and

delivers packets to network layer in the correct order(e.g., if packet P1 is in error and P2 and P3 are received correctly, the receiver buffers them until it receives P1 correctly)

Sender buffers copies of transmitted packet until it receives the corresponding ACK.

Sender retransmits a packet when its timeout expires with no ACK. ACK refers to the sequence number of the packet it acknowledges.

Page 29: CMPE 252A: Computer Networks SET 5:

29

4

How Many Packets Allowed in Sender’s Buffer?

Assume we allow a maximum of W=4 in buffer

time

S

R

1

timeout

X1

1

2

1

2

3

2 2

3

3

1

2

3

4

2

3

4

4

3

4

1

3

4

1

X1

3

4

1

5

2

3

5

4

5

6

4

1

5

3

2

3

6

4

56 overflows buffer!

6

1

5

and sender cankeep transmittingnew packets!

Page 30: CMPE 252A: Computer Networks SET 5:

30

Solution To Buffer Overflow Sender can transmit a new packet if the difference in

smallest and largest seq. # in buffer is smaller than W!

4time

S

R

1

timeout

X1

1

2

1

2

3

2 2

3

3

1

2

3

4

2

3

4

4

3

4

1

3

4

1

X

1

4

1

3

1

timeout

1

5

transmit 1 until ACK is received

2

3

4

1

1

timeout

1

5

ASSUME W=4

2 2

Page 31: CMPE 252A: Computer Networks SET 5:

31

Efficiency of SRP Consider the case in which no errors occur.

SPWwith

AQPS

<×+++=

)(2 τ

timeSENDER

RECEIVER

PACKET

P

τQ

ACK

A

τ

S = minimum time for packet to be ACKed

PACKET PACKET PACKET

W P

ACK ACK ACK

ACKQ

Note the implicit full duplex operation!

Page 32: CMPE 252A: Computer Networks SET 5:

32

Efficiency of SRP

Efficiency of SRP:⎭⎬⎫

⎩⎨⎧= 1,minS

WPSRPη

PACKET

P

PACKET PACKET PACKET

W P

S

With no errors,sender never stops with S < WP

Assume infinite W and T > S, so that sender never retransmits if there are no errors.p =P{ transmission error in packet or its ACK} Y= number of times packet is transmitted

pYE

−=11

)(Y is the Geometric r.v.; therefore,

Page 33: CMPE 252A: Computer Networks SET 5:

33

Efficiency of SRP We can also use the graphical method, of course… We focus on the number of transmissions, because all

transmissions last the same time.

start end

no transmission error

1, 1-p

error1, p

expected! as ,1

1}{

}){1()1(}{

pYE

YEppYE

−=

++−=

Efficiency = ηSRP =packet time

E{X}=

P

E{X}

∞=−=−

= WppP

PSRP for 1

)1/(η

Let E(X ) be the average time taken to transmit a packet, then E(X)=P E(Y)

Very high efficiency as long as window is longer than S !

Page 34: CMPE 252A: Computer Networks SET 5:

34

Correctness of SRP What to prove:

Finite sequence number space: What is the minimum sequence number space we can use so that sender and receiver never get confused with sequence numbers in ACKs and packets.

Safety: Receiver passes packets to the network layer in sequence, without gaps or replicas.

Liveness: Deadlocks never occur.

Page 35: CMPE 252A: Computer Networks SET 5:

35

Sequence Numbering in SRPAssume W=4 and sequence numbers are 0 to 4.

time S

R

PKT 1 PKT 2 PKT 3 PKT 4 PKT 5 PKT 6 PKT 7 PKT 8

ACK ACK ACK ACKACK ACK ACK ACK

0 1 2 3

0 1 2 3

sender waits for ACK to pkt 1

4 0 1 2

4 0 1 2

4 0 1 2

S# 0 1 2 3

receiver associates 0 with packet 6… should it?

all packets are passed

to network layer

Page 36: CMPE 252A: Computer Networks SET 5:

36

Sequence Numbering in SRPHowever, not all packets are successful

time S

R

PKT 1 PKT 2 PKT 3 PKT 4

0 1 2 3

sender waits for ACK to pkt 1

PKT 1

0

0

S# 0 1 2 3

0

ACK

receiver should associate0 to pkt 1 and NOT pass it to networklayer (sending ACK)

timeout for packet 1

all packets are passed

to network layer

ACK ACK ACK ACK

0 1 2 3

Page 37: CMPE 252A: Computer Networks SET 5:

37

Sequence Numbering in SRP…and many cases are possible!

time S

R

PKT 1 PKT 2 PKT 3 PKT 4

0 1 2 3

sender waits for ACK to pkt 1

S# 0 1 2 3

0

ACK

receiver should associate 0 to packet 6!Store it in buffer and sendACK

timeout for packet 1

all packets are passed

to network layerNote that S could have sent packets 5 and 6!

PKT 5 PKT 6

4 0

0

4

ACK ACK ACK ACK

0 1 2 3

Page 38: CMPE 252A: Computer Networks SET 5:

38

Sequence Numbering in SRP

time S

R

PKT 1 PKT 2 PKT 3 PKT 4

0 1 2 3

sender waits for ACK to pkt 1

S# 0 1 2 3

0

ACK

What should the receiver do?Association of packet to a seq. number is compromised.

timeout for packet 1

all packets are passed

to network layerWhich case took place?

PKT 5 PKT 6

4 0

0

4

ACK ACK ACK ACK

0 1 2 3PKT 1

0

0

Page 39: CMPE 252A: Computer Networks SET 5:

39

Sequence Numbering in SRPHowever, receiver can get confused!

time S

R

PKT 1 PKT 2 PKT 3 PKT 4

0 1 2 3

sender waits for ACK to pkt 1

PKT 1

0

0

S# 0 1 2 3

0

ACK

receiver does notknow if 0 correspondsto replica of packet 1 or packet 6!PASS TO NETWORK LAYER???

timeout for packet 1

all packets are passed

to network layerNote that S could have sent packets 5 and 6!

PKT 5 PKT 6

4 0

0

X4

Page 40: CMPE 252A: Computer Networks SET 5:

40

Sequence Numbering in SRP Is modulo 2W sufficient to identify any packet on the fly

or stored? Assume that window is W and packets are numbered modulo

2W (from 0 to 2W -1) Assume that, at time T, packet labeled n is passed to network

layer at the receiver, and is the packet with the highest number that can be passed to net layer!

time

T

R

n

=> n+1 has not been received!(o.w., it would have been sent to network layer)=> ACK(n+1) has not been sent to sender

sender sent packet n <==> sender received all ACKs up to ACK(n-W), because window is W

=> Largest sequence number sent by sender is n+W

=> Smallest sequence number pending an ACK at the sender is n-W+1

Given n, the possible range of sequence numbers of packets at the sender is {n-W+1, n+W} and using modulo 2W sequence number space works correctly

Page 41: CMPE 252A: Computer Networks SET 5:

41

Sequence Numbering in SRP The same type of argument can be

made for the receiver, assuming that the sender receives the ACK for packet n for the first time at time T.

HW: Left to the student to show that using a

sequence number space modulo 2W does not confuse the receiver!

Show the same for SWP! W = 1

Page 42: CMPE 252A: Computer Networks SET 5:

42

Safety Proof for SRP By induction on sequence number PN of a packet. Prove for the first packet:

S and R are initialized with PN =NP = 0. First packet sent by S is numbered 0. S must retransmit packet with PN = 0, until it receives an

ACK with NP > 0 or NP = 0 from R. While packet numbered 0 is not ACKed, S can only send

packets numbered up to PN = W - 1 to R due to window-size.

Due to buffering policy, R must have buffer space to receive packet 0 and passes it to network layer in sequence when it is received correctly for the first time.

R does not pass packet 0 to the network layer a second time.

Therefore, SRP is safe for packet 0!

Page 43: CMPE 252A: Computer Networks SET 5:

43

Safety Proof for SRP Assume that SRP is safe for PN = n-1 and

prove for PN = n: Because R has received packet n - 1, it has set NP = n R can only accept a packet with PN =NP to be passed

to the network layer, which can be done together with a set of other packets whose sequence numbers are in sequence.

When the first error-free copy of packet with PN = n arrives, R passes it to network layer in sequence and increases NP. No replica of the same packet is given to the network layer and no missing packets exist from 0 to n; therefore, SRP is safe.

Q.E.D.

Page 44: CMPE 252A: Computer Networks SET 5:

44

Liveness Proof for SRP The trick is to identify key events in time ensuring that the protocol never deadlocks. In an ARQ protocol, the key events can be stated with respect to a given packet numbered n:

The first transmission from S of packet with PN = n occurs at time t1 The first time that R receives an error-free transmission of a packet with any PN < or = n that makes

the packet with PN = n be in sequence occurs at t2 S receives an error-free transmission of an ACK reporting NP = or > n+1 at t3

Page 45: CMPE 252A: Computer Networks SET 5:

45

Liveness Proof of SRP

timeSENDER

RECEIVER

PN=i

Set of packets in sequence includingpacket with PN = i is passed to networklayer

t1

ACK

PN ≤ i

NP > or = i +1

t2

t3

NP > i

ACK

∞<] ,[ IF DEADLOCKS NO 31 tt

HSNi SSN

missing missing

Page 46: CMPE 252A: Computer Networks SET 5:

46

Liveness of SRPBy definition of SRP, NP(t) and PN(t) are non-decreasing functions of t

Because the channel has a finite propagation delay and t1 is the first time when S releases a packet with PN = i, given that SRP is safe, it is impossible for R to release a packet with PN = i before or at t1; therefore, t2 > t1

Because the probability that any packet and its ACK goes through the channel correctly is > 0, it follows that [t1, t2] is finite.

Because R releases the first ACK with NP ≥ i at time t2 and because the channel has a positive propagation delay, it must be true that t3 > t2

Because the probability of receiving an ACK with an NP covering a packet with PN < NP is non-zero, it follows that [t2, t3] is finite.

Q.E.D.

Page 47: CMPE 252A: Computer Networks SET 5:

47

Go-Back-N (GBN) ARQ SRP requires sender and receiver to have a buffer,

which is not an issue today. With GBN, the receiver discards any packet it receives

out of order; therefore, it does not need a buffer. Receiver accepts only those packets received in order. Receiver ACKs a packet received correctly with the

sequence number of the last packet received in sequence.

The sender starts a timer for each packet it transmits, and after the timeout of a packet expires, it retransmits the packet and all the packets sent after that packet.

Sender can have up to W packets waiting for ACKs.

Page 48: CMPE 252A: Computer Networks SET 5:

48

GBN ARQ Example 1

time S

R

P

PKT 1

Timeout for pkt 1 (T )

τ

PKT 2 PKT 3 PKT 4

ACK

1

PKT 5

Packet 1 is received correctly; receiver sends ACK

ACK to pkt 1 arrives before its timeout expires; sender can send packet 5.

Sender is able to transmit four packets before timeout for pkt 1 expires

Page 49: CMPE 252A: Computer Networks SET 5:

49

GBN ARQ Example 1

time S

R

PKT 1

timeout for pkt 2 (T )

τ

PKT 2 PKT 3 PKT 4

ACK

1

PKT 5

Packets 2 to 4 arrive in order at the receiver; receiver sends ACKs for them (asking for packet 5)

ACK to pkt 2 arrives before its timeout expires; sender can send packet 6.

ACK ACK ACK

2

PKT 6

Page 50: CMPE 252A: Computer Networks SET 5:

50

GBN ARQ Example 1

time S

R

PKT 1

timeout for pkt 3 (T )

τ

PKT 2 PKT 3 PKT 4

ACK

1

PKT 5

ACK to pkt 3 arrives before its timeout expires; sender can send packet 7.

ACK ACK ACK

2

PKT 6

3

PKT 7

Page 51: CMPE 252A: Computer Networks SET 5:

51

GBN ARQ Example 1

time S

R

PKT 1

timeout for pkt 4 (T )

τ

PKT 2 PKT 3 PKT 4

ACK

1

PKT 5

ACK to packet 4 arrives before its timeout expires; sender can send packet 8, etc.

ACK ACK ACK

2

PKT 6

3

PKT 7

4

PKT 8

Page 52: CMPE 252A: Computer Networks SET 5:

52

GBN ARQ Example 2

time S

R

P

PKT 1

timeout (T )

τ

PKT 2 PKT 3 PKT 4

ACK ACK ACKACK

X

all packets are delivered to

network layer but sender does not

know!

PKT 1 PKT 2 PKT 3 PKT 4

packets 1 to W-1 must be retransmitted

2 3 4

ACK to packet 2 arrives after timeout;sender schedules packets 1 to 4 for

retransmission!

Page 53: CMPE 252A: Computer Networks SET 5:

53

GBN ARQ Example 2

time S

R

P

PKT 1

timeout (T )

τ

PKT 2 PKT 3 PKT 4

ACK ACK ACK ACK

X

all packets are delivered to

network layer but sender does not

know!

PKT 1 PKT 2 PKT 3 PKT 4

packets 1 to W-1 must be retransmitted

ACK ACK ACK ACK

all packets are discarded

(out of order)

4 4 4 4

PKT 5

Sender can finally send packet 5

S

Note that receiverkeeps sending

a 4 as the last packetreceived in sequence

Page 54: CMPE 252A: Computer Networks SET 5:

54

GBN ARQ Example 3

time S

R

P

PKT 1

timeout (T )

τ

PKT 2 PKT 3 PKT 4

ACK ACK ACK

X

No packet can be delivered to network

layer! They are discarded.

Receiver keeps asking for packet 1

PKT 1 PKT 2 PKT 3 PKT 4

packets 1 to W-1 must be retransmitted

1 1 1

ACK to packet 2 arrives after timeout;sender already scheduled packets 1 to 4

for retransmission!

Page 55: CMPE 252A: Computer Networks SET 5:

55

GBN ARQ Example 3

time S

R

P

PKT 1

timeout (T )

τ

PKT 2 PKT 3 PKT 4

ACK ACK ACK

X

No packet can be delivered to network layer!

They are discarded. Receiver keeps asking for

packet 1

PKT 1 PKT 2 PKT 3 PKT 4

packets 1 to W-1 must be retransmitted

1 1 1

ACK ACK ACK ACK

all packets are received in order

and passed to network layer.

2 3 4 5

Receiver states the last packet

received in sequence

PKT 5

Sender can finally send packet 5

Page 56: CMPE 252A: Computer Networks SET 5:

56

Efficiency of GBN A packet that is not ACKed wastes a timeout (T ) To simplify our analysis, assume T= S = W x P We compute the average time needed for the sender to get

the ACK to a given packet n and advance window to n+1

n n+1

no transmission error

P, 1-p

errorT, p

⎟⎟⎠

⎞⎜⎜⎝

⎛−

+=−

+=

++−=

p

pWP

p

pTPXE

XETpPpXE

11

1}{

}){()1(}{

}{}{

XE

P

XE

timepacketEfficiency ==

11

1

⎟⎟⎠

⎞⎜⎜⎝

⎛−

+=

ppWGBNη

Page 57: CMPE 252A: Computer Networks SET 5:

57

Effect of Negative ACKs We have assumed that packets are

retransmitted after a timeout. Using negative acknowledgments (NACKs), the

receiver tells the sender about missing packets and the sender can retransmit after receiving the NACK. This increases throughput.

NACKs and ACKs can be combined in windows of ACKs:

last pkt in sequence … 0 1 0 1 1

Page 58: CMPE 252A: Computer Networks SET 5:

58

SRP with NACKs

time S

R

P

PKT 1

timeout (T.O. ) for packet 1

1

2,-

ACK

X

2

PKT 2

X

PKT 3

3

ACK

3,-

PKT 4

4

S knows R has received up to packet 2

Page 59: CMPE 252A: Computer Networks SET 5:

59

SRP with NACKs

time S

R

PKT 1

T.O. for packet 3

1

2,-

ACK

X

2

PKT 2

X

PKT 3

3

ACK

3,-

PKT 4

4

ACK

3, (1)

S receives NACK for packet 3 before T.O. expires.

Page 60: CMPE 252A: Computer Networks SET 5:

60

SRP with NACKs

time S

R

PKT 1

T.O. for packet 5

1

2,-

ACK

X

2

PKT 2

X

PKT 3

3

ACK

3,-

PKT 4

4

ACK

3, (1)

5

X

PKT 5

S receives NACK for packet 3 before T.O. expires.

PKT 6

6

PKT 3

3

T.O. for packet 3

Page 61: CMPE 252A: Computer Networks SET 5:

61

SRP with NACKs

time S

R

PKT 1

T.O. for packet 5

1

2,-

ACK

X

2

PKT 2

X

PKT 3

3

ACK

3,-

PKT 4

4

ACK

3, (1)

5

X

PKT 5 PKT 6

6

PKT 3

3

ACK

3, (101)

PKT 7

7

ACK

5,(1)

PKT 5

5

T.O. for packet 3

S receives NACK for packet 5 before T.O. expires; should not assume a NACK for packet 3!

A bit vector set for packet k in the ACK packet should not be interpreted as a NACK to packet k if the ACK packet is received during the next packet time after packet k is (re)transmitted.no retransmit after NACK if “S” for packet has not elapsed!

Page 62: CMPE 252A: Computer Networks SET 5:

62

SRP with NACKs

time S

R

PKT 3

3

T.O. for packet 3

“S” for packet 3

Cannot retransmit before it elapses!Must retransmit after it elapses!

NACK

Potential time saved with NACK

Page 63: CMPE 252A: Computer Networks SET 5:

63

SRP with NACKs

time S

R

PKT 1

T.O. for packet 5

1

2,-

ACK

X

2

PKT 2

X

PKT 3

3

ACK

3,-

PKT 4

4

ACK

3, (1)

5

X

PKT 5 PKT 6

6

PKT 3

3

ACK

3, (101)

S receives second NACK for packet 5 before T.O. expires.

PKT 7

7

ACK

5,(1)

PKT 5

5

ACK

5,(11)X

ACK

8,-

PKT 8

Page 64: CMPE 252A: Computer Networks SET 5:

64

GBN with NACKs

time S

R

PKT 1

T.O. for packet 1

1

1

ACK

X

2

PKT 2

X

PKT 3

3

ACK

2

to net layer

to net layer

Page 65: CMPE 252A: Computer Networks SET 5:

65

GBN with NACKs

time S

R

PKT 1

T.O. for packet 3

1

1

ACK

X

2

PKT 2

X

PKT 3

3

ACK

2

PKT 4

4

ACK

No 3

5

X

PKT 5

to net layer

to net layer

drop

X

Page 66: CMPE 252A: Computer Networks SET 5:

66

GBN with NACKs

t S

R

PKT 1

T.O. for packet 3

1

1

ACK

X2

PKT 2

X

PKT 3

3

ACK

2

PKT 4

4

ACK

No 3

5

X

PKT 5

to net layer

to net layer

drop

X

PKT 6

6

drop

X

ACK

No 3

PKT 5 PKT 3 PKT 4 PKT 6

3 4 5 6

to net layer

to net layer

to net layer

to net layer

ACK

3

ACK

4

ACK

5

ACK

6

Not much is gained with NACKs; it all depends on T.O. and S.NACKs must be evaluated at the end of a GBN transmission

Page 67: CMPE 252A: Computer Networks SET 5:

67

Initializing a Link Operation of initialization protocol leads to up

and down periods of the link S and R can have different views of the state

of the link S and R should not accept packets from prior

incarnations of the link. We can have a master-slave or peer-to-peer

protocol, which consists of two M-S protocols. Master sends two types of packets: INIT and

DISC, and must stop for ACKs This is the same as the SWP (ABP) protocol!

Page 68: CMPE 252A: Computer Networks SET 5:

68

Initializing a Link

time S

R

initializing link up

ACKI

INIT DISC

ACKD

disconnecting link down

link up link down

Page 69: CMPE 252A: Computer Networks SET 5:

69

Initialization of ARQ The basic problem is that an initialization protocol

between two parties requires feedback. The simplest scheme is a link-up packet and its

ACK used to set up a link, followed by a link-down packet and its ACK to tear down the link.

This, however, is just the SWP (ABP), which needs to be initialized!

Ad hoc approach: Node starts assuming that link is down, and must wait a

long time period after coming up before it accepts or sends an INIT packet to the link.

In e-t-e protocols (e.g., TCP) the connection is assigned an ID randomly.

Page 70: CMPE 252A: Computer Networks SET 5:

70

Link Control over Non-FIFO Channels

Logical link control is often applied over virtual links running above the link layer (e.g., TCP).

The assumptions we have made about fixed RTTs (or retransmission time outs) and the FIFO operation of the link no longer apply when packets must be sent over networks and take different routes from source to receiver.

A virtual link may be able to store up to a finite number of packets in transit.

Page 71: CMPE 252A: Computer Networks SET 5:

71

RTT Estimation over Non-FIFO Link

SENDER RECEIVERSEQ. # CRC

PACKET

ACK

time time

RTT

ACK specifies seq # of packet

Page 72: CMPE 252A: Computer Networks SET 5:

72

RTT Estimation over Non-FIFO Link

SENDER RECEIVERSEQ. # CRC

PACKET

ACK

time time

RTOX

RTT

Page 73: CMPE 252A: Computer Networks SET 5:

73

RTT Estimation over Non-FIFO Link

SENDER RECEIVERSEQ. # CRC

PACKET

ACK

time time

RTO

RTT?

Page 74: CMPE 252A: Computer Networks SET 5:

74

RTT Estimation over Non-FIFO Link

SENDER RECEIVERSEQ. # CRC

PACKET

ACK

time time

RTO

XRTT

RTT computationis not safe witha single sequencenumber!

Page 75: CMPE 252A: Computer Networks SET 5:

75

RTT Estimation over Non-FIFO Link

SENDER RECEIVERSEQ. # CRC

PACKET

time time

RTOX

RTT

ret #

SEQ. # CRCret #ACK

Because of storage in the channel, the ACK must be bound to a specificpacket transmission, not just the packet sequence number.