← Back to projects

File Transfer over Raw TCP

A file transfer system built from scratch: chunking, loss recovery and integrity checks, with live dashboards.

PythonTCP socketsFlaskSHA-256HTML/JS
File Transfer over Raw TCP screenshot

The problem

TCP hides most of what makes reliable delivery work. To really understand it, the goal was to rebuild the mechanics from scratch: splitting data into numbered chunks, surviving lost and out-of-order packets, and proving the file arrived intact. Built for BigEndian Challenge 1.

Approach

  • Built the server and client on Python's raw socket module with no helper libraries, including a receive loop that reads exact byte counts, since TCP is a stream with no message boundaries.
  • Split each file into 1024-byte chunks with sequence numbers, and shuffled them before sending to simulate out-of-order delivery.
  • Added packet-drop simulation on the server, either random (0 to 90% per chunk) or manual (choose exact chunks), with a control panel for it.
  • The client finds the missing sequence numbers and sends a NACK. The server resends only those chunks, and the loop repeats until nothing is missing.
  • The server computes a SHA-256 checksum of the original file and the client compares it with the reassembled file before accepting it.
  • Wrote two live web dashboards, one for the server (drop controls, chunk grid, log) and one for the client (upload and progress).

Results

  • End-to-end transfer that survives heavy simulated packet loss and still finishes with a verified checksum.
  • Application-layer sequencing and reassembly that works even when chunks arrive out of order.
  • Measures transfer speed end to end, including every retransmit round.
  • Integers are packed in big-endian byte order on the wire, using struct.pack.

At a glance

One transfer, with packet loss
  1. Client sends file

    4-byte size + data

  2. Server chunks it

    1024 B, shuffled

  3. Sends chunks

    some dropped on purpose

  4. Client sends NACK

    lists missing chunks

  5. Server resends

    until none are missing

  6. SHA-256 check

    verified by the client

Protocol from the project README. Retransmitted chunks are never dropped, so every transfer converges.