This is the backend component of the network simulator application, built with Spring Boot and Java 25.
- REST API endpoints for managing network simulation scenarios
- Database persistence using PostgreSQL
- Scenario model with network configuration parameters
- Basic proxy service with network simulation capabilities
The backend application listens for incoming HTTP requests.
Requests made to the path /api are handled by the backend itself, providing API endpoints for managing simulation scenarios.
The path /forward/{systemName} and everything under that, are proxied to the target service, applying the configured network simulation scenarios.
The API documentation is available at: http://localhost:9898/swagger-ui/index.html
src/
├── main/
│ ├── java/dk/fust/networksimulator/
│ │ ├── config/ # Application configuration
│ │ ├── controller/ # REST API controllers
│ │ ├── model/ # Database entities
│ │ ├── repository/ # Data access layer
│ │ ├── service/ # Business logic
│ │ └── simulations/ # Network simulation logic
│ └── resources/
│ └── application.yml # Configuration properties
└── test/ # Unit and integration tests
A scenario defines a set of network conditions to be applied to proxied requests.
Each scenario has a path pattern to match incoming requests and various network parameters like latency, bandwidth, status codes, etc.
If a path is omitted, the scenario applies to all paths.
All matching scenarios are applied to each request.
The application supports various network simulation scenarios.
A simulation that introduces a fixed delay (latency) to each request before forwarding it to the target service.
The simulation runs for all active scenarios that have a defined latencyMs.
The delay is implemented using Thread.sleep() and is the sum of all the scenarios that is active.
A simulation that returns a predefined HTTP status code (and optional response body) instead of forwarding the request to the target service.
The simulation runs for all active scenarios that have a defined statusCode.
The first scenario that defines a statusCode is used, and the request is not forwarded to the target service or further simulations.
If a response body is defined in the scenario, it is included in the response.
A simulation that simply passes requests and responses without any modifications.
A simulation that can add or modify, HTTP headers in responses.
- Ensure PostgreSQL is running and accessible
- Update database credentials in
application.yml - Run with Maven:
./mvnw spring-boot:run
The docker-compose.yml file sets up:
- PostgreSQL database with persistent storage
- Proper network configuration between services
The API Endpoints are documented using OpenAPI/Swagger and can be accessed at: http://localhost:9898/swagger-ui/index.html
erDiagram
target_systems {
INT id PK
TEXT systemName
TEXT targetBaseUrl
BIGINT timeoutMs
BOOL followRedirects
}
target_systems ||--o{ scenarios : ""
scenarios {
INT id PK
BOOL enable_scenario
TEXT name
TEXT path
TEXT description
BIGINT latency_ms
INT status_code
TEXT response_body
BIGINT timeout_ms
BOOL follow_redirects
INT target_system_id FK
}
scenarios ||--o{ scenario_headers : ""
scenario_headers {
INT id PK
INT scenario_id FK
TEXT header_name
TEXT header_value
BOOL header_replace_value
}