This project implements a small, TCP-like reliable streaming protocol on top of UDP using a provided network simulator (LossyUDP). The goal is to understand how reliable transport works when the network can drop, reorder, or corrupt packets.
The main abstraction is the Streamer class, which behaves similarly to a very simplified TCP connection.
Streamer provides a reliable byte stream over an unreliable network:
send(bytes)reliably sends data to the peerrecv()returns the next complete message (in order)close()performs a graceful connection teardown
All reliability is implemented at the application level, on top of UDP.
Large messages are split into packets small enough to fit within the UDP payload limit. Each message is broken into fixed-size chunks and reassembled on the receiver side.
Each packet contains:
flag— DATA, ACK, or FINmsg_id— message identifierseq— sequence number within the messagetotal— total number of packets in the messagemd5(header + payload)— corruption detectionpayload
Packets include an MD5 hash of the header and payload. If a packet fails verification, it is dropped and later retransmitted by the sender.
Packets may arrive out of order. The receiver buffers out-of-order packets and delivers data only when all earlier packets have arrived. ACKs are cumulative (Go-Back-N style).
The sender maintains a global window of outstanding packets, uses a single timeout based on the current “base” packet, and retransmits all unacknowledged packets on timeout. This allows multiple packets to be in flight at once.
close() performs a FIN/ACK-style shutdown similar to TCP:
- Waits for all sent data to be acknowledged
- Sends a FIN packet
- Retransmits FIN if needed until ACKed
- Waits for the peer’s FIN
- Enters a short TIME-WAIT period
- Shuts down cleanly
-
streamer.py
The reliable transport protocol implementation. -
lossy_socket.py
Provided UDP simulator that can drop, delay, reorder, or corrupt packets. -
test.py
Simple test program that sends data between two endpoints.
Open two terminals.
python3 test.py 8000 8001 1python3 test.py 8000 8001 2The program sends sequences of numbers between the two processes and verifies correctness.
The original project skeleton and assignment design were created by Steve Tarzia. This implementation builds on his provided framework and simulator.
This project demonstrates how core transport-layer ideas (chunking, sequencing, acknowledgements, retransmissions, and connection teardown) can be built on top of an unreliable network. It is intentionally simpler than TCP, but captures the essential mechanics of reliable streaming communication.