IMS ENGINEERING COLLEGE
LABORATORY FILE
COMPUTER NETWORKS
(BCS-653)
B.TECH – III YEAR
(EVEN SEM 2024-2025)
Name
Roll No.
Section-Batch
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
IMS ENGINEERING COLLEGE
(Affiliated to Dr A P J Abdul Kalam Technical University, Lucknow )
Approved by AICTE - Accredited by NAAC – ‘A’ Grade
NH#24, Adhyatmik Nagar, Ghaziabad, UP, India
www.imsec.ac.in
EXPERIMENT NO. - 12
Aim: Implement CRC at Sender and Receiver End
Description:
Cyclic Redundancy Check (CRC) is an error-detecting code used to detect accidental
changes to raw data in digital networks and storage devices. In a communication system,
the sender uses a CRC generator to produce a CRC code based on the data bits and
transmits both the data and CRC to the receiver. The receiver then performs a CRC check
by applying the same generator polynomial on the received data and compares the result
to verify the integrity of the message. CRC ensures high error detection efficiency,
especially for burst errors.
Algorithm/Syntax:
Sender Side:
1. Choose a generator polynomial (divisor).
2. Append zeros (equal to the degree of the divisor) to the original data bits.
3. Perform binary division (XOR operation) between the augmented data and the
divisor.
4. Append the remainder (CRC bits) to the original data and transmit.
Receiver Side:
1. Receive the data (original data + CRC bits).
2. Perform binary division (XOR operation) between the received data and the same
divisor.
3. If the remainder is zero, accept the data (no error); otherwise, discard (error
detected).
Numerical:
Original Message: 1010000
Generator polynomial: x³+1
CRC Generator: 1001
Sender:
1001)1010000000
1001
0011000000
1001
01010000
1001
0011000
1001
01010
1001
0011
Checksum: 1010000000 + 0011 = 1010000011
Receiver:
1001)1010000011
1001
0011000011
1001
01010011
1001
0011011
1001
01001
1001
0000
Important note:
1. If the remainder at receiver’s side is all zeroes, it means data is accepted.
2. If the remainder at receiver’s side is not all zeroes, it means data is not accepted.
EXPERIMENT NO. - 13
Aim: Implement Hamming Code C(7,4) at Sender and Receiver End.
Description:
Hamming Code is an error-detecting and error-correcting code that can detect up to two-
bit errors and correct one-bit errors without the need for retransmission. In C(7,4)
Hamming code, 4 data bits are used along with 3 redundant bits (parity bits) placed at
specific positions. At the sender's end, the parity bits are calculated and added to the data.
At the receiver's end, the received code is checked for errors using the parity bits and the
position of the error (if any) is identified and corrected.
Algorithm/Syntax:
Sender:
1. Identify Data and Parity Bits: The C(7,4) code uses 4 data bits and 3 parity bits.
2. Calculate Parity Bits:
3. Parity Bit 1 (P1): XOR the data bits at positions 2, 3, and 5.
4. Parity Bit 2 (P2): XOR the data bits at positions 3, 5, and 6.
5. Parity Bit 3 (P3): XOR the data bits at positions 5, 6, and 7.
6. Form 7-bit Codeword: Place the calculated parity bits (P1, P2, P3) in positions 1, 2,
and 4, respectively. The data bits are placed in positions 3, 5, 6, and 7.
Receiver:
1. Receive 7-bit Codeword: The receiver receives the 7-bit codeword from the sender.
2. Calculate Parity Bits: The receiver recalculates the parity bits using the same algorithm
as the sender.
3. Error Detection: Compare the calculated parity bits with the received parity bits. If
they match, no error is detected. If they differ, an error is detected.
4. Error Correction:
Error Location: If an error is detected, the parity bits can be used to pinpoint the exact
location of the error.
Error Correction: Flip the bit at the error location.
Example:
Let's say the data bits are 1101.
7. Sender:
Calculate Parity Bits:
P1 = 1 XOR 0 XOR 1 = 0
P2 = 0 XOR 1 XOR 1 = 0
P3 = 1 XOR 1 XOR 0 = 0
Form Codeword: 0001101
8. Receiver:
Recalculate Parity Bits:
P1 = 0 XOR 0 XOR 1 = 1 (Error detected in P1)
Error Location: Error is in position 3.
Error Correction: Flip the bit at position 3. The corrected codeword is 0001101.
The data bits are now 1101.
● C(7,4) Hamming Code Layout:
Position Parity/Data Bit
1 P1
2 P2
3 Data
4 P3
5 Data
6 Data
7 Data
Important Notes:
The C(7,4) Hamming code can detect and correct any single-bit error.
It cannot detect or correct multiple errors.
The minimum Hamming distance between any two valid codewords is 3.