|
1 | 1 | # Flex Net Sim Backend API |
2 | 2 |
|
3 | | -Welcome to the Flex Net Sim Backend API repository. |
| 3 | +A lightweight API for running optical network simulations with [Flex Net Sim C++](https://gitlab.com/DaniloBorquez/flex-net-sim). |
4 | 4 |
|
5 | | -This is the **publicly accessible backend API** for the [Flex Net Sim](https://gitlab.com/DaniloBorquez/flex-net-sim) project. |
| 5 | +## Overview |
6 | 6 |
|
7 | | -This API provides a **hands-on demonstration**, enabling users to quickly execute pre-configured network simulations and gain an initial understanding of Flex Net Sim's capabilities. |
| 7 | +The FlexNetSim Backend API provides: |
8 | 8 |
|
9 | | -Through simple POST requests, initiated via command-line tools or the [playground page](www.in-progress.com), users can experiment with a defined set of parameters and algorithms. This allows for exploration of fundamental network simulation concepts using Flex Net Sim. |
| 9 | +- **Hands-on demonstration** of optical network simulation capabilities |
| 10 | +- **Simplified access** to core Flex Net Sim features |
| 11 | +- **Quick experimentation** with pre-configured network topologies and parameters |
10 | 12 |
|
11 | | -It is important to note that **this API is intentionally designed as a limited demonstration platform**. It serves as a **simplified method of accessing** and showcasing the **basic functionalities** of Flex Net Sim. **It is not intended for complex simulations or for algorithm customization.** Algorithm customization is a core strength of Flex Net Sim, and this advanced capability is exclusively unlocked when working directly with **the library**. |
| 13 | +This API serves as an introduction to the full Flex Net Sim library, allowing users to explore basic network simulation concepts through simple HTTP requests. |
12 | 14 |
|
13 | | -The purpose of this API is to introduce users to Flex Net Sim and encourage exploration of **the full library** for advanced simulation tasks. **The full library** offers significantly greater power, flexibility, and customization potential. |
| 15 | +## Important Limitations |
14 | 16 |
|
15 | | -For users interested in progressing beyond this introductory API, comprehensive resources and documentation are available at the official [Flex Net Sim documentation](https://flex-net-sim-fork.readthedocs.io/stable/). |
| 17 | +This API is intentionally designed as a limited demonstration platform: |
16 | 18 |
|
17 | | -For **Development and Deployment Instructions** of this API (the playground itself), please refer to [README_DEV.md](README_DEV.md). |
| 19 | +- **Not intended** for complex simulations or algorithm customization |
| 20 | +- Provides access to **basic functionalities** only |
| 21 | +- For advanced simulation tasks, users should explore **the full library** |
| 22 | + |
| 23 | +For comprehensive resources, see the [Flex Net Sim documentation](https://flex-net-sim-fork.readthedocs.io/stable/). |
| 24 | + |
| 25 | +For development and deployment instructions for this API, refer to [README_DEV.md](.github/workflows/README_DEV.md). |
18 | 26 |
|
19 | 27 | ## API Endpoints |
20 | 28 |
|
21 | 29 | ### `/run_simulation` (POST) |
22 | 30 |
|
23 | | -This endpoint runs a Flex Net Sim simulation based on the parameters provided in the JSON request body. |
| 31 | +Runs a network simulation with the provided parameters. |
24 | 32 |
|
25 | | -**Request Body Parameters:** |
| 33 | +#### Request Parameters |
26 | 34 |
|
27 | | -| Parameter | Type | Description | Allowed Values | Default Value | Constraints | |
28 | | -| :---------------- | :-------------- | :----------------------------------------------------- | :---------------------------- | :------------ | :-------------------- | |
29 | | -| `algorithm` | `string` | Routing and spectrum assignment algorithm to use. | `FirstFit`, `ExactFit` | `FirstFit` | | |
30 | | -| `networkType` | `integer` | Type of optical network. | `1` | `1` | Only `1` (EON) available | |
31 | | -| `goalConnections`| `integer` | Target number of connection requests for the simulation.| | `100000` | Must be integer > 0 | |
32 | | -| `confidence` | `number (float)`| Confidence level for the simulation results. | | `0.05` | Must be > 0 | |
33 | | -| `lambdaParam` | `number (float)` | Arrival rate (lambda) of connection requests. | | `1.0` | Must be > 0 | |
34 | | -| `mu` | `number (float)`| Service rate (mu) of connection requests. | | `10.0` | Must be > 0 | |
35 | | -| `network` | `string` | Network topology to simulate. | `NSFNet`, `Cost239`, `EuroCore`, `GermanNet`, `UKNet` | `NSFNet` | | |
36 | | -| `bitrate` | `string` | Type of bitrate allocation. | `fixed-rate`, `flex-rate` | `bitrate` | | |
37 | | -| `K` | `integer` | Number of paths to consider. | | `3` | | |
| 35 | +| Parameter | Type | Description | Allowed Values & Constraints | Default | |
| 36 | +|---------------|---------|----------------------------|-------------------------------------------------|-----------| |
| 37 | +| `algorithm` | `string` | RSA algorithm | `FirstFit`, `ExactFit` | `FirstFit` | |
| 38 | +| `networkType` | `integer` | Network type | Only `1` (EON) supported | `1` | |
| 39 | +| `goalConnections` | `integer` | Target connection requests | Must be > 0 and < 10,000,000 | `100000` | |
| 40 | +| `confidence` | `float` | Confidence level | Must be > 0 and < 1.0 | `0.05` | |
| 41 | +| `lambdaParam` | `float` | Arrival rate | Must be > 0 | `1.0` | |
| 42 | +| `mu` | `float` | Service rate | Must be > 0 | `10.0` | |
| 43 | +| `network` | `string` | Network topology | `NSFNet`, `Cost239`, `EuroCore`, `GermanNet`, `UKNet` | `NSFNet` | |
| 44 | +| `bitrate` | `string` | Bitrate type | `fixed-rate`, `flex-rate` | `fixed-rate` | |
| 45 | +| `K` | `integer` | Path count | Must be > 0 and ≤ 6 | `3` | |
38 | 46 |
|
39 | | -**Example `curl` request with no parameters (defaults applied):** |
| 47 | +#### Example: Default Parameters |
40 | 48 |
|
41 | 49 | ```bash |
42 | | -curl -X POST -H "Content-Type: application/json" -d '{}' https://fns-api-cloud-run-787143541358.us-central1.run.app/run_simulation |
| 50 | +curl -X POST -H "Content-Type: application/json" -d '{}' \ |
| 51 | + https://fns-api-cloud-run-787143541358.us-central1.run.app/run_simulation |
43 | 52 | ``` |
44 | 53 |
|
45 | | -**Example `curl`request with all parameters specified:** |
| 54 | +#### Example: Custom Parameters |
46 | 55 |
|
47 | 56 | ```bash |
48 | 57 | curl -X POST -H "Content-Type: application/json" \ |
49 | | --d '{ "algorithm": "FirstFit", |
50 | | - "networkType": 1, |
51 | | - "goalConnections": 1000000, |
52 | | - "confidence": 0.05, |
53 | | - "lambdaParam": 120, |
54 | | - "mu": 1, |
55 | | - "network": "NSFNet", |
56 | | - "bitrate": "fixed-rate" |
57 | | - }' \ |
58 | | - https://fns-api-cloud-run-787143541358.us-central1.run.app/run_simulation |
59 | | -``` |
60 | | - |
61 | | - **Response**: |
62 | | - - `200` OK: Simulation executed successfully. The response body will be a JSON object with the following structure: |
63 | | - ```JSON |
64 | | - { |
65 | | - "output": "string", |
66 | | - "error": "string" |
67 | | - } |
68 | | - ``` |
69 | | - - `400` Bad Request: Indicates an error in the request, such as missing or invalid parameters. The response body will be a JSON object with an `error` field describing the issue. |
70 | | - - `500` Internal Server Error: Indicates a server-side error, either during compilation or simulation execution. The response body will be a JSON object with `error` and "details" fields providing more information about the error. |
| 58 | +-d '{ |
| 59 | + "algorithm": "FirstFit", |
| 60 | + "networkType": 1, |
| 61 | + "goalConnections": 100000, |
| 62 | + "confidence": 0.05, |
| 63 | + "lambdaParam": 120, |
| 64 | + "mu": 1, |
| 65 | + "network": "NSFNet", |
| 66 | + "bitrate": "fixed-rate" |
| 67 | +}' \ |
| 68 | +https://fns-api-cloud-run-787143541358.us-central1.run.app/run_simulation |
| 69 | +``` |
| 70 | + |
| 71 | +#### Response Codes |
| 72 | + |
| 73 | +- `200 OK`: Success. Returns `{"output": "...", "error": ""}` |
| 74 | +- `400 Bad Request`: Invalid parameters |
| 75 | +- `500 Internal Server Error`: Server-side error |
71 | 76 |
|
72 | 77 | ### `/help` (GET) |
73 | 78 |
|
74 | | -This endpoint provides detailed information about the `/run_simulation` endpoint, including the expected request structure, parameters, and response formats. |
| 79 | +Returns detailed API documentation. |
75 | 80 |
|
76 | | -**Request**: |
77 | 81 | ```bash |
78 | 82 | curl https://fns-api-cloud-run-787143541358.us-central1.run.app/help |
79 | 83 | ``` |
0 commit comments