Sender side
- Choose a generator polynomial mutually agreed upon by the sender and receiver, let k be the number of bits in the key obtained from this polynomial.
- Append (k – 1) 0’s to the right of the actual binary data.
- Divide the data obtained in step 2 by the key, and store the remainder.
- Append the remainder to the actual binary data, and send the data packet.
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.