Skip to content

AndMelox/Clock-Synchronization-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Clock Synchronization Project

This project consists of two main components: node-client and node-coordinator. The goal is to synchronize the clocks of multiple node-client instances using a node-coordinator.

Project Structure

node-client/ ├── clock-endpoints.js ├── clock.js ├── Dockerfile ├── index.js ├── logs.js ├── package.json └── public/ ├── index.html └── index.js

node-coordinator/ ├── .env ├── clients-endpoints.js ├── index.js ├── logs.js ├── package.json └── public/ ├── index.html ├── index.js └── socket-server.js

Setup

1. Configure IP Addresses

  1. Open the .env file in the node-coordinator folder and change the IP to your machine's IP address.

  2. Open the index.js file in the node-coordinator/public folder and replace the IP with your machine's IP address:

    fetch('http://your_ip:5000/createInstance')
    fetch('http://your_ip:5000/syncNodes', { method: 'PUT' })

2. Build and Run Containers

node-client

  1. Navigate to the node-client folder:

    cd node-client
  2. Build the Docker image:

    docker build -t node-client .

node-coordinator

  1. Navigate to the node-coordinator folder:

    cd node-coordinator
  2. Install dependencies and start the server:

    npm install
    npm start

3. Open in Browser

Open your browser and go to http://your_ip:5000 to view the node-coordinator interface.

Features

  • node-client: Provides endpoints to get and update the clock of each instance.
  • node-coordinator: Coordinates clock synchronization across multiple node-client instances.

Endpoints

node-client

  • GET /clock: Retrieves the current time of the clock.
  • PUT /clock: Updates the clock with a specified adjustment.

node-coordinator

  • POST /clients: Registers a new client.
  • GET /createInstance: Creates a new node-client instance.
  • PUT /syncNodes: Synchronizes the clocks of all registered instances.

Notes

  • Ensure that Docker is installed and running on your machine.
  • Make sure the configured IP addresses are accessible on your network.

Authors

GitHub
GitHub
GitHub

🔗 Contact Links

instagram

linkedin

gmail

twitter

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published