Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chugunov/clocks
Time, Clocks, and the Ordering of Events
https://github.com/chugunov/clocks
distributed-systems lamport-clock logical-clock
Last synced: 14 days ago
JSON representation
Time, Clocks, and the Ordering of Events
- Host: GitHub
- URL: https://github.com/chugunov/clocks
- Owner: chugunov
- Created: 2024-07-12T15:26:16.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-15T08:18:34.000Z (5 months ago)
- Last Synced: 2024-10-19T14:27:29.152Z (2 months ago)
- Topics: distributed-systems, lamport-clock, logical-clock
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Lamport clocks simulation
This project simulates a distributed system using Lamport clocks and visualizes the space-time diagram of the processes. The simulation reads an input file that describes the sequence of operations for each process, including local events, send, and receive operations. The resulting events are plotted on a space-time diagram to visualize the causality between events in different processes.
Heavily inspired by [Time, Clocks, and the Ordering of Events in a Distributed System](https://lamport.azurewebsites.net/pubs/time-clocks.pdf)
## Usage
To run the simulation, you need to provide an input file that describes the sequence of operations for each process. The format is as follows:
```txt
p0: s1 r1 l r1
p1: s0 s2 r0 l s2 s0 l r2
p2: l s1 r1 r1
```Each line represents a process and its sequence of operations:
- `sN` - send a message to process N
- `rN` - receive a message from process N
- `l` - local event### Command Line Flags
- `-i` : Path to the input file containing the processes sequence.
- `-o` : Path to the output file for the space-time diagram.## Command example
```sh
$ go run cmd/main.go -i input.txt -o space_time_diagram.svg
Space-time diagram saved as space_time_diagram.svg
```## Output plot example
![img](./space_time_diagram.svg)