You are on page 1of 53

Error Detection & Correction

Computer Networks UNIT 2


M.Subramaniam,. M.E., (Ph.D) Asst. Prof Dept of CSE, M.N.M. Jain Engineering College, Chennai 600 097, INDIA

Parity
Parity, also known as a (Vertical Redundancy Check or VRC), is the simplest error detection technique. Parity works by adding an error check bit to each character.

Aug 23, 2007

DATALINK LAYER

Parity check
ASCII a

even parity A parity bit is added to every data unit so that the total number of 1s is even (or odd for odd parity)

Parity Checking

Simple parity checking


Aug 23, 2007 DATALINK LAYER 4

Parity Checking

Parity checks can miss multiple bit errors


Aug 23, 2007 DATALINK LAYER 5

Error Correction
The receiving device detects the error and requests a re-transmission The sending device then retransmits the the portion that contained the error.

Aug 23, 2007

DATALINK LAYER

Error Correction
VRC Easy to find Single bit error. To correct single bit error in ASCII, the error correction code must determine which of the 7 bits has changed.
i.e. error in position 1, or 2, orupto 7. So requires enough redundancy bit to show all 8 states.
Aug 23, 2007 DATALINK LAYER 7

Contd..
Example now take 3 bit redundancy code, i.e to show (000 to 111) 8 different states.
i.e 7 bits ASCII 7 states. 1 state for redundancy themselves. 1 state for correct data. 7 =m data bits, 3=r redundancy bit total m+r bits transmitted. If m+r bits transmitted then r must indicate atleast m+r+1 states.
DATALINK LAYER

Aug 23, 2007

Contd..
Of these 1 state No-error, & m+r state indicates the location of error in each of m+r positions. So m+r+1 states must be discovered by r bits, i.e r bits indicates 2r different states. r Therefore 2 m+ r +1
Aug 23, 2007 DATALINK LAYER 9

Hamming code
Example: 7-bit ASCII code + 4 bit redundancy

Each r bit is the parity bit for one combination 20 1 1 1 1 1 1 of data bits
21 22 2 2 2 2 2 2 8 4 4 4 4 r1: bits: 1, 3, 5, 7, 9, 11 3 8 8 8 r2: bits: 2, 3, 6, 7, 10, 11 2 r3: bits 4, 5, 6, 7 r4: bits 8, 9, 10, 11

1 2 3 4 5 6 7 8 9 10 11

Hamming code (contd..)


Example of redundancy bit calculation (even parity)

Hamming code (contd..)


Error detection using Hamming code
1110 9 8 7 6 5 4 3 2 1

Once the bit is identified the receiver can reverse its value

Flow Control
Ensuring the sending entity does not overcome the receiving entity Preventing buffer overflow Transmission time Time taken to emit all bits into medium Propagation time Time for a bit to traverse the link

Aug 23, 2007

DATALINK LAYER

13

Model of Frame Transmission

Aug 23, 2007

DATALINK LAYER

14

Stop and Wait - ARQ


Source transmits frame Destination receives frame and replies with acknowledgement Source waits for ACK before sending next frame Destination can stop flow by not send ACK Works well for a few large frames Stop-and-Wait ARQ is sometimes referred to

Continuous-ARQ

Aug 23, 2007

DATALINK LAYER

15

Automatic Repeat Request - ARQ


Admit possibility of two types of errors,
Lost frames. Damaged Frames.

Ingredients of Error Control,


Error Detection Positive acknowledgement Retransmission after timeout. Negative acknowledgement and Re-transmission.

Collectively those mechanism are referred to as Automatic-Repeat-Request.


Aug 23, 2007 DATALINK LAYER 16

Stop-and-Wait ARQ -Normal operationThe sender will not send the next piece of data until it is sure that the current one is correctly received sequence number necessary to check for duplicated packets No NACK when packet is corrupted duplicate ACKs instead

Stop-and-Wait ARQ -Lost or damaged frame-

roundtrip delay + processing in the receiver

Stop-and-Wait ARQ -Lost ACK-

Importance of numbering

