A simple distributed chat system using UDP message flooding and Lamport logical clocks for message ordering.
This project demonstrates inter-process communication (IPC) in a distributed system where multiple processes communicate through a neighbor-based network topology. Messages are flooded across the network and delivered in a consistent order using Lamport timestamps.
- UDP-based communication between processes
- Message flooding through configurable neighbor topology
- Lamport clocks for causal message ordering
- Duplicate detection to prevent message re-delivery
- Python 3.7+
- tmux (optional, for automated multi-process launch)
cd src
# Start each process in a separate terminal
python3 app.py p1
python3 app.py p2
python3 app.py p3cd src
./Launcher.shType a message in any process terminal to broadcast it to all other processes.
Edit src/config.py to modify the network topology:
PROCESSES = {
'p1': {'host': 'localhost', 'port': 5000, 'neighbors': ['p2']},
'p2': {'host': 'localhost', 'port': 5001, 'neighbors': ['p1', 'p3']},
'p3': {'host': 'localhost', 'port': 5002, 'neighbors': ['p2']},
}src/
├── app.py # Entry point
├── Process.py # Core process logic (networking, flooding, ordering)
├── config.py # Network topology definition
└── Launcher.sh # tmux launcher script
- Each process listens on a UDP port and connects to its defined neighbors
- When a user sends a message, it's assigned a Lamport timestamp and flooded to neighbors
- Each receiving process updates its clock, forwards the message to other neighbors, and queues it for delivery
- Messages are delivered in timestamp order (ties broken by sender ID)