Prerequisites
Before you begin, ensure you have the following installed:- Java 11 or later - Required for client and server
- Go 1.7 or later - Required for the router
- Maven - For building Java components
Setup the Router
The router simulates network conditions and forwards packets between client and server.- Linux
- MacOS
- Windows
- Build from Source
The router will listen on port 3000 by default. The
--drop-rate=0.1 simulates 10% packet loss, and --max-delay=10ms adds up to 10ms of random delay.Running the Server
Open a new terminal and start the server:Run the Server
Start the server program:When prompted, enter the server command:Parameters:
-v- Verbose mode (shows detailed logging)-p 8080- Server listens on port 8080 (default)-d ./data- Directory for file storage (default is current directory)
Running the Client
Open another terminal and make requests using the client:Start the Interactive Client
Run the client program:The client will prompt you for commands interactively.
Make a GET Request
When prompted “Enter your command..”, type:This retrieves a directory listing from the server. When asked if you want to continue, type
yes.Understanding the Protocol Flow
When you run a request, here’s what happens under the hood:Connection Establishment
The client initiates a three-way handshake:Server responds with SYN-ACK, client sends ACK to complete the handshake.
Windowed Transmission
The client sends up to 100 packets (the window size) without waiting for ACKs:
Selective Acknowledgment
The server sends ACKs for received packets and NACKs for missing ones:
- ACK (type=1): Acknowledges receipt of a packet
- NACK (type=4): Requests retransmission of a missing packet
Command Reference
Client Commands
GET Request
GET Request
Syntax:Options:
-v- Verbose mode (prints headers)-h key:value- Add HTTP headers-o filename- Save output to file
POST Request
POST Request
Syntax:Options:
-v- Verbose mode-h key:value- Add HTTP headers-d data- Inline data-f filename- Read data from file-o filename- Save output to file
Router Commands
--port- Port number (default: 3000)--drop-rate- Packet drop probability 0.0-1.0 (default: 0.0)--max-delay- Maximum packet delay (default: 0)--seed- Random seed for reproducible tests
Testing Different Network Conditions
Try these router configurations to test the protocol under different conditions:Troubleshooting
Connection timeout
Connection timeout
- Ensure the router is running on port 3000
- Check that the server is running and listening on the specified port
- Verify firewall settings allow UDP traffic
Packets not being received
Packets not being received
- Check the router’s drop rate (lower it for testing)
- Increase the timeout value in the protocol
- Look at router logs for packet forwarding information
Java compilation errors
Java compilation errors
- Ensure you’re using Java 11 or later
- Run
mvn clean installto fetch all dependencies - Check that
JAVA_HOMEis set correctly
Next Steps
Architecture Overview
Learn how the three components work together
Client Usage Guide
Explore all client features and commands
Server Setup
Configure and customize the server
API Reference
Dive into the protocol implementation details