ccnet lec 08 error detection and flow control

Upload: suleman-jamil

Post on 08-Apr-2018

237 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    1/29

    Lecture

    08Data Communication & Networks

    Error Detection & Flow Control

    Muhammad Yousaf

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    2/29

    [email protected] 2

    Errors on the network:

    We know real life is very uncertainData sent might be lost in networkOr receiver receive data with errorsNoise may be higher enough to invert bit-values

    How receiver will decide that data receivedcorrectly or erroneouslyNeed to develop some mechanism that enables the

    receiver to discriminate between correct data anderroneous data

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    3/29

    [email protected] 3

    Error Detection:

    Idea is to add some extra information with userdataReceiver uses these information to infer about thecorrectness of dataThere are many schemes that implement errordetection

    Parity Checking

    Cyclic Redundancy Check (CRC)Checksum

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    4/29

    [email protected] 4

    Parity Check:

    Used with character-wise transmissionAppend an extra bit with the character bits0 1 0 0 0 0 1 0 P

    Count the number of ones & set the P-bitaccordinglyEven Parity:

    Number of ones including P-bit should be even

    0 1 0 0 0 0 1 0 00 1 0 0 0 0 1 1 1

    Similarly in Odd Parity number of ones are odd

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    5/29

    [email protected] 5

    Problem in Parity Check:

    Odd number of error-bits can be detected easilySend data with even parity: 0 1 0 0 0 0 1 0 0Error occurred during transmission: 0 1 0 0 0 1 1 0 0Receiver checked the parity: 0 1 0 0 0 1 1 0 0

    Number of ones are not even: ERROR DETECTEDEven number of error- bits cant be detected

    Send data with even parity: 0 1 0 0 0 0 1 0 0

    Error occurred during transmission: 0 1 0 0 1 1 1 0 0Receiver checked the parity: 0 1 0 0 1 1 1 0 0Number of ones are even: ERROR NOT DETECTED

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    6/29

    [email protected] 6

    Cyclic Redundancy Check: (CRC)

    Used with block-wise transmissionTransmitter & receiver agree on a common divisorTransmitter divides the data with this divisorCalculates the remainder

    Appends this remainder with the data as CRC valueTransmit (data + CRC value)Receiver divides this (data + CRC) value with the commondivisor

    If remainder is zero then data received error freeIf remainder is non-zero then data received erroneously

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    7/29

    [email protected] 7

    CRC Calculation: (sender side)

    1011

    10111

    11100

    10111

    10000

    10111

    10011

    10111

    11110

    10111

    10110

    10111

    11100

    10111

    010000110010011110111

    Let user data is:110010011101Common divisor is:

    10111

    Start with 0000110010011101 0000

    Dividing using XORRemainder is 1011Append it with data &transmit

    110010011101 1011

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    8/29

    [email protected] 8

    CRC Verification: (receiver side)

    0000

    10111

    10111

    10111

    10010

    10111

    10011

    10111

    11110

    10111

    10110

    10111

    11100

    10111

    011011110010011110111

    Receiver received thedata + CRC valuePerformed samecalculationIf remainder is zero

    Data received error free

    Else if Non-Zero

    There is some error inreceived data

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    9/29

    [email protected] 9

    Frame transmission scenarios:

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    10/29

    [email protected] 10

    Flow Control

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    11/29

    [email protected] 11

    Why Flow Control ?

    In this world, every one is not of same capabilitySender might be having more resources thanreceiver in terms of:

    Processing powerMemory spaceBandwidth

    Sender can send so much data packets that

    receiver might not be able to handlePackets more than the receivers buffer space willbe dropped

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    12/29

    [email protected] 12

    Means of Flow Control:

    Need a mechanism in which:Receiver can limit the sender from overwhelming himThere are two popular schemes:

    Stop & Wait Flow ControlSliding Window Flow Control

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    13/29

    [email protected] 13

    Stop and Wait:

    Source transmits frameDestination receives frame and replies withAcknowledgementSource waits for ACK before sending next frameDestination can stop flow by not send ACKVery simple scheme

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    14/29

    [email protected] 14

    Stop and Wait: cont

    Frames are alternatively numbered as frame-0 & frame-1Similarly receiver uses two ACK messages:

    ACK-0 = receiver has received frame-1 and is now asking for frame-0ACK-1 = receiver is asking for frame-1

    If sender doesnt receive any ACK then:Either receiver didnt received the frameOr ACK has been lost in the waySender waits for the period of TimeoutAfter the expiry of Timeout sender retransmits the previous frame

    Often Timeout = 2 * RTTRTT = Round Trip Time

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    15/29

    [email protected] 15

    Stop and Wait:

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    16/29

    [email protected] 16

    Stop and Wait: (Link Utilization)

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    17/29

    [email protected] 17

    Stop & Wait: (pros & cons)

    Advantages:Very simple schemeImplementation is easy

    Disadvantages:Poor link utilizationHigher delays

    Poor throughput

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    18/29

    [email protected] 18

    Sliding Windows:

    We want to improve link utilizationAllow multiple frames to be in transit at the sametimeEach frame is labeled with a sequence numberReceiver can send Accumulative ACKThis ACK includes number of next frame expected

    ACK-6 acknowledges the reception of previous 5 frames

    & is now asking for frame-6

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    19/29

    [email protected] 19

    Sliding Windows: cont

    Both sender & receiver maintain two windowsCommon window sizes are:3-bits = HDLC (High-level Data Link Control Protocol)7-bits = HDLC enhancement for satellite communication

    16-bits = TCP (Transmission Control Protocol)Sender maintains a list of sequence numbers thathe can sendReceiver maintains a list of sequence numbers thathe can receiveSender sends the number of frames usually lessthan the maximum window size

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    20/29

    [email protected] 20

    Example Sliding Window:

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    21/29

    [email protected] 21

    Automatic Repeat Request: (ARQ)

    If some frames are lost in transit or received witherror then what to do?Definitely perform retransmission

    In sliding window for retransmissions there are twopossibilities:

    Go back NSelective repeat

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    22/29

    [email protected] 22

    Go Back N:

    If frame N is lost or received with error;Receiver side:Receiver discards that frame and all subsequent framesuntil error frame received correctly

    Receiver doesnt buffer the out of order framesSends ACK-N to indicate that receiver is asking forframe-N

    Sender side:Goes back to sequence number N and sends allsubsequent frames

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    23/29

    [email protected] 23

    Go Back N: cont

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    24/29

    [email protected] 24

    Selective Repeat:

    Minimizes retransmissionOnly lost/damaged frames are retransmittedIf frame N is lost or received with error:Receiver side:

    Receiver discards that frame but buffers the subsequentframesReceiver must maintain a buffer to store out of orderframes

    Sender side:Only the frame that has been asked by the receiver isretransmitted

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    25/29

    [email protected] 25

    Selective Repeat:

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    26/29

    [email protected] 26

    HDLC:

    High-level Data Link Control ProtocolLayer 2 protocolDefines the services provided by data link layerAppends layer-2 header and trailer with the dataOnce heavily used protocolTodays data link protocols are based on HDLC

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    27/29

    [email protected] 27

    Frame Structure of HDLC:

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    28/29

    [email protected] 28

    Control Field: (information frame)

  • 8/6/2019 Ccnet Lec 08 Error Detection and Flow Control

    29/29

    myousaf@ymail com 29

    Questions ???