Skip to content

Repository files navigation

Flex Net Sim Backend API

Static BadgeStatic BadgeStatic BadgeStatic BadgeStatic Badge

A lightweight API for running optical network simulations with Flex Net Sim C++.

Overview

The Flex Net Sim Backend API provides:

  • Hands-on demonstration of optical network simulation capabilities
  • Simplified access to core Flex Net Sim features
  • Quick experimentation with pre-configured network topologies and parameters

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.

Important Limitations

This API is intentionally designed as a limited demonstration platform:

  • Not intended for complex simulations or algorithm customization
  • Provides access to basic functionalities only
  • For advanced simulation tasks, users should explore the full library

For comprehensive resources, see the Flex Net Sim documentation.

For development and deployment instructions for this API, refer to README_DEV.md.

API Endpoints

/run_simulation (POST)

Runs a network simulation with the provided parameters and returns complete results.

Request Parameters

ParameterTypeDescriptionAllowed Values & ConstraintsDefault
algorithmstringRSA algorithmFirstFit, BestFitFirstFit
networkTypeintegerNetwork typeOnly 1 (EON) supported1
goalConnectionsintegerTarget connection requestsMust be > 0 and < 10,000,000100000
confidencefloatConfidence levelMust be > 0 and < 1.00.05
lambdaParamfloatArrival rateMust be > 01.0
mufloatService rateMust be > 010.0
networkstringNetwork topologyNSFNet, Cost239, EuroCore, GermanNet, UKNetNSFNet
bitratestringBitrate typefixed-rate, flex-ratefixed-rate
KintegerPath countMust be > 0 and ≤ 63

Example: Default Parameters

curl -X POST -H "Content-Type: application/json" -d '{}' \
https://fns-api-cloud-run-787143541358.us-central1.run.app/run_simulation

Example: Custom Parameters

curl -X POST -H "Content-Type: application/json" \
-d '{  "algorithm": "FirstFit", "networkType": 1, "goalConnections": 100000, "confidence": 0.05, "lambdaParam": 120, "mu": 1, "network": "NSFNet", "bitrate": "fixed-rate"}' \
https://fns-api-cloud-run-787143541358.us-central1.run.app/run_simulation

Response Format

{
"status": "success",
"data": "simulation results as text..."
}

Response Codes

  • 200 OK: Success
  • 400 Bad Request: Invalid parameters
  • 500 Internal Server Error: Server-side error

/run_simulation_stream (POST)

Runs a network simulation with the provided parameters and streams results in real-time using Server-Sent Events (SSE).

Request Parameters

Same parameters as /run_simulation endpoint.

Example: Streaming with Default Parameters

curl -N -X POST -H "Content-Type: application/json" -d '{}' \
https://fns-api-cloud-run-787143541358.us-central1.run.app/run_simulation_stream

Example: Streaming with Custom Parameters

curl -N -X POST -H "Content-Type: application/json" \
-d '{  "algorithm": "FirstFit", "networkType": 1, "goalConnections": 5000000, "confidence": 0.05, "lambdaParam": 120, "mu": 1, "network": "NSFNet", "bitrate": "fixed-rate"}' \
https://fns-api-cloud-run-787143541358.us-central1.run.app/run_simulation_stream

Response Format

The endpoint returns a stream of Server-Sent Events with the following event types:

  1. Start Event:

    event: start
    data: {"status": "started", "message": "Simulation started"}
    
  2. Data Events (multiple events, one per line of output):

    event: data
    data: {"status": "running", "message": "Line of simulation output"}
    
  3. End Event:

    event: end
    data: {"status": "completed", "message": "Simulation completed"}
    
  4. Error Event (only if an error occurs):

    event: error
    data: {"status": "error", "message": "Error description", "error": "Detailed error"}
    

Response Codes

  • 200 OK: Success (stream starts)
  • 400 Bad Request: Invalid parameters
  • 500 Internal Server Error: Server-side error

/help (GET)

Returns detailed API documentation.

curl https://fns-api-cloud-run-787143541358.us-central1.run.app/help

About

Public API for simple interaction with the FlexNetSim C++ library, offering basic optical network simulations and an introduction to its core features. Designed for quick experimentation and simplified operations.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages