This project uses UDP to implement a custom TCP-like protocol to send files between two host nodes in a network. Our implementation is able to:
- Tolerate packet drops
- Allow other concurrent connections a fair chance
- Ensure that the entire bandwidth is not given up to other connections
In order to account for unreliable network connectivity, we first establish a reliable connection between the sender (sender.c
) and the receiver (receiver.c
) through a 3-way handshake process. The sender first sends a SYN, waits for a SYN-ACK from the receiver, then sends a final ACK before sending data packets over the network.
Follow these steps to run the program:
- Ensure that
gcc
is installed on your system. - (optional) If you have built the binaries before, run
make clean
to clean the executable files. - In the terminal, run
make
. - To start the sender, run
./sender receiver_hostname receiver_port filename_to_xfer bytes_to_xfer
- To start the receiver, run
./receiver UDP_port filename_to_write [writeRate]
We used Pytest, a Python testing framework, to test our code. These test files can be found in the src/test
directory. To run the test suite, first ensure that you have Pytest installed, then do the following:
This tests the transfer of 3 different files using the implemented protocol. It tests a plain text file, a jpeg file, and an mp3 file. It compares both the length and contents of the sent and received files.
To run the test:
- In the command line, navigate to the test directory using
cd src/test
. - Run
pytest test_transfer.py
to execute the test suite. - The results will be displayed on the console.
This tests the 3-way handshake protocol by testing the transfer of a file when the receiver is started before the sender and when the sender is started before the receiver. It compares both the length of the sent and received files as well as their contents.
To run the test:
- In the command line, navigate to the test directory using
cd src/test
. - Run
pytest test_handshake.py
to execute the test suite. - The results will be displayed on the console.
This tests the fairness between two competing instances of the protocol to ensure they fairly share the link.
To run the test:
- In the command line, navigate to the test directory using
cd src/test
. - Run
pytest test_fairness.py
to execute the test suite. - The results will be displayed on the console.
These test is to check the bandwidth usage of the protocol. It does not use Pytest.
To run the bandwidth check:
- In the command line, navigate to the test directory using
cd src/test
. - Run
python3 check_bandwidth.py
to start the bandwidth check. - The bandwidth usage over time will be displayed on the console.
- To stop the test program, press
CTRL + C
orCMD + C
on the keyboard, depending on your machine environment.
Q: FileNotFoundError: [Errno 2] No such file or directory: '../../receiver': '../../receiver'
A: Make sure to compile the C code and enter cd src/test
before running the test suite.
Q: Captured stderr call - bind: Address already in use
A: This means that the port needed for testing is currently being used by another process. You will need to stop the process which is using that port to let the tests run properly. In a Linux environment, use:
netstat -tulpn
to display the processeskill <pid>
to terminate the process