Node¶
-
class
NetworkSim.architecture.base.node.
Node
(control_signal, data_signal, network, node_id=None)[source]¶ Constructor of the individual node in the ring network
- Parameters
node_id (int) – The ID number of the Node. Default is
None
.control_signal (ControlSignal) – The control signal defined in the network.
data_signal (DataSignal) – The data signal defined in the network.
- Variables
generated_control_packet_df (pandas DataFrame) –
A DataFrame keeping a record of the generated control packets, containing the columns:
Timestamp
Raw Packet
Source ID
Destination ID
Control Code
received_control_packet_df (pandas DataFrame) –
A DataFrame keeping a record of the received control packets, containing the columns:
Timestamp
Raw Packet
Source ID
Destination ID
Control Code
generated_data_packet_df (pandas DataFrame) –
A DataFrame keeping a record of the generated data packets, containing the columns:
Timestamp
Raw Packet
Source ID
received_data_packet_df (pandas DataFrame) –
A DataFrame keeping a record of the received data packets, containing the columns:
Timestamp
Raw Packet
Source ID
-
generate_control_packet
(destination_id, control_code, timestamp)[source]¶ Control packet generation.
- Parameters
destination_id (int) – The node ID of the destination node.
control_code (int) – The control code in decimal.
timestamp (float) – The timestamp when the control packet is generated.
- Returns
control_packet – A string representation of the control packet in binary.
- Return type
str
-
generate_data_packet
(destination_id, timestamp)[source]¶ Data packet generation.
- Parameters
destination_id (int) – The node ID of the destination node.
timestamp (float) – The timestamp when the data packet is generated.
- Returns
data_packet – The data packet string in binary.
- Return type
str
-
get_distance_from
(start_node)[source]¶ Get distance from a node.
- Parameters
start_node (Node) – The start node.
- Returns
distance – The distance from the start node to the current node in meters.
- Return type
float
-
get_distance_to
(end_node)[source]¶ Get distance to a node.
- Parameters
end_node (Node) – The end node.
- Returns
distance – The distance from current node to the end node in meters.
- Return type
float
-
interpret_control_packet
(packet)[source]¶ Interpretation of a control packet.
- Parameters
packet
- Returns
source_id (int) – Source ID of the control packet.
destination_id (int) – Destination iD of the control packet.
control_code (int) – Control code in decimal.
-
store_received_control_packet
(packet, timestamp)[source]¶ Storage of received control packets. The packets are interpreted and stored in self.received_control_packet_df.
- Parameters
packet (str) – Received control packet string in binary.
timestamp (float) – The timestamp when the control packet is received.
-
store_received_data_packet
(packet, source_id, timestamp)[source]¶ Storage of received data packet. The data packet is stored in self.received_data_packet_df.
- Parameters
packet (str) – The received data packet string in binary.
source_id (int) – The node ID of the source node.
timestamp – The timestamp when the data packet is received.