Skip to content

About

Assignment 1 - Network Applications

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

📡 ReliableUDP

File transfer over UDP: chunked sending, a custom application protocol, and MD5 integrity checks, built on a reliable UDP connection layer.

C++ Windows Visual Studio UDP


📖 Overview

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).

✨ Features

  • 📦 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 pack so 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)

🔄 How It Works

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
Loading

Packet layout

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)

🚀 Getting Started

Prerequisites

Build

  1. Clone the repository:
    git clone https://github.com/Happytyagi1/ReliableUDP.git
  2. Open ReliableUDP.slnx in Visual Studio.
  3. Select Build → Build Solution.

Run

Start the server first (no arguments). It listens on UDP port 30000:

ReliableUDP.exe

Then start the client with the server's IP address. It uses port 30001:

ReliableUDP.exe 127.0.0.1

The client asks for:

  1. The path of the file to send
  2. 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.

📁 Project Structure

.
├── ReliableUDP.slnx          # Visual Studio solution
└── ReliableUDP/
    ├── Net.h                 # Sockets, addresses, reliable connection, flow control
    └── ReliableUDP.cpp       # File transfer protocol, MD5, client/server main loop

🙏 Credits

  • 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

About

Assignment 1 - Network Applications

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages