|
1 | | -# Rust Simulation UI - Web App |
| 1 | +# Leios visualization UI |
2 | 2 |
|
3 | | -This UI web app is designed to read and display simulation traces generated by |
4 | | -the `sim-rs` project. |
| 3 | +User interface to display Leios traffic in traces produced by simulations, |
| 4 | +prototypes and node implementations. |
5 | 5 |
|
6 | | -## Prerequisites |
| 6 | +## Getting started |
7 | 7 |
|
8 | | -Before you can run the UI, ensure you have the following installed: |
| 8 | +Example traces are available via Git LFS. Fetch them first: |
9 | 9 |
|
10 | | -- [Bun](https://bun.sh/) - A fast JavaScript runtime. |
| 10 | +```bash |
| 11 | +git lfs fetch |
| 12 | +git lfs checkout |
| 13 | +``` |
11 | 14 |
|
12 | | -## Setup Instructions |
| 15 | +Install dependencies and build the project with: |
13 | 16 |
|
14 | | -1. **Install Bun** |
| 17 | +```bash |
| 18 | +npm install |
| 19 | +npm run build |
| 20 | +``` |
15 | 21 |
|
16 | | - Follow the instructions on the [Bun website](https://bun.sh/) to install Bun |
17 | | - on your system. |
| 22 | +Or run the development server with: |
18 | 23 |
|
19 | | -2. **Generate a Trace** |
| 24 | +```bash |
| 25 | +npm start |
| 26 | +``` |
20 | 27 |
|
21 | | - Before running the UI, you need to prepare a scenario for it to visualize. Add the following to a file named `public/scenarios.json`: |
| 28 | +## Add a scenario from sim-rs |
22 | 29 |
|
23 | | - ```json |
24 | | - { |
25 | | - "scenarios": [ |
26 | | - { |
27 | | - "name": "My Scenario", |
28 | | - "topology": "topologies/thousand.yaml", |
29 | | - "duration": 30.0, |
30 | | - "trace": "traces/myscenario.jsonl" |
31 | | - } |
32 | | - ] |
33 | | - } |
34 | | - ``` |
| 30 | +To prepare a scenario to visualize, find or add the topology to the public directory, for example: |
35 | 31 |
|
36 | | - Now add that topology to the public directory: |
| 32 | +```sh |
| 33 | +mkdir -p public/topologies |
| 34 | +ln -sr ../sim-rs/test_data/small.yaml public/topologies/small.yaml |
| 35 | +``` |
37 | 36 |
|
38 | | - ```sh |
39 | | - mkdir -p public/topologies |
40 | | - cp ../sim-rs/test-data/thousand.yaml public/topologies |
41 | | - ``` |
| 37 | +And generate a trace to visualize using the built `sim-rs`, for example using the CIP scenario: |
42 | 38 |
|
43 | | - And generate a trace to visualize from the `sim-rs` directory: |
| 39 | +```bash |
| 40 | +mkdir -p public/traces |
| 41 | +cat ../analysis/sims/cip/experiments/NA,0.200/config.yaml \ |
| 42 | + | jq '."tx-start-time" = 20' > public/traces/config-200txkbs.json |
| 43 | +../sim-rs/target/release/sim-cli -p public/traces/config-200txkbs.json public/topologies/small.yaml public/traces/small-200txkbs.jsonl -s 120 |
| 44 | +``` |
44 | 45 |
|
45 | | - ```bash |
46 | | - mkdir -p ../ui/public/traces |
47 | | - cargo run --release test_data/thousand.yaml ../ui/public/traces/myscenario.jsonl -s 30 |
48 | | - ``` |
| 46 | +You might want to filter out `Cpu` events (not visualized) and, in case you want to store it, use gzip and git lfs: |
49 | 47 |
|
50 | | -3. **Run the UI** |
| 48 | +```bash |
| 49 | +grep -v 'Cpu' < public/traces/small-200txkbs.jsonl > public/traces/small-200txkbs-nocpu.jsonl |
| 50 | +gzip public/traces/small-200txkbs-nocpu.jsonl |
| 51 | +git lfs track public/traces/small-200txkbs-nocpu.jsonl.gz |
| 52 | +``` |
51 | 53 |
|
52 | | - With Bun installed and the trace generated, navigate to the UI project |
53 | | - directory and start the development server: |
| 54 | +Then update `public/scenarios.json` accordingly: |
54 | 55 |
|
55 | | - ```bash |
56 | | - bun dev |
57 | | - ``` |
| 56 | +```json |
| 57 | +{ |
| 58 | + "scenarios": [ |
| 59 | + { |
| 60 | + "name": "200 TxkB/s", |
| 61 | + "topology": "topologies/small.yaml", |
| 62 | + "duration": 120, |
| 63 | + "trace": "traces/small-200txkbs-nocpu.jsonl.gz" |
| 64 | + } |
| 65 | + ] |
| 66 | +} |
| 67 | +``` |
58 | 68 |
|
59 | | - This will launch the simulation in your browser. |
60 | | - |
61 | | -## Additional Information |
62 | | - |
63 | | -- Ensure that the path to the trace file (`output/messages.jsonl`) is correctly |
64 | | - set in the UI project. This is typically defined in a utility file such as |
65 | | - `ui/src/app/api/utils.ts`. |
66 | | - |
67 | | -- If you encounter any issues, check the console for error messages and ensure |
68 | | - all dependencies are correctly installed. |
| 69 | +Now add that |
0 commit comments