Lecture 7
Lecture 7
• IEEE -> Institute of Electrical and Electronics Engineers • ANSI -> American National Standards Institute
• ITU-T -> International Telecommunication Union Telecommunication Standardization Sector • HDLC -> High Level Data Link Control
• ADSL -> Asymmetric Digital Subscriber Line
• MPLS -> Multiprotocol Label Switching
• ISDN -> Integrated Services Digital Network
• ISO -> International Organization for Standardization
• FDDI -> Fiber Distributed Data Interface
Framing: Character count
• In this method a field in the header will be used to specify the number of CHARACTERS in the frame.
• When data link layer at the destination sees the character count, it knows how many characters follow and
hence where the end of the frame is.
• Challenge:
• Count can be garbed by a transmission error
• destination will get out of synchronization and will be unable to locate the start of the next frame.
• no way of telling where the next frame starts. For this reason this method is rarely used.
Sender Receiver
Framing: Flag bytes with byte stuffing
• Gets around the problem of resynchronization after an error by having each frame start and end with special bytes.
• In recent years most protocols have used the same byte, called a flag byte, as both the starting and ending delimiter.
• if the receiver ever loses synchronization, it can just search for the flag byte to find the end of the current frame.
• Two consecutive flag bytes indicate the end of one frame and start of the next one.
• What happens when flag byte's bit pattern occurs in the
data ?
• sender's data link layer insert a special escape byte
(ESC) just before each ''accidental'' flag byte in the
data.
• data link layer on the receiving end removes the
escape byte before the data are given to the network
layer -> byte stuffing or character stuffing
• What happens if an escape byte occurs in the middle of
the data?
• it too (escape byte) is stuffed with an escape byte
• doubled one indicates that a single escape
occurred naturally in the data
• Disadvantage
• it is closely tied to the use of 8-bit characters. Not all
character codes use 8-bit characters. For example (a ) A fra me de limite d by fla g byte s . (b) Four e xa mple s of byte
s e que nce s be fore a nd a fte r byte s tuffing.
UNICODE uses 16-bit characters, so a new technique
had to be developed to allow arbitrary sized characters
Framing: Starting and ending flags, with bit stuffing
• allows data frames to contain an arbitrary number of bits and allows character codes with an arbitrary
number of bits per character
• Each frame begins and ends with a special bit pattern, 01111110 (in fact, a flag byte)
• Whenever the sender's data link layer encounters five consecutive 1s in the data, it automatically stuffs
a 0 bit into the outgoing bit stream.
• analogous to byte stuffing
• When the receiver sees five consecutive incoming 1 bits, followed by a 0 bit, it automatically de- stuffs
(i.e., deletes) the 0 bit.
• If the user data contain the flag pattern, 01111110, this flag is transmitted as 011111010 but stored in
the receiver's memory as 01111110.
• With bit stuffing, the boundary between two
frames can be unambiguously recognized by
the flag pattern.
• if the receiver loses track of where it is, all
it has to do is scan the input for flag
sequences, since they can only occur at
frame boundaries and never within the
data.
Framing
• Many data link protocols use a combination of these methods for safety.
• A common pattern used for Ethernet and 802.11 (WiFi) is to have a frame begin with a well-defined
pattern called a preamble.
• This pattern might be quite long (72 bits is typical for 802.11) to allow the receiver to prepare for an
incoming packet.
• The preamble is then followed by a length (i.e., count) field in the header that is used to locate the
end of the frame
Data link layer: Error Detection and Correction
• Two strategies for dealing with errors in a network
• Error-detecting codes
• include only enough redundancy to allow the receiver to deduce that an error occurred, but
not which error, and have it request a retransmission.
• E.g.,
• Parity.
• Cyclic Redundancy Checks (CRCs)
• Checksums.
• Error-correcting codes
• include enough redundant information along with each block of data sent, to enable the
receiver to deduce what the transmitted data must have been.
• E.g.,
• Hamming codes.
• Binary convolutional codes.
• Reed-Solomon codes.
• Low-Density Parity Check codes (LDPC codes).
Error detection: Parity
• codeword = message bits + redundant bits
• redundant bits can be parity bits/check bits
• The parity bit is chosen so that the number of 1 bits in the codeword is even (or odd), i.e., even parity or
odd parity
• E.g., when 1011010 is sent
• in even parity, a bit is added to the end to make it 10110100.
• in odd parity 1011010 becomes 10110101.
• Single parity bit can only reliably detect a single-bit error in the block.
• For burst-error (multiple bit error),
• Odds (of detecting error) can be improved considerably if each block to be sent is regarded as a
rectangular matrix n bits wide and k bits high.
• if we compute and send one parity bit for each row, up to k bit errors will be reliably detected
as long as there is at most one error per row.
• Even better approach
• Interleaving: we can compute the parity bits over the data in a different order than the
order in which the data bits are transmitted.
Error detection: Parity
Interleaving example
• Transmission order is shown for n = 7 (length of message) and k = 7 (no. of rows/no. of messages). If parity is calculated
for each row, it will
not detect the burst
error, the parity bit
will remain
unchanged
But parity is
calculated for each
column even though
the message is sent
per row, the burst
error is distributed
across columns and
therefore can be
detected.
• When a burst error of length n = 7 occurs, the bits that are in error are spread across different columns.
• At most 1 bit in each of the n columns will be affected, so the parity bits on those columns will detect the error.
• This method uses n parity bits on blocks of kn data bits to detect a single burst error of length n or less .
• A burst of length n + 1 will pass undetected
Error detection: CRC
• CRC (Cyclic Redundancy Check), also known as a polynomial code
• Polynomial codes are based upon treating bit strings as representations of polynomials with coefficients of 0 and 1
only
• A k-bit frame is regarded as the coefficient list for a polynomial with k terms, ranging from xk - 1 to x 0
• Such a polynomial is said to be of degree k - 1
• The high-order (leftmost) bit is the coefficient of x k - 1, the next bit is the coefficient of x k - 2 and so on
• E.g., 110001 has 6 bits and thus represents a six-term polynomial with coefficients
• 1, 1, 0, 0, 0, and 1: 1x 5 + 1x 4 + 0x 3 + 0x 2 + 0x 1 + 1x 0
• Polynomial arithmetic is done modulo 2 according to the rules of algebraic field theory
• Both addition and subtraction are identical to exclusive OR
Error detection: CRC
• When the polynomial code method is employed, the sender and receiver must agree upon a generator polynomial,
G(x), in advance
• Both the high and low order bits of the generator must be 1. (e.g, G(x) = x 4 + x + 1, where k = 5, degree k-1 = 4 )
• To compute the CRC for some frame with m bits corresponding to the polynomial M(x), the frame must be longer
than the generator polynomial.
• Idea/Method
• append a CRC to the end of the frame in such a way that the polynomial represented by the checksummed frame
is divisible by G(x).
• When the receiver gets the checksummed frame, it tries dividing it by G(x).
• If there is a remainder, there has been a transmission error.
• Algorithm
Error detection: CRC
• E.g., The calculation for a frame 1101011111 using the generator G(x) = x 4 + x + 1.
Polynomial
Polynomial
Polynomial
Polynomial