Sie sind auf Seite 1von 50

Errors Happen

Errors must be controlled


Detection
Correction

Must have redundancy


Overhead incurred for error control
Higher for correction

Error control strategies have limitation


Having detected the errors, now what ?
Need acknowledgement.
Error recovery

Three armies problem!

ECE/CSC 570

The Three Armies Problem


B

Acknowledgements are needed

But may not be available

Hence requests must sometimes be implicit


ECE/CSC 570

ARQ Error Control


n

Types of errors: Lost frames, damaged frames

Most Error Control techniques are based on (1)


Error Detection Scheme (e.g., Parity checks,
CRC), and (2) Retransmission Scheme

Error Control schemes that involve error


detection and retransmission of lost or corrupted
frames are referred to as Automatic Repeat
reQuest (ARQ) error control

ECE/CSC 570

Retransmission Strategies
n

Automatic Repeat reQuest (ARQ)


Detect frames with errors at the receiving DLC module and to
request the transmitting DLC module to repeat the information in
those erroneous frames.

Correctness and Efficiency


Correctness: Does the protocol succeed in releasing each
packet, once and only once, without errors, from the receiving
DLC?
Efficiency: How much of the bit-transmitting capability of the bit
pipe is wasted by unnecessary waiting and by sending
unnecessary retransmissions?

Assumptions
Transmissions are eventually successful.

ECE/CSC 570

Approach
n

Sequence numbers
Delineated streams of bits stream of frames
Successive frames have different identities

Timing Diagrams

Diagram showing sequence of events involved


Transmission of frames (start and end)
Delays four kinds

sender
Time
receiver

ECE/CSC 570

Some ARQ Protocols


n

Stop-And-Wait (SAW)
Simplex in data transmission
Half-duplex considering acknowledgement

Go-Back-N (GBN)
Increase utilization
Sliding window

Selective Repeat Protocol (SRP)


Increase efficiency

ECE/CSC 570

Assumptions
n

We refer to frames without transmission errors as errorfree frames and those with transmission errors as error
frames.

We assume that the receiver can always distinguish error


frames from error-free frames.

Each transmitted frame is delayed by an arbitrary and


variable time before arriving at the receiver, and assume
that some frames might be lost and never arrive.

Those frames that arrive are assumed to arrive in the


same order as transmitted, with or without errors.

ECE/CSC 570

Stop-and-Wait (SAW)
Flow Control: How to prevent the sender from flooding the
receiver with data faster than the latter is able to process them?
n

Simplest scheme
Protocols in which the sender sends one frame and then waits
for an acknowledgement before proceeding are called SAW.
Assume that no automatic buffering and queuing at the
receiver, the sender must never transmit a new frame until the
old one has been fetched.

Assume acknowledgement delay bound T


A timer associated with each packet
Implicit request for retransmission

Only one outstanding packet at anytime


ECE/CSC 570

Stop-and-Wait (2)
n

Frames are transmitted from A to B.

If the frame is error-free, B sends an acknowledgement (called an


ack) back to A; if the frame is an error frame, B sends a negative
acknowledgement (called a nak) back to A.

Since error can occur from B to A as well as from A to B, the ack or


nak is protected with a CRC.

T
Sender A

Receiver B
ECE/CSC 570

Stop-and-Wait (3)
n

The trouble with unnumbered packets


The ack for packet 0 is abnormally delayed, so A
retransmits packet 0, but B cannot tell whether it is 0
or 1.
0

Sender A

Ack
Packet 0 or 1 ?

Receiver B
Packet 0

Solution? Use a sequence number in the frame


header to identify successive packets.
ECE/CSC 570

Stop-and-Wait (4)
n

The trouble with unnumbered acks


If the transmitter at A times-out and sends packet 0 twice, node B can
use the sequence numbers to recognize that packet 0 is being
repeated. It must send an ack for both copies, however, and (since
acks can be lost) the transmitter cannot tell whether the second ack is
for packet 0 or 1.

SN
Sender A

1 ?

0
Ack

Ack

2
Nak

Receiver B
Packet 0

Packet 0

Solution? Instead of returning ack or nak on the reverse


link, returns the number of the next packet awaited.
ECE/CSC 570

Stop-and-Wait (5)
n

In many applications, there is another stream of data from B to A (full


duplex), and in this case, the frames from B to A carrying requests
for new A to B packets must be interspersed with data frames
carrying data from B to A.

piggybacking is to delay outgoing acks so that they can be


