Professional Documents
Culture Documents
Assignment 2 - Computer Networks
Assignment 2 - Computer Networks
Flow of Program :
There are three distinct directories, each dedicated to a specific aspect of the
problem: Go-Back-N, Stop-and-Wait, and Selective-Repeat. Within each directory, we
create three Python files: server.py, client.py, and inject_error.py. In this setup, the
server.py file is responsible for reading binary data from a file and performing various
operations to calculate the checksum and CRC. Following this, we execute the
inject_error.py file, which introduces errors into the sender's data, affecting both the
message and the checksum or CRC. The potentially corrupted data is then
transmitted to the client, where the client.py file attempts to identify the presence of
errors. Importantly, each of these methods employs distinct retransmission
strategies.
● client.py
1. Receiving the modified binary string from the server.
2. Verifying the correctness of the received data using the checksum
method.
3. Dividing the binary string into several 16-bit substrings using the
divide_into_substrings method.
4. Adding CRC to the data using the calculate_CRC method. Checking the
final data for any errors using CRC.
● injectError.py
1. The inject_error.py module contains a function that randomly injects
errors into the binary data. This random error injection simulates
real-world network scenarios where data corruption may occur during
transmission.
2. First, we evaluate the permissible error count. Afterward, we iterate to
identify that specific number of indexes, randomly setting them to
either 0 or 1. This approach allows us to simulate various types of errors,
including: no errors, single errors, multiple errors, and burst errors.
3. We get no error in two different scenarios here, either we get the
number of permissible errors to be zero or the places where we were
supposed to have the errors we are having the values already that we
get after changing.
1. Stop and Wait ARQ – The sender sends the packet and waits for the
acknowledgement of the packet. Once the acknowledgement reaches the sender, it
transmits the next packet in a row. If the acknowledgement does not reach the
sender before the specified time, known as the timeout, the sender sends the same
packet again.
In this protocol, both the sender and receiver maintain a buffer capable of holding
just a single frame or packet at any given time.
2. Go Back N ARQ – The sender sends N packets which are equal to the window size.
Once the entire window is sent, the sender then waits for a cumulative
acknowledgement to send more packets. On the receiver end, it receives only
in-order packets and discards out-of-order packets. As in case of packet loss, the
entire window would be re-transmitted.
3. Selective Repeat ARQ– The sender sends packets of window size N and the receiver
acknowledges all packets whether they were received in order or not. In this case,
the receiver maintains a buffer to contain out-of-order packets and sorts them. The
sender selectively re-transmits the lost packet and moves the window forward.
Selective Repeat ARQ, implemented across server.py, client.py, and injectError.py,
facilitates reliable data transmission. Server.py handles checksum and CRC
calculations, while client.py receives, verifies, and processes data. InjectError.py
simulates error scenarios. This system ensures data integrity through checksums and
CRC, along with error simulation for testing purposes.