Reliable File Transfer Protocol Built On (Unreliable) UDP

May. 2025

Built a reliable file transfer protocol on top of UDP using a Selective Reject sliding window. The project includes a client and forked server that handle packet loss, reordering, and corruption via checksums, cumulative ACKs (RR), targeted NACKs (SREJ), and an EOF/ACK teardown.

Sliding Window Protocol diagram
Networks Protocol design UDP C

Project Overview

This project implements a TCP-like reliable file transfer protocol built on top of UDP, written entirely in C. Because UDP does not guarantee delivery, ordering, or data integrity, the system adds its own reliability mechanisms to support correct file transfer over an unreliable network. The protocol uses a selective-reject sliding window to keep multiple packets in flight at once, cumulative acknowledgments (RR) to advance the window efficiently, and targeted retransmissions (SREJ) to recover from packet loss or corruption without resending unaffected data. A checksum is used to detect bit errors, and an explicit EOF/ACK handshake ensures both sides agree when a transfer has completed. The system consists of a concurrent UDP server that forks per client and maintains a circular send window, and a client that buffers out-of-order packets, requests retransmissions for missing data, and writes the reconstructed file to disk. Robustness is verified using controlled packet loss and corruption injection, confirming correct file transfer across varying error rates, window sizes, and file sizes. This project emphasizes low-level networking, protocol state machines, and fault-tolerant C programming, providing hands-on experience with how transport-layer reliability and flow control are implemented beneath TCP.

What I Did