This project implements a time synchronization system consisting of master and slave nodes. It allows for dynamic addition and removal of nodes without interrupting any of the procedures.
The Berkeley Algorithm is a time synchronization algorithm that was developed by Gustave Berkeley in 1989. It is used to synchronize the time of different nodes in a distributed system. The algorithm works by calculating the time difference between the master node and each slave node, and then adjusting the time of the slave nodes accordingly.
- Dynamic Node Management: The system supports adding and removing nodes dynamically.
- Master-Slave Architecture: The system follows a master-slave architecture for time synchronization.
- Master Node Election: The system automatically elects a master node from available slave nodes when the current master node goes offline.
- Time Synchronization: Slave nodes synchronize their time with the master node periodically.
- Error Handling: Error handling mechanisms are in place for network communication and node operations.
-
Installation: No installation is required. Simply clone the repository to your local machine.
git clone https://github.com/Gennadion/berkeley-algorithm.git
-
Running the System:
-
Execute
runner.py
to start the system.python runner.py
-
The master node will be started automatically, while slave nodes can be added dynamically during runtime.
-
-
Dynamic Node Management:
- Current logic adds a Slave Node every 20 seconds and removes a Slave Node every 30 seconds.
- You can modify the logic in
runner.py
to add or remove nodes at different intervals. - You can also add or remove nodes manually using the
add_node
andremove_node
methods inrunner.py
.
Contributions to the project are welcome! Feel free to submit issues or pull requests if you find any bugs or have suggestions for improvements.
This project is licensed under the MIT License. See the LICENSE file for details.