hooked onto the next outgoing data frame.

piggyback these requests for new packets into the headers of the
data frames from B to A.
SN

RN

Packet

CRC

Request Number (RN) for piggybacking


of the next packet awaited in the opposite direction

ECE/CSC 570

SAW: Algorithms for A-to-B Trans.


n

Algorithm at sender A for A-to-B transmission

Algorithm at receiver B for A-to-B transmission

Use timer expires/disabled to handle the arbitrary delays


between subsequent transmissions in the algorithm
above.
SN

Sender A
Receiver B
RN
Packets out

1
0

2
1

ECE/CSC 570

SAW: Detailed Algorithms


n

The algorithm at node A for A-to-B transmission:


1.
2.
3.
4.
5.

Set the integer variable SN to 0


Accept a packet from the next higher layer at A; if no packet is available, wait
until it is; assign number SN to the new packet.
Transmit the SN-th packet in a frame containing SN in the sequence number
field.
If an error-free frame is received from B containing a request number RN greater
than SN, increase SN to RN and go to step 2.
If no such frame is received within some finite delay (timeout), go to step 3

The algorithm at node B for A-to-B transmission:


1.
2.

3.

Set the integer variable RN to 0 and then repeat steps 2 and 3 forever.
Whenever an error-free frame is received from A containing a sequence number
SN equal to RN , release the received packet to the higher layer and increment
RN.
At arbitrary times, but within bounded delay after receiving any error-free data
frame from A, transmit a frame to A containing RN in the request number field.

ECE/CSC 570

Efficiency: Throughput Analysis of SAW


n
n
n

Throughput = # of successful packets received/sec


(unit of packet/sec, bits/sec etc.)
Capacity = potential max. packets received/sec
Efficiency = throughput / capacity
= transmission time / total time between two (successful)
frames

Assumption:

Fixed size frames


Infinite sequence #s
Packet errors are assumed to be independent.
Infinite retransmission

Note: From now on, frame and packet are used interchangeably.
ECE/CSC 570

More Assumptions
n

If there is no error, every ack arrives at the sender exactly


S seconds after the start of the transmission of the packet.
Then the protocol transmits one packet every S seconds.

Assume that with probability (1-p), either the packet does


not reach the receiver, or the ack does not make it back to
the sender in both cases, timeout occurs!

p = Probability of success !

Assume that if the ack gets to the sender (with probability


p), then it does so in exactly S seconds.

The efficiency depends on the packet error rate and


on the actual delay of the acknowledgements.

ECE/CSC 570

Efficiency of SAW (2): No Error case


n

Let time X be the random variable that the sender


takes between the first transmission of packet n and
that of packet n+1 (time between successful packets).

In case of no error, i.e., p=1, then the throughput is


= 1/S (packets/sec)
Every S seconds, station A transmits 1 packet successfully.

ECE/CSC 570

Efficiency of SAW (3)


n

X : random variable that the sender takes between the first


transmission of packet n and that of packet n+1 (time between
successful packets)
With probability 1-p, the ack does not come back. In this case, after T
seconds, the sender restarts its attempt to deliver packet n.
With probability 1-p, one has X = T+Y, where Y is the time that the
sender takes from that second transmission of packet n until the
transmission of packet n+1.

ECE/CSC 570

Efficiency of SAW (4)


n

Then

E ( X ) = pS + (1 p){T + E (Y )}

Since the transmission errors after the second transmission have the
same likelihood as after the first one, the random time Y has the same
statistics as the random variable X. Both X and Y are the random time
until the ack of a packet is correctly received, measured from the start of
the transmission of the packet.

E ( X) = pS + (1 p) (T + E ( X))
1 p
E ( X) = S + T
p
ECE/CSC 570

Efficiency of SAW (5)


n

Therefore, under the assumptions, SAW transmits one packet every


E(X) seconds, on average. That is, the (successful) transmission
rateor throughput is 1/E(X).

The efficiency of SAW is equal to its throughput 1/E(X) divided by the


line rate 1/, where is the transmission time of a packet. That is,

SW
n

=
S + T(1 p) / p

The minimum value of T for SAW is equal to S because the


transmitter waits until it knows that no ack can arrive before it
retransmits a packet. (T S)
ECE/CSC 570

A closer look on the efficiency


n

Assume no error, i.e., p=1,

Efficiency = / S, where T = S = + tout

Assume that tout = 2tprop + tproc 2tprop

a = tprop/ = propagation delay / transmission


delay
ECE/CSC 570

