COMPUTER NETWORKS CS610 Lecture-5 Hammad Khalid Khan
Review Lecture 4 The Concept of Packets Why use Packets? Packets and Frames Byte Stuffing
Byte Stuffing Sometimes, the special characters (i.e. soh or eot) may appear in the data Problem: soh and eot as part of data will be misinterpreted as framing data Solution: Byte stuffing
Byte Stuffing (cont’d) Byte stuffing translates each reserved byte into two unreserved bytes For example, can use esc as prefix, followed by x for soh, y for eot and z for esc
Byte Stuffing (cont’d) The sender replaces each occurance of special characters with a combination of two characters (i.e.esc x, esc y, esc z) The receiver then replaces each occurence of esc x, esc y, esc z, by the corresponding single character
Byte Stuffing (cont’d)
Byte Stuffing (cont’d)
Transmission Errors Interference or power surges may destroy data during transmission Bits may be lost Bit values may be changed Frames include additional information to detect / correct errors Inserted by the sender Checked by the receiver
Error Detection & Correction Error detection - send additional information so that incorrect data can be detected and rejected Error correction - send additional information so that incorrect data can be corrected and accepted
Parity Checking Parity refers to the number of bits set to 1 in the data item Even parity - An even number of bits are 1 Odd parity - An odd number of bits are 1
Parity Checking A Parity Bit is an extra bit transmitted with a data item, chose to give the resulting bits even or odd parity Even parity - data: 10010001, parity bit 1 Odd parity - data: 10010111, parity bit 0
Parity and Error Detection If noise or other interference introduces an error, one of the bits in the data will be changed from a 1 to a 0 or from a 0 to a 1 Parity of resulting bits will be wrong Original data and parity: 10010001+1 (even parity) Incorrect data: 10110001+1 (odd parity)
Limitations of Parity Checking Parity can only detect errors that change an odd number of bits Original data and parity: 10010001+1 (even parity) Incorrect data: 10110011+1 (even parity!) Parity usually used to catch one-bit errors
Alternative Error Detection Schemes Alternative error detection mechanisms have been introduced Differences among mechanisms: The size of the additional information (transmission overhead) Computational complexity of the algorithm (computational overhead) The number of bit error that can be detected (how well errors are detected)
Checksum Checksum is calculated before transmission Treats data as a sequence of integers Computes their arithmetic sum Carry bits are added into the final sum Calculated checksum is sent along with data Receiver then performs the same calculation
Checksum
Checksum Can be 8-, 16- or 32-bit integers Easy to do - uses only addition May not detect all errors
Cyclic Redundancy Check (CRC) Problem : How can a network system detect more errors without increasing the amount of information in each packet? Answer: Cyclic Redundancy Check (CRC)
Cyclic Redundancy Check (CRC) Consider data in message as coefficients of a polynomial Divide that coefficient set by a known polynomial Transmit remainder as CRC Good error detection properties Easy to implement in hardware
Hardware Components Uses two hardware components: Shift Register Exclusive or (xor) unit
Hardware Components Exclusive OR (XOR) unit
Hardware Components Shift Register: Performs two operations: Initialize : Sets all bits to zero Shift: Moves all bits to the left one position
SUMMARY Byte Stuffing Transmission Errors Error Detection Parity Check Checksum CRC