gossipy.core module#
Module contents#
- class gossipy.core.AntiEntropyProtocol(value)#
Bases:
enum.Enum
The overall protocol of the gossip algorithm.
- PULL = 2#
Pull the gossip model from the gossip node(s).
- PUSH = 1#
Push the local model to the gossip node(s).
- PUSH_PULL = 3#
Push the local model to the gossip node(s) and then pull the gossip model from the gossip node(s).
- class gossipy.core.CreateModelMode(value)#
Bases:
enum.Enum
The mode for creating/updating the gossip model.
- MERGE_UPDATE = 2#
Merge the models and then make an update using the local data.
- PASS = 4#
Do nothing.
- UPDATE = 1#
Update the model with the local data.
- UPDATE_MERGE = 3#
Update the models with the local data and then merge the models.
- class gossipy.core.Delay#
Bases:
abc.ABC
A class representing a delay.
The delay is a function of a message and returns the delay in simulation time units.
- class gossipy.core.LinearDelay(timexunit, overhead)#
Bases:
gossipy.core.Delay
A class representing a linear delay.
The linear delay is computed as a fixed overhead plus a quantity proportional tothe message’s size.LinearDelay
can mimic the behavior ofConstantDelay
, i.e., LinearDelay(0, x) is equivalent to ConstantDelay(x).- Parameters
- get(msg)#
Returns the delay for the specified message.
The delay is linear with respect to the message’s size and it is computed as follows:delay = floor(timexunit * size(msg)) + overhead.This type of delay allows to simulate the transmission time which is a linear functionof the size of the message.
- class gossipy.core.Message(timestamp, sender, receiver, type, value)#
Bases:
gossipy.Sizeable
A class representing a message.
- Parameters
timestamp (int) – The message’s timestamp with the respect to the simulation time. The timestamp refers to the moment when the message is sent.
sender (int) – The sender node id.
receiver (int) – The receiver node id.
type (MessageType) – The message type.
value (tuple[Any, ...] or None) – The message’s payload. The typical payload is a single item tuple containing the model (handler). If the value is None, the message represents an ACK.
- get_size()#
Computes and returns the estimated size of the message.
The size is expressed in number of “atomic” values stored in the message. Atomic values are integers, floats, and booleans.
Note
Currently strings are not supported.
- class gossipy.core.MessageType(value)#
Bases:
enum.Enum
The type of a message.
- PULL = 2#
Asks for the model to the receiver.
- PUSH = 1#
The message contains the model (and possibly additional information)
- PUSH_PULL = 4#
The message contains the model (and possibly additional information) and also asks for the model to the receiver.
- REPLY = 3#
The message is a response to a PULL message.
- class gossipy.core.P2PNetwork(num_nodes, topology=None)#
Bases:
abc.ABC
Abstract class representing a network topology.
- Parameters
num_nodes (int) – The number of nodes in the network.
topology (Optional[Union[np.ndarray, csr_matrix]], default=None) – The adjacency matrix of the network topology. If None, the network is considered to be a fully connected network.
- class gossipy.core.StaticP2PNetwork(num_nodes, topology=None)#
Bases:
gossipy.core.P2PNetwork
A class representing a static network topology.
A static network topology is a network topology where the adjacency matrix is fixed.
- Parameters
num_nodes (int) – The number of nodes in the network.
topology (Optional[Union[np.ndarray, csr_matrix]], default=None) – The adjacency matrix of the network topology. If None, the network is considered to be a fully connected network.
- class gossipy.core.UniformDelay(min_delay, max_delay)#
Bases:
gossipy.core.Delay
A class representing a uniform delay.
- Parameters