and T = S

A closer look on the efficiency (2)


n

a = tprop/ = propagation delay / transmission


delay
Let d = propagation delay, P = frame size in bits, R =
link speed in bps

Then, a = d/(P/R) = Rd / P, where Rd =


bandwidth-delay product representing the length
of the medium (link) in bits: i.e., How many bits
are required to fill the pipe ?

a >> 1? a << 1?

ECE/CSC 570

Sliding Window Protocols


n

Bidirectional protocols
To use the same circuit for data in both directions, instead of one for
data (forward) and one for ack (reverse). The receiver can tell whether
the frame is data or ack by looking at the type in the packet header.

Piggybacking
Temporarily delaying outgoing acks so that they can be hooked onto
the next outgoing data frame (free ride for acks!).

How long should the receiver wait for a packet to piggyback the
ack?
Too long will incur retransmission
Too short separate acknowledgement

Ack with request # RN acknowledge all packets up to (RN-1)


and request transmission of packet RN.

ECE/CSC 570

Sliding Window Protocols (2)


n

Major drawback of Stop-and-Wait


Only one frame can be in transmission at a time
Leads to inefficiency if propagation delay is much
longer than the transmission delay (i.e., a >> 1)

Sliding window flow control


Allows transmission of multiple frames
Assigns each frame a k-bit sequence number
Range of sequence number is [0,1,,2k-1], i.e.,
frames are counted modulo 2k

ECE/CSC 570

Operation of Sliding Window


n

Sending Window:
The sequence numbers within the senders window represent frames
that are allowed to send (have been sent or can be sent, but are as
yet not acknowledged).
When a new packet arrives from the network layer, the upper edge of
the window is advanced by one.
The sender must have a buffer which keeps the copy of all frames
within the window because these frames may need retransmission.
Frames already
transmitted

Windows of frames that may


be transmitted

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6
Frame sequence
number

Last frame
transmitted
Window shrinks as
frames are sent
ECE/CSC 570

Window expands as
acknowledgements are
received

Operation of Sliding Window (2)


n

Receiving Window:
The receiver maintains a receiving window
corresponding to the sequence numbers of frames
that the receiver is permitted to accept.
Frames already
received

Windows of frames that are


accepted by receiver

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6
Last frame
acknowledged
Window shrinks as frames
are received
ECE/CSC 570

Window expands as
acknowledgements are sent

Operation of Sliding Window (3)


n

How is flow control achieved?


Receiver can control the size of the sending window
By limiting the size of the sending window, data flow
from the sender to the receiver can be limited.

Interpretation of ACK N message:


Receiver acknowledges all packets until (but not
including) sequence number N.

ECE/CSC 570

Example
Transmitter

Receiver

0 1 2 3 4 5 6 7 0 1 2 3
F0
F1
F2

0 1 2 3 4 5 6 7 0 1 2 3

0 1 2 3 4 5 6 7 0 1 2 3

0 1 2 3 4 5 6 7 0 1 2 3
ACK 3

0 1 2 3 4 5 6 7 0 1 2 3

0 1 2 3 4 5 6 7 0 1 2 3

ECE/CSC 570

Example (contd)
Transmitter

Receiver
F3

0 1 2 3 4 5 6 7 0 1 2 3

0 1 2 3 4 5 6 7 0 1 2 3
F4
F5
F6
0 1 2 3 4 5 6 7 0 1 2 3

0 1 2 3 4 5 6 7 0 1 2 3

ACK 4
0 1 2 3 4 5 6 7 0 1 2 3

0 1 2 3 4 5 6 7 0 1 2 3

ECE/CSC 570

Why Use Sliding Window Protocols?


n

Example: Consider a 50-kbps satellite channel with a


500msec round-trip delay. If we want to send 1000bit frames via the satellite.
The first frame will be completely sent at t=20msec, and it arrives at
the receiver at t=270msec. The ack will be received at t=520msec.
It means that the second frame cannot be sent out until t=520msec,
i.e., the sender is in idle from 20msec-520msec. That is 500/520,
about 96% of bandwidth is wasted.
Therefore, the large window is desired if the product of bandwidth x
round-trip-delay is large.

Pipelining: the product of the bandwidth and the


delay (bandwidth-delay product) the capacity of
the pipe (channel).
The sender needs the ability to fill it without stopping in order to
operate at peak efficiency.

ECE/CSC 570

Sliding Window Protocols (ARQs)


n

Go Back n ARQ
If no error occurs, this is the same as the previous
sliding window operation.

