This project implements and analyzes two different file transfer protocols for reliable data transmission:
- TCP-based file transfer - Using the reliable TCP protocol
- UDP-based Selective Repeat ARQ - Custom implementation of a reliable data transfer protocol over UDP with interleaving
The project is designed to compare the performance of these protocols under various network conditions including delay, packet loss, corruption, duplication, and reordering.
ceng435/
├── README.md # This file
├── docker-compose.yaml # Docker Compose configuration
├── Dockerfile # Container environment setup
├── generateobjects.sh # Script to generate test files
├── authors.txt # Project authors
├── Network Report.pdf # Performance analysis report
├── code/ # Main implementation directory
│ ├── README.md # Code directory documentation
│ ├── obj/ # Test objects directory
│ │ ├── small-*.obj # Small test files (~10KB each)
│ │ └── large-*.obj # Large test files (~10MB each)
│ ├── checksums/ # MD5 checksums for verification
│ │ ├── small-*.obj.md5 # Checksums for small files
│ │ └── large-*.obj.md5 # Checksums for large files
│ ├── tcp/ # TCP implementation
│ │ ├── tcpserver.py # TCP server implementation
│ │ ├── tcpclient.py # TCP client implementation
│ │ └── received_files/ # Directory for received files
│ └── selectiveRepeat/ # UDP Selective Repeat implementation
│ ├── server.py # UDP server with Selective Repeat ARQ
│ ├── client.py # UDP client with Selective Repeat ARQ
│ ├── mychecksums.py # Checksum verification module
│ └── received_files/ # Directory for received files
└── examples/ # Example implementations
├── tcp/ # Basic TCP examples
└── udp/ # Basic UDP examples
The TCP implementation (code/tcp/
) provides a simple and reliable file transfer mechanism:
Features:
- Reliable transmission using TCP's built-in error correction
- Sequential file transmission
- Automatic retransmission and flow control
- File integrity verification using MD5 checksums
- Performance timing and logging
Server (tcpserver.py
):
- Listens on port 65432
- Sends all files from the
obj/
directory sequentially - Uses 1KB chunks for transmission
- Sends filename before each file's data
- Uses special markers for end-of-file and end-of-transmission
Client (tcpclient.py
):
- Connects to server and receives all files
- Reconstructs files from received chunks
- Verifies file integrity using predefined checksums
- Logs reception time for each file
The UDP implementation (code/selectiveRepeat/
) implements a sophisticated reliable data transfer protocol:
Features:
- Selective Repeat ARQ for reliability
- Adaptive window size (10-100 packets)
- Interleaving of chunks from multiple files
- Dynamic chunk sizing based on file size
- Timeout-based retransmission (250ms default)
- Congestion control with window size adjustment
Server (server.py
):
- Implements sliding window protocol
- Interleaves chunks from multiple files for balanced transmission
- Uses different chunk sizes for small (1KB) and large (10KB) files
- Maintains timers for each unacknowledged packet
- Implements congestion control by adjusting window size
Client (client.py
):
- Sends acknowledgments for received packets
- Handles out-of-order packet delivery
- Requests missing chunks at the end of transmission
- Reconstructs files from received chunks
- Verifies file integrity using checksums
- Docker (with Compose V2 plugin recommended)
- VSCode (recommended for development)
- Git
-
Clone the repository:
git clone https://github.com/cengwins/ceng435.git cd ceng435
-
Build the Docker image:
docker build -t ceng435 .
-
Start the containers:
docker compose up -d
-
Access the server container:
docker exec -it server bash
-
Access the client container (in another terminal):
docker exec -it client bash
-
Stop the containers:
docker compose down
Server container:
docker run -t -i --rm --privileged --cap-add=NET_ADMIN --name ceng435server -v ./code:/app:rw ceng435:latest bash
Client container:
docker run -t -i --rm --privileged --cap-add=NET_ADMIN --name ceng435client -v ./code:/app:rw ceng435:latest bash
In the server container, navigate to the objects directory and generate test files:
cd /app/obj
../generateobjects.sh
This creates:
- 10 small files (~10KB each):
small-0.obj
tosmall-9.obj
- 10 large files (~10MB each):
large-0.obj
tolarge-9.obj
- Corresponding MD5 checksum files
Use Linux Traffic Control (tc
) to simulate various network conditions:
Add delay:
tc qdisc add dev eth0 root netem delay 100ms
Add packet loss:
tc qdisc add dev eth0 root netem loss 5%
Add corruption:
tc qdisc add dev eth0 root netem corrupt 1%
Add duplication:
tc qdisc add dev eth0 root netem duplicate 2%
Add reordering:
tc qdisc add dev eth0 root netem delay 10ms reorder 25% 50%
Remove all rules:
tc qdisc del dev eth0 root
Server (in server container):
cd /app/tcp
python3 tcpserver.py
Client (in client container):
cd /app/tcp
python3 tcpclient.py
Server (in server container):
cd /app/selectiveRepeat
python3 server.py
Client (in client container):
cd /app/selectiveRepeat
python3 client.py
The project includes comprehensive performance analysis capabilities:
- Total transfer time for all 20 files
- Individual file transfer times
- Throughput (bytes/second)
- Packet loss and retransmission statistics
- File integrity verification
- Delay: 0ms, 25ms, 50ms, 100ms, 200ms
- Packet Loss: 0%, 1%, 2%, 5%, 10%
- Corruption: 0%, 0.1%, 0.5%, 1%
- Duplication: 0%, 1%, 2%, 5%
- Reordering: 0%, 5%, 10%, 25%
- TCP performs better under normal conditions due to optimized implementation
- UDP Selective Repeat shows better performance under high packet loss
- Interleaving in UDP implementation provides more balanced file completion times
- Both protocols maintain data integrity under all tested conditions
- Simplicity: Leverages TCP's built-in reliability
- Sequential Transfer: Files sent one after another
- Automatic Flow Control: TCP handles congestion control
- Error Recovery: Automatic retransmission by TCP stack
- Custom Reliability: Implements ARQ protocol from scratch
- Parallel Transfer: Multiple files transferred simultaneously
- Adaptive Window: Dynamic window size based on network conditions
- Interleaving: Chunks from different files interleaved for balanced completion
- Congestion Control: Custom implementation with window size adjustment
Both implementations include robust file integrity verification:
- MD5 Checksums: Pre-computed checksums for all test files
- Automatic Verification: Clients verify received files against expected checksums
- Mismatch Detection: Reports any corrupted or missing files
- Complete Transfer Confirmation: Ensures all 20 files are received correctly
- Ubuntu 22.04 base image
- Python 3 for implementation
- Network tools:
tc
,ping
,netstat
,ss
- Development tools:
vim
,git
,curl
- Local
code/
directory mounted to/app/
in containers - Local
examples/
directory mounted to/examples/
in containers - Changes made locally are immediately available in containers
- Persistent storage for development work
- Transfer times logged to
ten.txt
- Console output for real-time monitoring
- Checksum verification results
- Network condition impact analysis
- Connection Refused: Ensure server is running before starting client
- Permission Denied: Check that containers have proper network privileges
- File Not Found: Verify test files are generated in
/app/obj/
- Checksum Mismatch: May indicate network corruption or implementation bug
- Server IP: Use
172.17.0.2
(default Docker bridge) or container hostname - Port: 65432 (configurable in source code)
- Firewall: Docker handles port forwarding automatically
- Chunk Size: Adjustable in source code for different network conditions
- Window Size: Configurable for UDP implementation
- Timeout Values: Tunable based on network latency
- Buffer Sizes: Can be adjusted for memory/performance trade-offs
When modifying the code:
- Test both TCP and UDP implementations
- Verify file integrity after transfers
- Test under various network conditions
- Update documentation for any protocol changes
- Ensure compatibility with existing test infrastructure
- Linux Traffic Control Manual
- TC Tutorial
- RFC 793 (TCP Specification)
- RFC 768 (UDP Specification)
- Computer Networks: A Systems Approach (Peterson & Davie)