Documentation for Networksimulator Module¶
NetworkSimulator
¶
Bases: ABC
Abstract base class representing a network simulator interface.
This interface defines the required methods for controlling and simulating network conditions between nodes. A concrete implementation is expected to manage artificial delays, bandwidth restrictions, packet loss, or other configurable conditions typically used in network emulation or testing.
Required asynchronous methods:
- start()
: Initializes the network simulation module.
- stop()
: Shuts down the simulation and cleans up any active conditions.
- set_thresholds(thresholds)
: Configures system-wide thresholds (e.g., max/min delay or distance mappings).
- set_network_conditions(dest_addr, distance)
: Applies network constraints to a target address based on distance.
Synchronous method:
- clear_network_conditions(interface)
: Clears any simulated network configuration for a given interface.
All asynchronous methods should be non-blocking to support integration in async systems.
Source code in nebula/addons/networksimulation/networksimulator.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
|
clear_network_conditions(interface)
abstractmethod
¶
Clears any simulated network conditions applied to the specified network interface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
interface
|
str
|
The name of the network interface to restore (e.g., 'eth0'). |
required |
Source code in nebula/addons/networksimulation/networksimulator.py
64 65 66 67 68 69 70 71 72 |
|
set_network_conditions(dest_addr, distance)
abstractmethod
async
¶
Applies network simulation settings to a given destination based on the computed distance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dest_addr
|
str
|
The address of the destination node (e.g., IP or identifier). |
required |
distance
|
float
|
The physical or logical distance used to determine the simulation severity. |
required |
Source code in nebula/addons/networksimulation/networksimulator.py
53 54 55 56 57 58 59 60 61 62 |
|
set_thresholds(thresholds)
abstractmethod
async
¶
Sets threshold values for simulating conditions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
thresholds
|
dict
|
A dictionary specifying condition thresholds, e.g., {'low': 100, 'medium': 200, 'high': 300}, or distance-delay mappings. |
required |
Source code in nebula/addons/networksimulation/networksimulator.py
42 43 44 45 46 47 48 49 50 51 |
|
start()
abstractmethod
async
¶
Starts the network simulation module.
This might involve preparing network interfaces, initializing tools like tc
, or configuring internal state.
Source code in nebula/addons/networksimulation/networksimulator.py
24 25 26 27 28 29 30 31 |
|
stop()
abstractmethod
async
¶
Stops the network simulation module.
Cleans up any modifications made to network interfaces or system configuration.
Source code in nebula/addons/networksimulation/networksimulator.py
33 34 35 36 37 38 39 40 |
|