Message Actors

class dsns.message_actors.MessageRoutingActor(routing: ~dsns.simulation.RoutingDataProvider, store_and_forward: bool = False, model_bandwidth=False, attack_strategy: None = None, loss_config: ~dsns.message.LossConfig = None, reliable_transfer_config: ~dsns.message.ReliableTransferConfig = <dsns.message.UnreliableConfig object>)

Actor that implements message routing for each node in the simulation. This actor requires a RoutingDataProvider to be present in the data providers.

Routing can be done using either IP-style best-effort routing, or DTN-style store-and-forward routing. For each of these, the store_and_forward parameter should be set and the appropriate RoutingDataProvider should be used.

Note that this actor does not handle broadcast messages.

__init__(routing: ~dsns.simulation.RoutingDataProvider, store_and_forward: bool = False, model_bandwidth=False, attack_strategy: None = None, loss_config: ~dsns.message.LossConfig = None, reliable_transfer_config: ~dsns.message.ReliableTransferConfig = <dsns.message.UnreliableConfig object>)

Build the actor.

Parameters:
  • routing – The routing data provider to use.

  • store_and_forward – Whether to use store-and-forward routing, instead of best-effort routing.

initialize() list[Event]

Initialize the actor.

Returns:

List of events to add to the event queue.

handle_message_sent_event(mobility: MultiConstellation, event: MessageSentEvent) list[Event]

Handle a message sent 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.

handle_message_received_event(mobility: MultiConstellation, event: MessageReceivedEvent, message: DirectMessage) list[Event]

Handle a message received 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.

handle_message_created_event(mobility: MultiConstellation, event: MessageCreatedEvent, message: DirectMessage) list[Event]

Handle a message created 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.

Handle a link up 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.

handle_message_reroute_event(mobility: MultiConstellation, event: MessageRerouteEvent, message: DirectMessage)
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.message_actors.MessageBroadcastActor(routing: RoutingDataProvider, store_and_forward: bool = False, model_bandwidth=False, forwarding_strategy: str = 'flooding', gossip_neighbors: int = 1, max_cache_time: None | float | dict[int, float] = None, attack_strategy: None = None, loss_config: LossConfig = None)

Actor that provides message broadcasting for each node in the simulation.

Routing can be done using either IP-style best-effort routing, or DTN-style store-and-forward routing. For each of these, the store_and_forward parameter should be set and the appropriate RoutingDataProvider should be used.

Note that this actor does not handle unicast messages.

__init__(routing: RoutingDataProvider, store_and_forward: bool = False, model_bandwidth=False, forwarding_strategy: str = 'flooding', gossip_neighbors: int = 1, max_cache_time: None | float | dict[int, float] = None, attack_strategy: None = None, loss_config: LossConfig = None)

Build the actor.

Parameters:
  • routing – The routing data provider to use.

  • store_and_forward – Whether to use store-and-forward routing, instead of best-effort routing.

  • forwarding_strategy – The broadcast forwarding strategy to use. “flooding” sends the message to all neighbors. “gossip” sends the message to a random subset of neighbors.

  • gossip_neighbors – Number of neighbors to forward to when using the gossip forwarding strategy.

  • max_cache_time – Maximum time to cache messages for, or None to disable caching. If a dict is provided, it should map satellite IDs to cache times. Should not be used when store_and_forward is False.

  • attack_strategy – Attack strategy to use.

initialize() list[Event]

Initialize the actor.

Returns:

List of events to add to the event queue.

handle_message_sent_event(mobility: MultiConstellation, event: MessageSentEvent, message: BroadcastMessage) list[Event]

Handle a message sent event.

Parameters:
  • mobility – The mobility model to handle the event with.

  • event – The event to handle.

  • message – The message to send.

Returns:

List of events to add to the event queue.

handle_message_received_event(mobility: MultiConstellation, event: MessageReceivedEvent, message: BroadcastMessage) list[Event]

Handle a message received event.

Parameters:
  • mobility – The mobility model to handle the event with.

  • event – The event to handle.

  • message – The received message.

Returns:

List of events to add to the event queue.

handle_message_delivered_event(mobility: MultiConstellation, event: MessageDeliveredEvent, message: BroadcastMessage) list[Event]

Handle a message delivered event.

Parameters:
  • mobility – The mobility model to handle the event with.

  • event – The event to handle.

  • message – The received message.

Returns:

List of events to add to the event queue.

handle_message_created_event(mobility: MultiConstellation, event: MessageCreatedEvent, message: BroadcastMessage) list[Event]

Handle a message created event.

Parameters:
  • mobility – The mobility model to handle the event with.

  • event – The event to handle.

  • message – The created message.

Returns:

List of events to add to the event queue.

Handle a link up 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.

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.message_actors.BestEffortRoutingDataProvider(get_next_hop_override: Callable[[BaseMessage, int, int], int | None] | None = None)

Routing data provider that implements best effort routing.

time: float
__init__(get_next_hop_override: Callable[[BaseMessage, int, int], int | None] | None = None)
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.

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.

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.

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.

get_path_cost(source, destination)
get_neighbors(source: int, max_distance: float | None = None) list[int]

Get the neighbors of a given source.

Parameters:
  • source – Source satellite.

  • max_distance – Maximum distance to neighbors.

Returns:

List of neighbors.

class dsns.message_actors.UpdateConnectivityEvent(time: float)

Event for updating the connectivity graph.

__init__(time: float)
class dsns.message_actors.LookaheadRoutingDataProvider(resolution: float, num_steps: int, get_next_hop_override: Callable[[BaseMessage, int, int], int | None] | None = None)

Data provider that keeps track of a connectivity graph over time, for use in store-and-forward routing. Multiple timesteps are measured at once, to provide information on the next time a link will be up (within a given time bound).

This also generates events for when links go up and down.

time: float
__init__(resolution: float, num_steps: int, get_next_hop_override: Callable[[BaseMessage, int, int], int | None] | None = None)

Initialise the connectivity system.

Parameters:
  • resolution – Time between updates of the connectivity graph.

  • num_steps – Number of timesteps of lookahead to store at once.

resolution: float
num_steps: int
initialize(mobility: MultiConstellation, time: float) list[Event]

Initialize the connectivity system.

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.

update(mobility: MultiConstellation, time: float)

Update the connectivity system for a given timestep.

Parameters:
  • mobility – The mobility model to update the data provider with.

  • time – The current simulation time.

update_connectivity(mobility: MultiConstellation, initial: bool = False) list[Event]

Update the connectivity graphs.

Parameters:
  • mobility – The mobility model to update the connectivity graph with.

  • initial – Whether this is the initial update.

Returns:

List of events to add to the event queue.

handle_update_connectivity_event(mobility: MultiConstellation, event: UpdateConnectivityEvent) list[Event]

Handle an update connectivity 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.

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.

get_path_cost(source: int, destination: int)
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.

get_neighbors(source: int, max_distance: float | None = None) list[int]

Get the neighbors of a given source.

Parameters:
  • source – Source satellite.

  • max_distance – Maximum distance to neighbors.

Returns:

List of neighbors.