Stop-and-Wait ARQ -Delayed ACK-

Importance of ACK numbering

Stop and Wait Diagram

Drawbacks of Stop-and-Wait ARQ


After each frame sent the host must wait for an ACK inefficient use of bandwidth To improve efficiency ACK should be sent after multiple frames Alternatives: Sliding Window protocols 1. Go-back-N ARQ 2. Selective Repeat ARQ
Aug 23, 2007 DATALINK LAYER 22

Go-back-N ARQ
Based on sliding window Use window to control number of outstanding frames If no error, ACK as usual with next frame expected(RR=Receive Ready) If destination station detects error in a frame it sends a NACK (REJ=Reject) Discard that frame and all future frames until error frame received correctly Transmitter must go back and retransmit that frame and all subsequent frames
Aug 23, 2007 DATALINK LAYER 23

Go Back N -

Damaged Frame

(Case 1)

A transmits frame i, B detects an error and has previously successfully received frame (i-1). B sends REJ i, indicated the frame i is rejected. When A receives REJ, it must retransmit frame i and all subsequent frames that it has transmitted since the original transmission of frame i.

Aug 23, 2007

DATALINK LAYER

24

Go Back N -

Damaged Frame

(Case 2)

Frame i is lost in transit, A subsequently sends frame (i+1). B receives frame (i+1) out of order and send REJ i , A must retransmit frame i and all subsequent frames.

Aug 23, 2007

DATALINK LAYER

26

Go Back N -

Damaged Frame

(Case 3)

Frame i is lost in transit, and A does not soon send additional frame. B receives nothing and returns neither RR nor an REJ. When As timer expires, it transmits an RR frame that include a bit known as the P bit, which is set to 1. B interprets the RR frame with a P bit of 1 a command that must be acknowledged by sending an RR indicating the next frame that it expects. When A receives the RR, it retransmits frame i.
Aug 23, 2007 DATALINK LAYER 27

Damaged RR (case 1)
B receives frame i and sends RR(i+1), which is in transit.
Because acknowledgements are cumulative (e.g., RR 6 means that all frames through 5 are acknowledged), it may be that A will receive a subsequent RR to a subsequent frame and that it will arrive before the timer associated with frame i expires.
DATALINK LAYER 28

Aug 23, 2007

Damaged RR (case 2)
If As timer expires, it transmits a RR command as in Slide 26. It sets another timer, called the P bit timer. If B fails to respond to RR command, or if its response is damaged, then As P-bit timer will expire. At this point, A will try again by issuing a new RR command and restarting the P-bit timer. This procedure is tried for number of iterations. If A fails t obtain an acknowledgement after some maximum number if attempts, it initiates a reset procedure.
Aug 23, 2007 DATALINK LAYER 29

Selective Reject
Also called selective re-transmission Only rejected frames are retransmitted Subsequent frames are accepted by the receiver and buffered Minimizes retransmission Receiver must maintain large enough buffer More complex login in transmitter
Aug 23, 2007 DATALINK LAYER 30

Selective Reject Diagram

Aug 23, 2007

DATALINK LAYER

31

High Level Data Link Control


HDLC ISO 33009, ISO 4335

Aug 23, 2007

DATALINK LAYER

32

HDLC Station Types


Primary station
Controls operation of link Frames issued are called commands Maintains separate logical link to each secondary station Under control of primary station Frames issued called responses May issue commands and responses
DATALINK LAYER 33

Secondary station Combined station


Aug 23, 2007

HDLC Link Configurations


Unbalanced
One primary and one or more secondary stations Supports full duplex and half duplex

Balanced
Two combined stations Supports full duplex and half duplex

Aug 23, 2007

DATALINK LAYER

34

HDLC Transfer Modes (1)


Normal Response Mode (NRM)
Unbalanced configuration Primary initiates transfer to secondary Secondary may only transmit data in response to command from primary Used on multi-drop lines Host computer as primary Terminals as secondary
Aug 23, 2007 DATALINK LAYER 35

HDLC Transfer Modes (2)