Selective Repeat ARQ

ECE/CSC 570

Go Back n ARQ
n

Window size W = n

n (=W): determines how many successive packets can


be sent without a request for a new packet
Node A is not allowed to send packet i+n before i has been
acked (i.e., before i+1 has been requested)

Timer value T W

The sender transmits packets 0,1,2, ,W-1 and waits for


up to T seconds for each of their ACKs. As soon as the
receiver gets an ACK for packet 0 it transmits packet W.

If time-out, go back and retransmit.

ECE/CSC 570

Go Back n ARQ (2)


n

Operations:
A station may send multiple frames as allowed by
the window size.
receiver sends a NAK i if frame i is in error. After
that, the receiver discards all incoming frames until
the frame in error was correctly retransmitted.
If sender receives a NAK i, it will retransmit frame i
and all packets i+1, i+2, which have been sent,
but not been acknowledged.

ECE/CSC 570

Effect of transmission error


n

Lost Frame
Frames 4,5,6 are
retransmitted

ACK 6

NACK 4

e6

ACK 3

Fra m

ECE/CSC 570

e5

e4

Frames 5 and 6
are discarded

Fra m

Fra m

e6

e5

e4

e3

e2

Fra m

Fra m

Fra m

Fra m

Fra m

e1

e0

Fra m

Fra m

Effect of transmission error (2)


n

Lost ACK
Frames 0 -- 4 are
retransmitted

Timeout

ACK 5

ACK 3

e5

ACK 3

Fra m

e4

e3

e2

ECE/CSC 570

Fra m

Fra m

Fra m

e1

e0

e4

e3

e2

Fra m

Fra m

Fra m

Fra m

Fra m

e1

e0

Fra m

Fra m

Go Back n ARQ (3): A-to-B Trans.


n

After each transmission, A sets an acknowledgement


timer (time-out timer) for the frame just transmitted.

Case1: Damaged frame.


A transmits frame i. B detects an error and has previously
successfully received frame (i-1). B sends a NAK i, indicating
that the frame is rejected. When A receives this NAK, it must
retransmit frame i and all subsequent frames that it has
transmitted.
frame i is lost in transit. A subsequently sends frame (i+1). B
receives a damaged frame (i+1), and sends a NAK i.
frame i is lost in transit and A does not soon send additional
frames. B receives nothing and returns neither an ACK or a NAK.
A will time out and retransmit frame i.
ECE/CSC 570

Go Back n ARQ (4): A-to-B Trans.


n

Case 2: Damaged ACK.


B receives frame i and sends ACK(i+1), which is lost in transit.
Since acknowledgments a cumulative, it may be that A will
receive a subsequent ACK to a subsequent frame that will do
the job of the lost ACK before the associated time expires.
A's timer expires. A will then retransmit frame i and all
subsequent frames.

Case 3: Damaged NAK. If a NAK is lost, A will time out


on the associated frame and retransmit that frame and
all subsequent frames.

Note: Each individual frame may not be individually


acknowledged, since an arriving ACK(i+1) implies that all frames
from frame i and backwards to the last acknowledged frame have
been delivered sound and well.
ECE/CSC 570

Go Back n ARQ (5): Sequence Numbers


n

A sequence space can only support a window size of 2k


1 for k-bits acknowledge field. (not 2k =W )

Why?

Consider a case in which a station transmits frame 0 and gets


an ACK1, and then transmits frame 1,2,3,4,5,6,7,0 (sequence
space of k = 3) and gets another ACK1.
This is ambiguous Is this (1) all eight frames were received
correctly, or (2) all frames were lost in transit, and the receiving
station is repeating its previous ACK1

Maximum # of outstanding packets (window size)


should be up to 2k-1, when the max. seq. # is 2k

ECE/CSC 570

Efficiency of GBN
n

We expect GBN to be more efficient than SAW.

Assume that every ACK of a packet reaches the sender


exactly S seconds after the sender started sending the
packet.

Denote by the transmission time of a packet.

First we assume no errors and the window size is W


sender transmits packets 0,1,, W-1 then waits for the
first ACK which arrives after S seconds.

ECE/CSC 570

Efficiency of GBN (2)


A

Assume no errors!

ACK

W
If S W =
S
S < W = 1
If

W
GBN = min 1,
S

ECE/CSC 570

Efficiency of GBN (3)


n

Transmission errors will of course reduce the efficiency.

For simplicity, we assume that the window size of GBN


