|
1 | 1 | # Flex Net Sim Backend API |
2 | 2 |
|
3 | | -[](https://github.com/MirkoZETA/FlexNetSim-API) |
| 3 | +[](https://github.com/MirkoZETA/FlexNetSim-API) |
4 | 4 |  |
5 | 5 | [](https://github.com/MirkoZETA/FlexNetSim-API/blob/master/LICENSE) |
6 | 6 | [](https://github.com/MirkoZETA/FlexNetSim-API/actions/workflows/fns-api-workflow.yml) |
7 | | -[](https://mirkozeta.github.io/FlexNetSim-API/coverage/) |
| 7 | +[](https://mirkozeta.github.io/FlexNetSim-API/coverage/) |
8 | 8 |
|
9 | 9 | A lightweight API for running optical network simulations with [Flex Net Sim C++](https://gitlab.com/DaniloBorquez/flex-net-sim). |
10 | 10 |
|
@@ -34,13 +34,13 @@ For development and deployment instructions for this API, refer to [README_DEV.m |
34 | 34 |
|
35 | 35 | ### `/run_simulation` (POST) |
36 | 36 |
|
37 | | -Runs a network simulation with the provided parameters. |
| 37 | +Runs a network simulation with the provided parameters and returns complete results. |
38 | 38 |
|
39 | 39 | #### Request Parameters |
40 | 40 |
|
41 | 41 | | Parameter | Type | Description | Allowed Values & Constraints | Default | |
42 | 42 | |---------------|---------|----------------------------|-------------------------------------------------|-----------| |
43 | | -| `algorithm` | `string` | RSA algorithm | `FirstFit`, `ExactFit` | `FirstFit` | |
| 43 | +| `algorithm` | `string` | RSA algorithm | `FirstFit`, `BestFit` | `FirstFit` | |
44 | 44 | | `networkType` | `integer` | Network type | Only `1` (EON) supported | `1` | |
45 | 45 | | `goalConnections` | `integer` | Target connection requests | Must be > 0 and < 10,000,000 | `100000` | |
46 | 46 | | `confidence` | `float` | Confidence level | Must be > 0 and < 1.0 | `0.05` | |
@@ -74,9 +74,84 @@ curl -X POST -H "Content-Type: application/json" \ |
74 | 74 | https://fns-api-cloud-run-787143541358.us-central1.run.app/run_simulation |
75 | 75 | ``` |
76 | 76 |
|
| 77 | +#### Response Format |
| 78 | + |
| 79 | +```json |
| 80 | +{ |
| 81 | + "status": "success", |
| 82 | + "data": "simulation results as text..." |
| 83 | +} |
| 84 | +``` |
| 85 | + |
| 86 | +#### Response Codes |
| 87 | + |
| 88 | +- `200 OK`: Success |
| 89 | +- `400 Bad Request`: Invalid parameters |
| 90 | +- `500 Internal Server Error`: Server-side error |
| 91 | + |
| 92 | +### `/run_simulation_stream` (POST) |
| 93 | + |
| 94 | +Runs a network simulation with the provided parameters and streams results in real-time using Server-Sent Events (SSE). |
| 95 | + |
| 96 | +#### Request Parameters |
| 97 | + |
| 98 | +Same parameters as `/run_simulation` endpoint. |
| 99 | + |
| 100 | +#### Example: Streaming with Default Parameters |
| 101 | + |
| 102 | +```bash |
| 103 | +curl -N -X POST -H "Content-Type: application/json" -d '{}' \ |
| 104 | + https://fns-api-cloud-run-787143541358.us-central1.run.app/run_simulation_stream |
| 105 | +``` |
| 106 | + |
| 107 | +#### Example: Streaming with Custom Parameters |
| 108 | + |
| 109 | +```bash |
| 110 | +curl -N -X POST -H "Content-Type: application/json" \ |
| 111 | +-d '{ |
| 112 | + "algorithm": "FirstFit", |
| 113 | + "networkType": 1, |
| 114 | + "goalConnections": 5000000, |
| 115 | + "confidence": 0.05, |
| 116 | + "lambdaParam": 120, |
| 117 | + "mu": 1, |
| 118 | + "network": "NSFNet", |
| 119 | + "bitrate": "fixed-rate" |
| 120 | +}' \ |
| 121 | +https://fns-api-cloud-run-787143541358.us-central1.run.app/run_simulation_stream |
| 122 | +``` |
| 123 | + |
| 124 | +#### Response Format |
| 125 | + |
| 126 | +The endpoint returns a stream of Server-Sent Events with the following event types: |
| 127 | + |
| 128 | +1. **Start Event**: |
| 129 | + ``` |
| 130 | + event: start |
| 131 | + data: {"status": "started", "message": "Simulation started"} |
| 132 | + ``` |
| 133 | + |
| 134 | +2. **Data Events** (multiple events, one per line of output): |
| 135 | + ``` |
| 136 | + event: data |
| 137 | + data: {"status": "running", "message": "Line of simulation output"} |
| 138 | + ``` |
| 139 | + |
| 140 | +3. **End Event**: |
| 141 | + ``` |
| 142 | + event: end |
| 143 | + data: {"status": "completed", "message": "Simulation completed"} |
| 144 | + ``` |
| 145 | + |
| 146 | +4. **Error Event** (only if an error occurs): |
| 147 | + ``` |
| 148 | + event: error |
| 149 | + data: {"status": "error", "message": "Error description", "error": "Detailed error"} |
| 150 | + ``` |
| 151 | + |
77 | 152 | #### Response Codes |
78 | 153 |
|
79 | | -- `200 OK`: Success. Returns `{"output": "...", "error": ""}` |
| 154 | +- `200 OK`: Success (stream starts) |
80 | 155 | - `400 Bad Request`: Invalid parameters |
81 | 156 | - `500 Internal Server Error`: Server-side error |
82 | 157 |
|
|
0 commit comments