In data communication, error can happen during the transmission of data from the sender to
the receiver over unreliable medium.
In order to help the receiver check for error, redundancy bits are added to the dataword to help
the receiver verifies the validity of the received data (codeword).
In this project, I have implemented the knowledge I learnt in class by writing the programs and functions.
Input:
- bit string of any size up to k (input frame).
- Probability of having a bit in error (p).
Output:
- bit string of size k defined by the input bit string (output frame).
Behavior: The function randomly generates errors on the bits of the input frame. A bit can be in error with probability p. The function outputs output frame which could be a corrupted or uncorrupted frame.
Generator: codeword = parity_gen(dataword, parity_type, size)
Input:
- A bit string of any size up to k (input frame) where k ≥ 9 (input frame)
- Type of parity (even, odd, two-dimensional-even, two-dimensional-odd)
- Size of two-dimensional block for dataword (if two-dimensional parity bit is used).
Output:
- A code word based on the type of parity
Behavior: This function calculates the redundancy bit(s) for the dataword and output the codeword. If two-dimensional parity check is used, the size of the two-dimensional block for dataword must be specify. For example, 3x3, 4x4.
Checker: validity = parity_check(codeword, parity_type, size)
Input:
- A bit string of any size up to k (codeword)
- Type of parity (even, odd, two-dimensional-even, two-dimensional-odd)
- Size of two-dimensional block for dataword (if two-dimensional parity bit is used).
Output:
- Validity of codeword
Behavior: This function verifies the codeword.
Generator: codeword = CRC_gen(dataword, divisor)
Input:
- Dataword of size k
- Divisor
Output:
- A codeword based on CRC
Behavior: This function calculates the redundancy bit(s) for the dataword and output the codeword for CRC. Hint: you have to create a modulo-2 division function.
Checker: validity = CRC_check(codeword, divisor)
Input:
- codeword size k
- divisor
Output:
- Validity of codeword
Behavior: This function verifies the CRC codeword.
Generator: codeword = Checksum_gen(datawords, word_size, num_blocks)
Input:
- A set of datawords
- Size of each dataword (word_size)
- Number of datawords used (num_blocks)
Output:
- A codeword based on Checksum
Behavior: This function calculates the redundancy bit(s) for the dataword and output the codeword for Checksum.
Checker: validity = Checksum_check(codeword, word_size, num_blocks)
Input:
- codeword
- Size of each dataword (word_size)
- Number of datawords used (num_blocks)
Output:
- Validity of codeword
Behavior: This function verifies the CRC codeword.
Generator: codeword = Hamming_gen(dataword)
Input:
- A dataword
Output:
- A codeword based on Hamming code
Behavior: This function calculates the redundancy bit(s) for the dataword and output the codeword for Hamming code.
Checker: error_pos = Hamming_check(codeword)
Input:
- codeword
Output:
- Position of error (in case of a single bit error)
Behavior: This function verifies the Hamming codeword and report the location of error for the case of single bit error.
TLDR; I have created a program that implements the knowledge of error control I learnt in class.
The file named "datacomm" is a module used in the file "6088122_DataComm". It contains all the functions in the assignment.
To run those functions, you have to install python on your computer first. You can follow this link to download python step by step.
For python2, type: python 6088122_DataComm.py
For python3, type: python3 6088122_DataComm.py
After that, the file will run. Please follow the instruction of the file carefully.
============================================================ Enjoy!!