pydistsim.network.behavior.NetworkBehaviorModel

class NetworkBehaviorModel(message_ordering: bool = False, message_loss_indicator: Callable[[NetworkType, Message], bool] | None = None, clock_increment: Callable[[Node], int] | None = None, node_processing_frequency: Callable[[Node], int] | None = None, message_delay_indicator: Callable[[NetworkType, Message], int] | None = None, bounded_communication_delays: bool = False)[source]

Bases: object

Behavioral properties for a network.

Parameters:
  • message_ordering – Boolean indicating if messages should be ordered. Default is False.

  • message_loss_indicator – Function that returns a boolean indicating if a given message should be lost. Default (None) means no message loss.

  • clock_increment – Function that returns the increment for the clock of a given node. Default (None) means unitary clock increment (sync).

  • node_processing_frequency – Function that controls how often a node may process a message. Default (None) means no delay. The integer must be greater than 0. For example, if the integer is 2, the node will process every other message. As this will be called on every simulation step, it is recommended to use a constant value or a function that does not depend on the node state, since doing so may lead to unexpected behavior, such as a node never processing any message.

  • message_delay_indicator – Function that returns the amount of steps to delay a given message. Default (None) means no message delay.

  • bounded_communication_delays – Boolean indicating if there is a predefined constant T such that the communication delay of any message on any link is at most T. Default is False.

Methods

__init__

Attributes

message_ordering

Boolean indicating if messages should be ordered.

message_loss_indicator

Function that returns a boolean indicating if a given message should be lost.

clock_increment

Function that returns the increment for the clock of a given node.

node_processing_frequency

Function that controls how often a node may process a message.

message_delay_indicator

Function that returns the amount of steps to delay a given message.

bounded_communication_delays

If there is a predefined constant T such that the communication delay of any message on any link is at most T.

IdealCommunication

Properties for a network with message ordering, no message loss, no message delay and synchronized clocks.

LikelyRandomLossCommunication

Properties for a network with message ordering, a random (but likely) message loss, no message delay and unsynchronized clocks.

RandomDelayCommunication

Properties for a network with message ordering, no message loss, random delay based on the network size and unsynchronized clocks.

RandomDelayCommunicationSlowNodes

Properties for a network with message ordering, no message loss, random delay based on the network size, unsynchronized clocks and half the nodes are 'slow'.

RandomDelayCommunicationVerySlowNodes

Properties for a network with message ordering, no message loss, random delay based on the network size, unsynchronized clocks and half the nodes are very 'slow'.

ThrottledCommunication

Properties for a network with message ordering, no message loss, a delay based on network usage and unsynchronized clocks.

UnlikelyRandomLossCommunication

Properties for a network with message ordering, a random (but unlikely) message loss, no message delay and unsynchronized clocks.

UnorderedCommunication

Properties for a network with no message ordering, no message loss, no message delay and unsynchronized clocks.

UnorderedRandomDelayCommunication

Properties for a network with no message ordering, no message loss, random delay based on the network size and unsynchronized clocks.

UnorderedThrottledCommunication

Properties for a network with no message ordering, no message loss, a delay based on network usage and unsynchronized clocks.

IdealCommunication: ClassVar[NetworkBehaviorModel] = NetworkBehaviorModel(message_ordering=True, message_loss_indicator=None, clock_increment=None, node_processing_frequency=None, message_delay_indicator=None, bounded_communication_delays=True)

Properties for a network with message ordering, no message loss, no message delay and synchronized clocks.

LikelyRandomLossCommunication: ClassVar[NetworkBehaviorModel] = NetworkBehaviorModel(message_ordering=True, message_loss_indicator=<function random_loss.<locals>._random_loss>, clock_increment=<function small_random_increment>, node_processing_frequency=None, message_delay_indicator=None, bounded_communication_delays=True)

Properties for a network with message ordering, a random (but likely) message loss, no message delay and unsynchronized clocks.

RandomDelayCommunication: ClassVar[NetworkBehaviorModel] = NetworkBehaviorModel(message_ordering=True, message_loss_indicator=None, clock_increment=<function small_random_increment>, node_processing_frequency=None, message_delay_indicator=<function random_delay_max_size_network>, bounded_communication_delays=True)

Properties for a network with message ordering, no message loss, random delay based on the network size and unsynchronized clocks.

