Communication
gradysim.simulator.handler.communication.CommunicationHandler
Bases: INodeHandler
Adds communication to the simulation. Nodes, through their providers, can send this handler communication commands that dictate how a message should be sent. This message will be delivered to the destination node.
Messages are transmited through a medium that determines conditions like communication range and failure rate. Messages can fail to be delivered or be delivered late.
Source code in gradysim/simulator/handler/communication.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
__init__(communication_medium=CommunicationMedium())
Initializes the communication handler.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
communication_medium |
CommunicationMedium
|
Configuration of the network conditions. If not set all default values will be used. |
CommunicationMedium()
|
Source code in gradysim/simulator/handler/communication.py
handle_command(command, sender)
Performs a communication command. This method should be called by the node's provider to transmit a communication command to the communication handler.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
command |
CommunicationCommand
|
Command being issued |
required |
sender |
Node
|
Node issuing the command |
required |
Source code in gradysim/simulator/handler/communication.py
gradysim.simulator.handler.communication.CommunicationMedium
dataclass
Conditions through which the messages are delivered. Can influence how and when messages can be delivered.
Source code in gradysim/simulator/handler/communication.py
delay: float = 0
class-attribute
instance-attribute
Sets a delay in seconds for message delivery, representing network delay. Range is evaluated before the delay is applied
failure_rate: float = 0
class-attribute
instance-attribute
Failure chance between 0 and 1 for message delivery. 0 represents messages never failing and 1 always fails.
transmission_range: float = 60
class-attribute
instance-attribute
Maximum range in meters for message delivery. Messages destined to nodes outside this range will not be delivered