Asynchronous Balanced Mode (ABM)
Balanced configuration Either station may initiate transmission without receiving permission Most widely used No polling overhead

Aug 23, 2007

DATALINK LAYER

36

HDLC Transfer Modes (3)


Asynchronous Response Mode (ARM)
Unbalanced configuration Secondary may initiate transmission without permission form primary Primary responsible for line rarely used

Aug 23, 2007

DATALINK LAYER

37

Frame Structure
Synchronous transmission All transmissions in frames Single frame format for all data and control exchanges

Aug 23, 2007

DATALINK LAYER

38

Frame Structure

Aug 23, 2007

DATALINK LAYER

39

Flag Fields
Delimit frame at both ends 01111110 May close one frame and open another Receiver hunts for flag sequence to synchronize Bit stuffing used to avoid confusion with data containing 01111110 0 inserted after every sequence of five 1s If receiver detects five 1s it checks next bit If 0, it is deleted If 1 and seventh bit is 0, accept as flag If sixth and seventh bits 1, sender is indicating abort

Aug 23, 2007

DATALINK LAYER

40

Bit Stuffing
Example with possible errors

Address Field
Identifies secondary station that sent or will receive frame Usually 8 bits long May be extended to multiples of 7 bits LSB of each octet indicates that it is the last octet (1) or not (0) All ones (11111111) is broadcast

Aug 23, 2007

DATALINK LAYER

42

Control Field
Different for different frame type
Information frames (I-Frame) - data to be transmitted to user (next layer up)
Flow and error control piggybacked on information frames.

Supervisory frames (S- Frames)- provide ARQ when piggyback not used. Unnumbered frames (U- Frames)- supplementary link control functions.

First one or two bits of control filed identify frame type Remaining bits explained later
Aug 23, 2007 DATALINK LAYER 43

Control Field Diagram

Aug 23, 2007

DATALINK LAYER

44

Poll/Final Bit
Use depends on context Command frame Response frame
P bit 1 to solicit (poll) response from peer F bit 1 indicates response to soliciting command
DATALINK LAYER 45

Aug 23, 2007

Information Field
Only in information and some unnumbered frames Must contain integral number of octets Variable length

Aug 23, 2007

DATALINK LAYER

46

Frame Check Sequence Field


FCS Error detection 16 bit CRC Optional 32 bit CRC

Aug 23, 2007

DATALINK LAYER

47

HDLC Operation
Exchange of information, supervisory and unnumbered frames Three phases
Initialization Data transfer Disconnect

Aug 23, 2007

DATALINK LAYER

48

Initialization
Initialization may be requested either side by issuing one of the six set-mode commands It signals the other side that Initialization is requested. It specifies which of the three modes (NRM,ABM,ARM) is requested. It specifies whether 3-or 7-bit sequence numbers are to be used. If the other side accepts the request, then HDLC module on that end transmits an, Unnumbered acknowledgement (UA) frame back to the initiating side. If the request is rejected, then a Disconnected mode (DM) frame is sent.

Aug 23, 2007

DATALINK LAYER

49

Data transfer
Both sides may begin to send the user data in I- frames, starting with sequence no.(0). The N(S) and N(R) of I- frames flow control & Error Control. An HDLC module sending a sequence of I-frames will number them sequentially, mod 8 or 128, - 3 or 7-bit sequence number is used in N(S) and N(R). S- frames are also used for flow and error control.
Receive ready (RR)- Frame Receive-not-ready (RNR) Frame REJ initiates the GO-back-N ARQ. SREJ- used to request re-transmission of just a single frame.
Aug 23, 2007 DATALINK LAYER 50

Disconnect
Either HDLC module can initiate a disconnect, either on its own initiative if there is some sort of fault, or at the request of its higher-layer user. HDLC issues a disconnect by sending a Disconnect(DISC) frame. The other side must accept the disconnect by replying with UA

Aug 23, 2007

DATALINK LAYER

51

Examples of Operation (1)

Aug 23, 2007

DATALINK LAYER

52

Examples of Operation (2)

Aug 23, 2007

DATALINK LAYER

53

You might also like