50
ECE/CSC 570 Errors Happen n Errors must be controlled Detection Correction n Must have redundancy Overhead incurred for error control Higher for correction n Error control strategies have limitation Having detected the errors, now what ? Need acknowledgement. Error recovery n Three armies problem!

ARQ ppt

Embed Size (px)

DESCRIPTION

ARQ protocol slides

Citation preview

  • ECE/CSC 570

    Errors Happen

    n Errors must be controlled Detection Correction

    n Must have redundancy Overhead incurred for error control Higher for correction

    n Error control strategies have limitation Having detected the errors, now what ? Need acknowledgement. Error recovery

    n Three armies problem!

  • ECE/CSC 570

    The Three Armies Problem

    n Acknowledgements are neededn But may not be availablen Hence requests must sometimes be implicit

    AB B

  • ECE/CSC 570

    ARQ Error Control

    n Types of errors: Lost frames, damaged framesn Most Error Control techniques are based on (1)

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

    n 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 inthose erroneous frames.

    n 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?

    n Assumptions Transmissions are eventually successful.

  • ECE/CSC 570

    Approach

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

    n Timing Diagrams Diagram showing sequence of events involved Transmission of frames (start and end) Delays four kinds

    sender

    receiverTime

  • ECE/CSC 570

    Some ARQ Protocols

    n Stop-And-Wait (SAW)Simplex in data transmissionHalf-duplex considering acknowledgement

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

    n Selective Repeat Protocol (SRP)Increase efficiency

  • ECE/CSC 570

    Assumptions

    n We refer to frames without transmission errors as error-free frames and those with transmission errors as error frames.

    n We assume that the receiver can always distinguish error frames from error-free frames.

    n 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.

    n 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)

    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.

    n Assume acknowledgement delay bound T A timer associated with each packet Implicit request for retransmission

    n Only one outstanding packet at anytime

    Flow Control: How to prevent the sender from flooding the receiver with data faster than the latter is able to process them?

  • ECE/CSC 570

    Stop-and-Wait (2)

    n Frames are transmitted from A to B.

    n 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.

    n Since error can occur from B to A as well as from A to B, the ack or nak is protected with a CRC.

    Sender A

    Receiver B

    X

    T T T

  • ECE/CSC 570

    Stop-and-Wait (3)

    n The trouble with unnumbered packetsThe ack for packet 0 is abnormally delayed, so A

    retransmits packet 0, but B cannot tell whether it is 0 or 1.

    Solution? Use a sequence number in the frame header to identify successive packets.

    Sender A

    Receiver B Packet 0 or 1 ?

    T T T0Ack

    0

    Packet 0

  • 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.

    Solution? Instead of returning ack or nak on the reverse link, returns the number of the next packet awaited.

    Sender A

    Receiver BPacket 0

    Ack

    SN 0 0 1 2

    Ack Nak

    Packet 0

    ?

  • 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.

    n piggybacking is to delay outgoing acks so that they can be hooked onto the next outgoing data frame.

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

    Request Number (RN) for piggybackingof the next packet awaited in the opposite direction

    SN RN Packet CRC

  • ECE/CSC 570

    SAW: Algorithms for A-to-B Trans.

    n Algorithm at sender A for A-to-B transmission

    n Algorithm at receiver B for A-to-B transmission

    n Use timer expires/disabled to handle the arbitrary delays between subsequent transmissions in the algorithm above.

    Sender A

    Receiver B

    0

    0 0 1 3SN

    RN 1 21

    2

    31Packets out 2

  • ECE/CSC 570

    SAW: Detailed Algorithms

    n The algorithm at node A for A-to-B transmission:1. Set the integer variable SN to 02. 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.3. Transmit the SN-th packet in a frame containing SN in the sequence number

    field.4. 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. 5. If no such frame is received within some finite delay (timeout), go to step 3

    n The algorithm at node B for A-to-B transmission:1. Set the integer variable RN to 0 and then repeat steps 2 and 3 forever.2. 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.

    3. 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 Throughput = # of successful packets received/sec (unit of packet/sec, bits/sec etc.)

    n Capacity = potential max. packets received/secn Efficiency = throughput / capacity

    = transmission time / total time between two (successful) frames

    n 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.

    n 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!

    n p = Probability of success !n 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).

    n In case of no error, i.e., p=1, then the throughput is l= 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 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 p T E X( ) ( ) ( ( ))= + - +1

    E X S T pp

    ( ) = + -1

    )}(){1()( YETppSXE +-+=

  • ECE/CSC 570

    Efficiency of SAW (5)

    n Therefore, under the assumptions, SAW transmits one packet everyE(X) seconds, on average. That is, the (successful) transmission rateor throughput is 1/E(X).

    n The efficiency of SAW is equal to its throughput 1/E(X) divided by the line rate 1/t, where t is the transmission time of a packet. That is,

    n 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)

    ht

    SW S T( p p=

    + -1 ) /

  • ECE/CSC 570

    A closer look on the efficiency

    n Assume no error, i.e., p=1, and T = S

    n Efficiency h = t / S, where T = S = t + tout n Assume that tout = 2tprop + tproc 2tprop

    n a = tprop/t = propagation delay / transmission delay

  • ECE/CSC 570

    A closer look on the efficiency (2)

    n a = tprop/t = propagation delay / transmission delay Let d = propagation delay, P = frame size in bits, R =

    link speed in bps n 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 ?

    n a >> 1? a

  • 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.

    n Piggybacking Temporarily delaying outgoing acks so that they can be hooked onto

    the next outgoing data frame (free ride for acks!). n How long should the receiver wait for a packet to piggyback the

    ack? Too long will incur retransmission Too short separate acknowledgement

    n 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 timeLeads to inefficiency if propagation delay is much

    longer than the transmission delay (i.e., a >> 1)n Sliding window flow controlAllows transmission of multiple framesAssigns each frame a k-bit sequence numberRange 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 frameswithin the window because these frames may need retransmission.

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

    Frames already transmitted

    Windows of frames that may be transmitted

    Frame sequence number

    Last frame transmitted

    Window shrinks as frames are sent

    Window expands as acknowledgements are

    received

  • ECE/CSC 570

    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.

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

    Frames already received

    Windows of frames that are accepted by receiver

    Last frame acknowledged

    Window shrinks as frames are received

    Window expands as acknowledgements are sent

  • ECE/CSC 570

    Operation of Sliding Window (3)

    n How is flow control achieved?Receiver can control the size of the sending windowBy limiting the size of the sending window, data flow

    from the sender to the receiver can be limited.n Interpretation of ACK N message:Receiver acknowledges all packets until (but not

    including) sequence number N.

  • ECE/CSC 570

    Example

    Transmitter

    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

    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

    F0F1F2

    ACK 3

    Receiver

  • ECE/CSC 570

    Example (contd)

    Transmitter

    0 1 2 3 4 5 6 7 0 1 2 30 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

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

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

    F3

    F5F4

    ACK 4

    Receiver

    F6

  • 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 1000-bit 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.

    n 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. n Selective Repeat ARQ

  • ECE/CSC 570

    n Window size W = n

    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)

    n Timer value T Wt

    n 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.

    n If time-out, go back and retransmit.

    Go Back n ARQ

  • 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

    Frame 0

    Frame 3

    Frame 2

    Frame 1

    Frame 4

    Frame 5

    Frame 6

    Frame 4

    Frame 6

    Frame 5

    ACK

    3

    ACK

    6

    NA

    CK

    4

    A

    B

    Frames 5 and 6 are discarded

    Frames 4,5,6 are retransmitted

  • ECE/CSC 570

    Effect of transmission error (2)

    n Lost ACK

    Frame 0

    Frame 3

    Frame 2

    Frame 1

    Frame 4

    Frame 0

    Frame 1

    Frame 2

    Frame 4

    Frame 3

    ACK

    3

    ACK

    5

    A

    B

    Frames 0 -- 4 are retransmitted

    Frame 5

    ACK

    3

    Timeout

  • ECE/CSC 570

    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.

    n 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.

    n 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.

    n 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 )

    n 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

    n 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.

    n Assume that every ACK of a packet reaches the sender exactly S seconds after the sender started sending the packet.

    n Denote by t the transmission time of a packet.

    n First we assume no errors and the window size is Wsender transmits packets 0,1,, W-1 then waits for the first ACK which arrives after S seconds.

  • ECE/CSC 570

    ACK

    S t

    If S W WS

    =t ht

    If S W< =t h 1

    Assume no errors!

    Efficiency of GBN (2)

    A B

    =

    SW

    GBNt

    h ,1 min

  • ECE/CSC 570

    Efficiency of GBN (3)

    n Transmission errors will of course reduce the efficiency.n 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= = t

    sender

    receiver

    kt

    S

    k

    t, p t, p

    S, 1-p S, 1-p

  • ECE/CSC 570

    Efficiency of GBN (4)

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

    Since the useful transmission time per packet is t , the transmission time, we conclude that the efficiency hGBNof Go Back N is given by

    (When S =T=Wt )

    ht

    tGBN p S p=

    + -( ) /1

    pSpXE )1()( -+=t

    )(XEGBNt

    h =

  • ECE/CSC 570

    Example of Choosing Wn Assume that a wireless link with a distance of 20km and

    a transmission rate of 13kbps.n The packets have 1000 bits and acknowledgements

    100 bits.n So one-way propagation time is (20km)/3x105km/s =

    66.7us. n S = ? t = ?n The efficiency of GBN is

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

    SW t,1min

  • 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.

    n The packets have 1000 bits and acknowledgements 100 bits. Assumeeach bit transmission time is t.

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

    n S = (1000 + 100)/13000 + 2 66.7 10-6 1102 /13000.n t = 1000/13000. Then the efficiency of GBN is

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

    11021000,1min W

  • 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

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

    n Let R = 2.4Gbps

    n S = ? t = ?

    n Then the efficiency of GBN is

    n This formula shows that the efficiency of 100% is achieved for awindow size W equal to 1.2 x 106 /424 =2831.

    6102.1424,1min W

    Conclusion: GBN is much more efficient than SAW in situations where the round-trip time S is significantly larger than the transmission time t

  • 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

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

    n Let R = 2.4Gbps

    n S = (424+424)/R + 2 250 10-6

    n t = 424 / R.

    n Then the efficiency of GBN is

    n This formula shows that the efficiency of 100% is achieved for awindow size W equal to 1.2 x 106 /424 =2831.

    6102.1424,1min W

  • 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.

    n Advantage over Go-Back-n:Fewer Retransmission

    n Disadvantages:More complexity at sender and receiverEach 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

    Frame 0

    Frame 3

    Frame 2

    Frame 1

    Frame 4

    Frame 5

    Frame 6

    Frame 4

    Frame 0

    Frame 7

    ACK

    3

    ACK

    0

    A

    B

    Frames 5 and 6 are buffered

    Only frame 4 is retransmitted

    ACK

    1

    ACK

    4

    NA

    CK

    4AC

    K 6

    ACK

    2

    ACK

    1

    ACK

    5

    ACK

    7

  • ECE/CSC 570

    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.

    n The upper bound of the efficiency h 1-perror, where perroris the probability of frame error.

    n If there is no error, the efficiency of SRP is identical to that of GBN, which is repeated here

    =

    SW

    SRPt

    h ,1min

  • 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.

    n Framing methods are used to break bit streams into frames.

    n Error control to transmit damaged or lost frames.

    n ARQ schemes are used to integrate error control and flow control so that the slow receiver will not be flooded by a fast sender.