Configuration Data
These are some constants that are shared by the receiver and the sender save this file as configuration.py.
Python3
# Number of characters to be read # at once. FRAME_SIZE = 10 # Buffer size of tcp socket BUFFER_SIZE = 1024 * 10 # Constant to determine the end # of file and transaction. END_OF_FILE = "##**##**##**##**##" # CRC generator key CRC_GENERATOR = "10110100110101110011010101110100000101" # Accept and reject acknowledgements # from receiver to the sender. REJECT = "NAK" ACCEPT = "OK" |
Python – Stop & Wait Implementation using CRC
Stop and wait protocol is an error control protocol, in this protocol the sender sends data packets one at a time and waits for positive acknowledgment from the receiver’s side, if acknowledgment is received then the sender sends the next data packet else it’ll resend the previous packet until a positive acknowledgment is not received.
Note: To get more info on what is stop and wait protocol, refer Stop and Wait ARQ article.
CRC aka Cyclic redundancy check is an error detection mechanism, its procedure is as follows.