CS305 Computer Networks
NOTE
Contributors:
- Yujun He
- Zhaoyang Hong
- Yicheng Xiao
For the socket package, we can only use the method for UDP, which is recvfrom()
and sendto()
. We need to use threads to maintain a "connection" between the client and the server, because the server needs to be able to handle multiple clients at once. Each socket is binded to an address and a port, while connecting to a server, the client needs to know the address and the port of the server. After the server gets the address and the port of the client, it will maintain a FSM with the according client to form a "connection".
Usage
There are in total three test files that should be run to test the realization and performance of the RDT implementation.
test_case.py
is the test file for the basic realization of the RDT implementation.calculate_throughput.py
is the test file for the large file transmission performance of the RDT implementation.calculate_latency.py
is the test file for the latency of the RDT implementation.
The first one requires modifying the LOCAL_IP
field based on the current IP address.(Please ensure that it is connected with the campus network) The last two files are run locally.
File structure
There are in total 11 files in the repository:
.
├── calculate_latency.py # calculate the latency of the RDT implementation
├── calculate_throughput.py # calculate the throughput of the RDT implementation
├── congestion.py # the congestion control module
├── data # the data folder for the test files
│ ├── original.txt
│ ├── transmit_rdt.txt
│ └── transmit_udp.txt
├── Header.py # the RDTHeader
├── proxy.py # the proxy server for the test files
├── RDT.py # the RDT implementation
├── README.md # the README file
└── test_case.py # the test file for the basic realization of the RDT implementation
Realization
Connection
- 3-way Handshake
- 4-way Handshake
- Multithreading
Packet Verfiication
- Checksum Generate
- Checksum in
send()
- Checksum in
recv()
Retransmitting
- FSM for basic
send()
andrecv()
Data Segmentation
- Segmenting data into packets
- Reassembling packets into data
Congestion Control
- Slow Start
- Congestion Avoidance
- Fast Retransmit
- Fast Recovery
Flow Control
- Sliding Window
- Selective Repeat
Error Control
- Error Detection
Performance Improvement
- Pipelining
Further Improvement
After communicating with our SAs and other classmates, there are some places we can improve the final performance.
- Use multiprocess instead of multithread. In python version
3.9
, threading is actually running within only one thread, which will not bring much improvement. - Try to send and receive data from the same process. Because the socket in python can only be run within one thread or process, there are large time penalty when switching the socket connection between differen threads.
- Use queue to demultiplex data. In our realization, we use list to store the incoming data. It is neither thread-safe nor blocking, which might cost a performance loss.
The github repository: RDT Implementation