File transfer over UDP: chunked sending, a custom application protocol, and MD5 integrity checks, built on a reliable UDP connection layer.
UDP is fast but makes no promises: packets can be lost, duplicated or arrive out of order. This project starts from Glenn Fiedler's Networking for Game Programmers reliability example (connection handling, sequence numbers, acks, RTT and flow control) and adds an application-level file transfer protocol on top of it.
A client reads a file, splits it into 1 KB chunks and streams them to the server. The server rebuilds the file in memory, checks that every chunk arrived and that the MD5 checksum matches, and only then writes the file to disk.
Built for the Network Applications course (Assignment 1).
- 📦 Chunked transfer: files are split into 1024-byte chunks, each tagged with its index
- 🧾 Custom packet types:
HANDSHAKE,FILE_INFO,FILE_DATA,FILE_DONE, packed with#pragma packso the binary layout is exact - 🔐 MD5 integrity check: a self-contained MD5 implementation (no external libraries) verifies the rebuilt file
- 🧩 Missing-chunk detection: the server tracks which chunks arrived and rejects incomplete files
- 💥 Corruption test mode: optionally flips a byte in chunk #2 to prove the checksum catches it
- ⏱️ Throughput report: the client prints transfer time and speed in Mbps
- 🚦 Flow control: switches between good and bad send modes based on round-trip time (250 ms threshold)
sequenceDiagram
participant C as Client
participant S as Server
C->>S: HANDSHAKE
Note over C,S: Connection established
C->>S: FILE_INFO (file name, size, chunk size)
loop for each 1 KB chunk
C->>S: FILE_DATA (chunk index + bytes)
end
C->>S: FILE_DONE (file size + MD5 checksum)
Note over S: All chunks received?<br/>MD5 matches?
S-->>S: ✅ Save file / ❌ Report failure
| Packet | Fields |
|---|---|
FILE_INFO |
type · fileSize (u32) · chunkSize (u32) · fileNameLen (u8) · file name bytes |
FILE_DATA |
type · chunkIndex (u32) · chunkSize (u32) · chunk bytes |
FILE_DONE |
type · fileSize (u32) · checksum (16-byte MD5) |
- Windows 10/11
- Visual Studio 2022+ with the Desktop development with C++ workload
- Clone the repository:
git clone https://github.com/Happytyagi1/ReliableUDP.git
- Open
ReliableUDP.slnxin Visual Studio. - Select Build → Build Solution.
Start the server first (no arguments). It listens on UDP port 30000:
ReliableUDP.exeThen start the client with the server's IP address. It uses port 30001:
ReliableUDP.exe 127.0.0.1The client asks for:
- The path of the file to send
- Whether to enable the corruption test (
1= yes,0= no)
The server prints File received correctly. and saves the file under its original name, or reports File transfer FAILED if a chunk is missing or the checksum does not match.
.
├── ReliableUDP.slnx # Visual Studio solution
└── ReliableUDP/
├── Net.h # Sockets, addresses, reliable connection, flow control
└── ReliableUDP.cpp # File transfer protocol, MD5, client/server main loop
- Reliability layer based on Glenn Fiedler's Networking for Game Programmers series.
- MD5 algorithm follows RFC 1321.
Made with ❤️ by Happy Tyagi and Nate Neal