Simulation
- class dsns.simulation.DataProvider
Base class for data providers (e.g. routing tables, etc.).
- name: str
- kind: str
- __init__()
- abstractmethod initialize(mobility: MultiConstellation, time: float) list[Event]
Initialize the data provider.
- Parameters:
mobility – The mobility model to initialize the data provider with.
time – The initial simulation time.
- Returns:
List of events to add to the event queue.
- abstractmethod update(mobility: MultiConstellation, time: float)
Update the data provider. This is called every time the clock updates.
- Parameters:
mobility – The mobility model to update the data provider with.
time – The current simulation time.
- abstractmethod handle_event(mobility: MultiConstellation, event: Event) list[Event]
Handle an event.
- Parameters:
mobility – The mobility model to handle the event with.
event – The event to handle.
- Returns:
List of events to add to the event queue.
- class dsns.simulation.RoutingDataProvider(get_next_hop_override: Callable[[BaseMessage, int, int], int | None] | None = None)
Base class for routing data providers.
- kind: str = 'routing'
- __init__(get_next_hop_override: Callable[[BaseMessage, int, int], int | None] | None = None)
- get_next_hop(source: int, destination: int, message: BaseMessage = None) int | None
- abstractmethod get_distance(source: int, destination: int) float | None
Get the distance (time difference, latency) between a given source and destination.
- Parameters:
source – Source satellite.
destination – Destination satellite.
- Returns:
Distance (time difference) between the source and destination, or None if no distance is available.
- abstractmethod get_path_cost(source: int, destination: int) float | None
- abstractmethod get_neighbors(source: int, max_distance: float | None = None) list[int]
Get the neighbors for a given source, up to a maximum distance (time difference). For look-ahead routing, this should provide the neighbors that are reachable within the given time difference, including those that are not currently connected.
- Parameters:
source – Source satellite.
max_distance – Maximum time difference (distance) to consider.
- Returns:
List of neighbor satellites.
- class dsns.simulation.Actor
Base class for simulation actors.
Actors are objects that can be added to the simulation and can react to events, and generate their own events.
- __init__()
- abstractmethod initialize() list[Event]
Initialize the actor.
- Returns:
List of events to add to the event queue.
- abstractmethod handle_event(mobility: MultiConstellation, event: Event) list[Event]
Handle an event.
- Parameters:
mobility – The mobility model to handle the event with.
event – The event to handle.
- Returns:
List of events to add to the event queue.
- class dsns.simulation.Simulation(mobility: MultiConstellation, actors: list[Actor] = [], logging_actors: list[Actor] = [], data_providers: list[DataProvider] = [], timestep: float | None = None)
Main event-based simulator.
- __init__(mobility: MultiConstellation, actors: list[Actor] = [], logging_actors: list[Actor] = [], data_providers: list[DataProvider] = [], timestep: float | None = None)
Setup the simulation.
- Parameters:
mobility – The mobility model to use.
actors – List of actors to add to the simulation.
data_providers – List of data providers to add to the simulation.
timestep – Timestep for mobility and data provider updates. If None, update on every event. This can signficantly speed up the simulation, but may cause inaccuracies with some data providers.
- initialize(time: float = 0.0)
Initialize the simulation.
- Parameters:
time – Initial time for the simulation.
- step()
Run the simulation for a single step.
- run(duration: float, progress: bool = False)
Run the simulation for a given duration.
- Parameters:
duration – Duration of the simulation.
- class dsns.simulation.LoggingActor(verbose: bool = False, event_filter: ~typing.Callable[[~dsns.events.Event], bool] = <function LoggingActor.<lambda>>)
Actor that logs all events.
- __init__(verbose: bool = False, event_filter: ~typing.Callable[[~dsns.events.Event], bool] = <function LoggingActor.<lambda>>)
Setup the logging actor.
- Parameters:
verbose – If True, print events to stdout.
event_filter – Optional filter function to filter events.
- handle_event(mobility: MultiConstellation, event: Event) list[Event]
Handle an event.
- Parameters:
mobility – The mobility model to handle the event with.
event – The event to handle.
- Returns:
List of events to add to the event queue.
- class dsns.simulation.FixedEventsActor(events: list[Event])
Actor that generates a fixed set of events.
- __init__(events: list[Event])
Setup the fixed events actor.
- Parameters:
events – List of events to add to the queue.
- handle_event(mobility: MultiConstellation, event: Event) list[Event]
Handle an event.
- Parameters:
mobility – The mobility model to handle the event with.
event – The event to handle.
- Returns:
List of events to add to the event queue.