has the smallest value that results in an efficiency of
100% in the absence of error:

T = S = W

sender

S
S, 1-p

S, 1-p

, p

receiver
ECE/CSC 570

, p

Efficiency of GBN (4)


n

E (X) = p + (1-p){ S + E(X)}

(1 p ) S
E( X ) = +
p
Since the useful transmission time per packet is , the
transmission time, we conclude that the efficiency GBN
of Go Back N is given by
(When S =T=W )

GBN

=
E( X )

GBN
ECE/CSC 570

=
+ (1 p)S / p

Example of Choosing W
n
n
n
n
n

Assume that a wireless link with a distance of 20km and


a transmission rate of 13kbps.
The packets have 1000 bits and acknowledgements
100 bits.
So one-way propagation time is (20km)/3x105km/s =
66.7us.
S=? =?
The efficiency of GBN is
W
min 1,

If W=1, then the efficiency is approximately 90%, and if


W=2, then the efficiency is equal to 100%.
ECE/CSC 570

Example of Choosing W (note)


n

Assume that a wireless link with a distance of 20km and a transmission


rate of 13kbps.

The packets have 1000 bits and acknowledgements 100 bits. Assume
each bit transmission time is t.

So one-way propagation time is (20km)/3x105km/s = 66.7us.

S = (1000 + 100)/13000 + 2 66.7 10-6 1102 /13000.

= 1000/13000. Then the efficiency of GBN is

W 1000
min 1,

1102

If W=1, then the efficiency is approximately 90%, and if W=2, then the
efficiency is equal to 100%.

ECE/CSC 570

Example of Choosing W (2)


n

Consider an optical link of 50km with transmission rate of 2.4Gbps


and with packets and acknowledgements of 424 bits. Propagation
speed of the link is v = 2/3 c

So one-way propagation time is (50km)/2x105km/s = 250us.

Let R = 2.4Gbps

S=?

Then the efficiency of GBN is

This formula shows that the efficiency of 100% is achieved for a


window size W equal to 1.2 x 106 /424 =2831.

=?

W 424
min 1,
6
1.2 10

Conclusion: GBN is much more efficient than SAW in situations where


the round-trip time S is significantly larger than the transmission time

ECE/CSC 570

Example of Choosing W (2) (note)


n

Consider an optical link of 50km with transmission rate of 2.4Gbps


and with packets and acknowledgements of 424 bits. Propagation
speed of the link is v = 2/3 c

So one-way propagation time is (50km)/2x105km/s = 250us.

Let R = 2.4Gbps
10-6

W 424
min 1,
6
1.2 10

S = (424+424)/R + 2 250

= 424 / R.

Then the efficiency of GBN is

This formula shows that the efficiency of 100% is achieved for a


window size W equal to 1.2 x 106 /424 =2831.

ECE/CSC 570

Selective-Repeat ARQ
n

Similar to Go-Back-n ARQ. However, the sender


only retransmits frames for which a NAK is
received.

Advantage over Go-Back-n:


Fewer Retransmission

Disadvantages:
More complexity at sender and receiver
Each frame must be acknowledged individually (no
cumulative acknowledgements)
Receiver may receive frames out of sequence (buffer
required)
ECE/CSC 570

Selective-Repeat ARQ (2)


n

Lost Frame
Only frame 4 is
retransmitted

ACK 1

ACK 0

ACK 5

ACK 4

ACK 3

ACK 2

ACK 1

ACK 7

ECE/CSC 570

e0

Frames 5 and 6
are buffered

e7

e4

Fra m

Fra m

Fra m

e6

e5

e4

e3

e2

Fra m

Fra m

Fra m

Fra m

Fra m

e1

e0

Fra m

Fra m

ACK 6
NACK 4

Efficiency of Selective Repeat ARQ


n

The basic idea of SRP is to accept out-of-order packets


and to request retransmission from A only for those
packets that are not correctly received.

The upper bound of the efficiency 1-perror, where perror


is the probability of frame error.

If there is no error, the efficiency of SRP is identical to


that of GBN, which is repeated here

W
SRP = min1,
S
ECE/CSC 570

Summary
n

DLC is to convert the raw bit stream offered by


the physical layer into a stream of frames for use
by the network layer.

Framing methods are used to break bit streams


into frames.

Error control to transmit damaged or lost frames.

ARQ schemes are used to integrate error control


and flow control so that the slow receiver will not
be flooded by a fast sender.
ECE/CSC 570

Das könnte Ihnen auch gefallen