BaseReceiver¶
-
class
NetworkSim.simulation.process.receiver.
BaseReceiver
(env, until, receiver_id, simulator, model=None)[source]¶ Receiver processes creator for the simulation.
- Parameters
env (simpy Environment) – The simulation environment.
until (float) – The end time of the simulation.
receiver_id (int) – The receiver ID.
simulator (BaseSimulator) – The simulator used.
model (Model, optional) – The network model used for the simulation. Default is
Model()
.
- Variables
received_data_packet (list) –
A list keeping the information of the received data packets, containing the columns:
Timestamp
Raw Packet
Source ID
received_control_packet (list) –
A list keeping the information of the received control packets, containing the columns:
Timestamp
Raw Packet
Source ID
queue_record (list) –
A list keeping the information of the control packets stored in the receiver RAM, including the columns:
- Timestampfloat
The timestamp when the operation is carried out.
- Raw Packetstr
The raw control packet.
- Source IDint
Source ID of the control packet.
- Operationstr
Operation carried out on the packet in the queue.
queue (list) –
A list of packet in the receiver RAM queue, in the format:
raw_packet
generation_timestamp
transmission_timestamp
packet_entry_point
entry_node_id
destination_node_id
reception_timestamp
-
check_control_packet
()[source]¶ Function to check if there is a control packet present at the receiver
- Returns
present (bool) – Presence of the data packet.
True
if present,False
if not present.packet (packet) – Packet information, in the format:
raw_packet
generation_timestamp
transmission_timestamp
packet_entry_point
entry_node_id
destination_node_id
-
check_data_packet
(ring_id, reversed=False)[source]¶ Function to check if there is a data packet present at the receiver
- Parameters
ring_id (int) – The ID of the data ring to check.
- Returns
present (bool) – Presence of the data packet.
True
if present,False
if not present.packet (packet) – Packet information, in the format:
raw_packet
generation_timestamp
transmission_timestamp
packet_entry_point
entry_node_id
destination_node_id
-
control_id_match
(packet)[source]¶ Function to check if the control packet destination ID matches the receiver ID.
- Parameters
packet (packet) – The control packet.
- Returns
if_match – If the received packet ID matches that of the receiver.
True
if matched, otherwiseFalse
.- Return type
bool
-
get_original_control_packet
(packet)[source]¶ Locate the original control packet if a new control packet with “Remove” code is obtained.
- Parameters
packet (packet) – The control packet.
- Returns
original_packet – The original control packet if found. Otherwise return
None
.- Return type
packet
-
initialise
()[source]¶ Initialisation of the receiver simulation.
This function adds two asynchronous receiver processes into the environment:
Reception of control packets
Reception of data packets
-
interpret_control_packet
(packet)[source]¶ Function to interpret a control packet.
- Parameters
packet (packet) – Packet information, in the format:
raw_packet
generation_timestamp
transmission_timestamp
packet_entry_point
entry_node_id
destination_node_id
- Returns
source_id (int) – The source ID.
destination_id (int) – The destination ID.
control_code (int) – The control code.
-
is_upstream
(source_id)[source]¶ Check if the destination node is an upstream node.
- Parameters
source_id (int) – ID of the source node.
- Returns
is_upstream –
True
if the destination is upstream,False
if downstream.- Return type
bool
-
ram_queue_input
(packet, priority='low')[source]¶ Handling input to the receiver RAM queue.
- Parameters
packet (packet) – The control packet.
priority (str) – Priority of the packet:
If “high”, the packet is inserted to the list (at the beginning). - If “low”, the packet is append to the list (at the end).
Default is
"low"
.
-
ram_queue_output
(packet)[source]¶ Handling output from the receiver RAM queue.
- Parameters
packet (packet) – The control packet read from the front of the queue.
- Returns
source_id – The data ring to tune to for reception.
- Return type
int
-
receive_control_packet
(packet)[source]¶ Control packet reception function.
This function removes the control packet from the ring and keeps a record of the transmission.
- Parameters
packet (packet) – The control packet.
-
receive_data_packet
(ring_id, packet, reversed=False)[source]¶ Data packet reception function.
This function removes the data packet from the ring and keeps a record of the transmission.
- Parameters
ring_id (int) – The ID of the data ring where the packet is removed.
packet (packet) – The data packet.
reversed (bool, optional) – If the receiver is receiving on the reversed data rings.