RandomDelayCommunicationSlowNodes: ClassVar[NetworkBehaviorModel] = NetworkBehaviorModel(message_ordering=True, message_loss_indicator=None, clock_increment=<function small_random_increment>, node_processing_frequency=<function half_the_nodes_are_slow>, message_delay_indicator=<function random_delay_max_size_network>, bounded_communication_delays=True)

Properties for a network with message ordering, no message loss, random delay based on the network size, unsynchronized clocks and half the nodes are ‘slow’.

RandomDelayCommunicationVerySlowNodes: ClassVar[NetworkBehaviorModel] = NetworkBehaviorModel(message_ordering=True, message_loss_indicator=None, clock_increment=<function small_random_increment>, node_processing_frequency=<function half_the_nodes_are_very_slow>, message_delay_indicator=<function random_delay_max_size_network>, bounded_communication_delays=True)

Properties for a network with message ordering, no message loss, random delay based on the network size, unsynchronized clocks and half the nodes are very ‘slow’.

ThrottledCommunication: ClassVar[NetworkBehaviorModel] = NetworkBehaviorModel(message_ordering=True, message_loss_indicator=None, clock_increment=<function small_random_increment>, node_processing_frequency=None, message_delay_indicator=<function delay_based_on_network_usage>, bounded_communication_delays=False)

Properties for a network with message ordering, no message loss, a delay based on network usage and unsynchronized clocks.

UnlikelyRandomLossCommunication: ClassVar[NetworkBehaviorModel] = NetworkBehaviorModel(message_ordering=True, message_loss_indicator=<function random_loss.<locals>._random_loss>, clock_increment=<function small_random_increment>, node_processing_frequency=None, message_delay_indicator=None, bounded_communication_delays=True)

Properties for a network with message ordering, a random (but unlikely) message loss, no message delay and unsynchronized clocks.

UnorderedCommunication: ClassVar[NetworkBehaviorModel] = NetworkBehaviorModel(message_ordering=False, message_loss_indicator=None, clock_increment=<function small_random_increment>, node_processing_frequency=None, message_delay_indicator=None, bounded_communication_delays=True)

Properties for a network with no message ordering, no message loss, no message delay and unsynchronized clocks.

UnorderedRandomDelayCommunication: ClassVar[NetworkBehaviorModel] = NetworkBehaviorModel(message_ordering=False, message_loss_indicator=None, clock_increment=<function small_random_increment>, node_processing_frequency=None, message_delay_indicator=<function random_delay_max_size_network>, bounded_communication_delays=True)

Properties for a network with no message ordering, no message loss, random delay based on the network size and unsynchronized clocks.

UnorderedThrottledCommunication: ClassVar[NetworkBehaviorModel] = NetworkBehaviorModel(message_ordering=False, message_loss_indicator=None, clock_increment=<function small_random_increment>, node_processing_frequency=None, message_delay_indicator=<function delay_based_on_network_usage>, bounded_communication_delays=False)

Properties for a network with no message ordering, no message loss, a delay based on network usage and unsynchronized clocks.

__setattr__(name, value)

Implement setattr(self, name, value).

_get_clock_increment(node: Node) int[source]

Get the increment for the clock of a given node.

_get_delay(network: NetworkType, message: Message) int[source]

Get the delay for a given message.

_get_node_processing_frequency(node: Node) int[source]

Get the delay for a given node.

_should_lose(network: NetworkType, message: Message) bool[source]

Check if a given message should be lost.

bounded_communication_delays: bool

If there is a predefined constant T such that the communication delay of any message on any link is at most T.

clock_increment: Callable[[Node], int] | None

Function that returns the increment for the clock of a given node. None means unitary clock increment (sync).

message_delay_indicator: Callable[[NetworkType, Message], int] | None

Function that returns the amount of steps to delay a given message. None means no message delay.

message_loss_indicator: Callable[[NetworkType, Message], bool] | None

Function that returns a boolean indicating if a given message should be lost. None means no message loss.

message_ordering: bool

Boolean indicating if messages should be ordered.

node_processing_frequency: Callable[[Node], int] | None

Function that controls how often a node may process a message. None means no delay. The integer must be greater than 0. For example, if the integer is 2, the node will process every other message. As this will be called on every simulation step, it is recommended to use a constant value or a function that does not depend on the node state, since doing so may lead to unexpected behavior, such as a node never processing a message.