Welcome to Selective Repeat UDP
Selective Repeat UDP is a robust implementation of HTTP over UDP that provides reliable data transfer using the Selective Repeat Automatic Repeat reQuest (ARQ) protocol. This project demonstrates how to build a reliable transport layer on top of the unreliable UDP protocol, making it suitable for applications that require guaranteed delivery without the overhead of TCP.What is Selective Repeat ARQ?
Selective Repeat is a sliding window protocol that allows the sender to transmit multiple packets without waiting for individual acknowledgments. Unlike Go-Back-N, Selective Repeat retransmits only those packets that are suspected to be lost or corrupted, making it more efficient in networks with higher error rates.HTTP Client (httpc)
A curl-like HTTP client that sends GET and POST requests over UDP with reliable delivery guarantees
HTTP File Server (httpfs)
A file server that handles HTTP requests over UDP, supporting file retrieval and storage operations
Network Router
A simulated network router written in Go that introduces realistic network conditions for testing
Reliable Protocol
Custom protocol implementation with windowing, acknowledgments, timeouts, and retransmission logic
Key Features
Reliable Data Transfer
The implementation ensures reliable data transfer over UDP through:- Selective Repeat ARQ: Only lost packets are retransmitted, not the entire window
- Sliding Window Protocol: Window size of 100 packets for efficient throughput
- Sequence Numbers: Each packet is uniquely identified for proper ordering
- Acknowledgments & NACKs: Positive acknowledgments (ACK) for received packets and negative acknowledgments (NACK) for missing packets
Three-Way Handshake
Connection establishment follows a TCP-like three-way handshake:Packet Structure
Each packet contains the following fields:Packets have a minimum length of 11 bytes and maximum length of 1035 bytes (11 byte header + 1024 byte payload)
| Field | Size | Description |
|---|---|---|
| Type | 1 byte | Packet type (0=Data, 1=ACK, 2=SYN, 3=SYN-ACK, 4=NACK, 6=FIN) |
| Sequence Number | 4 bytes | Packet sequence number |
| Peer Address | 4 bytes | IPv4 address |
| Peer Port | 2 bytes | Port number |
| Payload | 0-1024 bytes | Data payload |
HTTP Over UDP Protocol
The project implements a custom HTTP variant called HTTPFC/1.0 that works over the reliable UDP layer:Advanced Features
Automatic Retransmission
Packets are automatically retransmitted if acknowledgment is not received within the timeout period (50ms)
Out-of-Order Handling
The receiver buffers out-of-order packets and sends NACKs for missing packets to trigger selective retransmission
Flow Control
Sliding window mechanism prevents sender from overwhelming the receiver
Connection Management
Proper connection setup and teardown with SYN/FIN packets
Architecture Overview
The system consists of three main components:- Client (Java): Implements the HTTP client with reliable UDP protocol
- Server (Java): File server that responds to HTTP requests over UDP
- Router (Go): Simulates network conditions including packet loss, delays, and reordering
Protocol Flow Example
Here’s how a typical request-response flow works:Connection Establishment
Client sends SYN packet to server, receives SYN-ACK, and sends ACK to complete handshake
Windowed Data Transfer
Client sends up to 100 packets (window size) without waiting for acknowledgments
Window Sliding
As packets are acknowledged, the window slides forward allowing more packets to be sent
Use Cases
This project is ideal for:- Learning: Understanding how reliable transport protocols work at a fundamental level
- Network Research: Experimenting with ARQ protocols and network conditions
- Protocol Development: Building custom protocols on top of UDP
- Testing: Simulating unreliable networks for application testing
Next Steps
Quickstart Guide
Get up and running with the client and server in minutes
Architecture Overview
Learn about the system architecture and components