This repo contains several tools that will help you simulate and test your solution.

computer science

Description

## Homework 5: Reliable Communication

In this homework, you will implement reliable communication over an unreliable
link, just like TCP.

You will be provided with code that simulates an unreliable link between sender
and receiver.  This link has a very constrained buffer (only two packets can
be 'in flight' at a time), and can have arbitrary delay and loss rates.  Your
job will be to create and implement a protocol over this connection that
correctly transfers data, in a reasonable amount of time.


### Writing Your Solution

This repo contains several tools that will help you simulate and test your
solution.  **You should not make changes to any file other than `hw5.py`.**
All other files contain code used to either simulate the unreliable connection,
or code to help you test your your solution.

Your solution / `hw5.py` file will be tested against stock versions of all the
other files in the repo, so any changes you make will not be present at
grading time.

Your solution must be contained in the `send` and `recv` functions in `hw5.py`.
You should not change the signatures of these functions, only their bodies.
These functions will be called by the grading script, with parameters
controlled by the grading script.  Your solution must be general, and should
work for any file.

Your task is to modify the bodies of these functions so that they communicate
using a protocol that ensures that the data sent by the `send` function
can be reliably and quickly reconstructed by the `recv` function.  You should
do so through a combination of setting timeouts on socket reads (e.x.
`socket.timeout(float)`) and developing a system through which each side can
acknowledge if / when they receive a packet.

Remember that the connection is bandwidth constrained.  No more than two
packets can be "on the wire" at a time. If you send a third packet while
there are already two packets traveling to their destination (in either
direction), the third packet will be dropped, so it is important that you get
your timeouts and your acknowledgments right.


### Testing Your Solution

You can use the provided `tester.py` script when testing your solution.  This
script uses the `receiver.py`, `sender.py`, and `server.py` scripts to
simulate an unreliable connection, and to test your solution.

The `tester.py` script contains many parameters you can use to test your
solution under different conditions, and to receive different amounts
of debugging information to better understand the network.  These
parameters and options can be viewed by calling `tester.py --help`, and are
also reproduced below.


    usage: tester.py [-h] [-p PORT] [-l LOSS] [-d DELAY] [-b BUFFER] -f FILE
                    [-r RECEIVE] [-s] [-v]

    Utility script for testing HW5 solutions under user set conditions.

    optional arguments:
    -h, --help            show this help message and exit
    -p PORT, --port PORT  The port to simulate the lossy wire on (defaults to
                            9999).
    -l LOSS, --loss LOSS  The percentage of packets to drop.
    -d DELAY, --delay DELAY
                            The number of seconds, as a float, to wait before
                            forwarding a packet on.
    -b BUFFER, --buffer BUFFER
                            The size of the buffer to simulate.
    -f FILE, --file FILE  The file to send over the wire.
    -r RECEIVE, --receive RECEIVE


Related Questions in computer science category