Unit 3
Unit 3
Bit stuffing
(a) The original data.
(b) The data as they appear on the line.
(c) The data as they are stored in receiver’s memory after destuffing.
Error Detection and Correction
• Error-Correcting Codes
• Error-Detecting Codes
• Key idea: redundant (additional) bits
(use only 2m out of 2n code words)
• Key metrics:
• how many errors can be
corrected/detected;
• what burst length
Hamming Distance
• Some codes words are valid; others are invalid
• Hamming distance between two code words is number of bits
that must be flipped to change from one to the other
• If Hamming distance is d then d single bit errors needed to change one
word to the other
• Hamming distance of a code is the minimum Hamming
distance between two valid code words
• Detecting one single-bit error requires a distance 2 code; how
does this generalize?
• Correcting one single-bit error requires a distance 3 code; how
does this generalize?
Parity Schemes
• Parity bits: choose a rule
• Even parity – each codeword has even number of 1’s
• Odd parity – each codeword has odd number of 1’s
• Always transmit according to the rule
• On receipt, if rule is violated, word is invalid
• Can also do “vertical parity” over whole block to achieve
single-bit error correction
CRC Schemes
• CRC – Cyclic Redundancy Check or polynomial code
• Consider bits of a message to be coefficients of a polynomial
M(x)
• 1011 – 1x3 + 0x2 + 1x1 + 1x0
• Of course real messages will be much longer and hence of higher degree
• Agree on a small-degree generator polynomial G(x) of degree r
• Note: G(x) has r digits to the right of the leading 1, hence r+1 total
• Divide xrM(x) by G(x) using modulo 2 division (no carries or
borrows) getting the remainder polynomial R(x)
• Transmit T(x) = xrM(x) - R(x); note that this has remainder 0
when divided by G(x)
• Receiver rejects frame if the remainder it computers is not 0
Error-Detecting Codes
Continued
Some definitions
needed in the
protocols to follow.
These are located in
the file protocol.h.
Unrestricted
Simplex
Protocol
Simplex
Stop-and-
Wait
Protocol
A Simplex Protocol for a Noisy Channel
A positive
acknowledgement
with retransmission
protocol.
Continued
A Simplex Protocol for a Noisy Channel (ctd.)
• Why?
• Efficiency – bandwidth*delay product
• Efficiency – when errors occur
• A One-Bit Sliding Window Protocol
• A Protocol Using Go Back N
• A Protocol Using Selective Repeat
Sliding Window Protocols (2)
Continued
A One-Bit Sliding Window Protocol (ctd.)
A One-Bit Sliding Window Protocol (2)
Continued
Sliding Window Protocol Using Go Back N
Continued
Sliding Window Protocol Using Go Back N
Continued
Sliding Window Protocol Using Go Back N
Sliding Window Protocol Using Go Back N (2)
Continued
A Sliding Window Protocol Using Selective Repeat (2)
Continued
A Sliding Window Protocol Using Selective Repeat (3)
Continued
A Sliding Window Protocol Using Selective Repeat (4)
A Sliding Window Protocol Using Selective Repeat (5)
Control field of
(a) An information frame.
(b) A supervisory frame.
(c) An unnumbered frame.
The Data Link Layer in the Internet