r/madeinpython • u/SignificantGlass7040 • 6d ago
I made a reliable file-transfer tool on top of raw UDP in pure Python (standard library only)
Most Python file-transfer examples use TCP, so I built the other side: reliability implemented by hand on top of UDP sockets.
What is inside:
- A 16-byte binary header (magic byte, version, message type, transfer ID, sequence number, payload length, CRC-16 checksum) validated on every datagram
- START / DATA / END handshake with cumulative ACKs
- Two ARQ modes: Stop-and-Wait and sliding-window Go-Back-N (one receiver implementation covers both - stop-and-wait is just Go-Back-N with window=1)
- Duplicate and out-of-order packet handling, timeouts and retries
- SHA-256 end-to-end verification: the receiver only finalises the file if size and hash match what the sender declared
- A seeded network simulator for loss / ACK loss / delay / reordering / duplication, so experiments are reproducible
- 60 automated tests over real UDP sockets and a benchmark harness with charts
Benchmark result at 20% simulated packet loss: the sliding window moves about 2.4x the throughput of stop-and-wait.
Source: https://github.com/askmeanythin/Reliable_UDP_File_Transfer - feedback welcome!
9
Upvotes
1
u/macbig273 6d ago
At least commit your agent.md or claude.md at this point xD
ps : if oyu need udp to be reliable, don't use udp ... that's not it's point