Ring

class NetworkSim.architecture.base.ring.Ring(model, ring_id=None, time_unit='ns', reversed=False)[source]

Ring class to store packets on both control and data rings. Packets can be added or removed from the ring. Time of addition of the packet is recorded to track packet location.

Parameters
  • model (Model) – The network model used. Default is Model().

  • time_unit (str) – The time unit used for the simulation, chosen from the following:

    • ‘ns’

    • ‘s’

    Default is 'ns'

Variables
  • ring_id (int) – The ID of the ring. Default is None.

  • nodes_location (array) – Array of locations of the nodes on the ring, in meters.

  • packets (list) –

    List of packets present on the ring, containing:

    • raw_packetstr

      The raw packet string.

    • generation_timestampfloat

      Time when the packet was generated and stored into the RAM.

    • transmission_timestampfloat

      Time when the packet was added onto the ring.

    • packet_entry_pointfloat

      The location (in meters) where the packet was added.

    • entry_node_idint

      The ID of the node where the packet was added.

    • destination_node_idint

      The ID of the destination of the packet.

  • packet_record (list) –

    A list containing the information on all packet transmission on the ring, including the columns:

    • Generation Timestampfloat

      The timestamp when the packet is generated and stored in the RAM.

    • Transmission Timestampfloat

      The timestamp when the packet is added onto the ring by the transmitter.

    • Reception Timestampfloat

      The timestamp when the packet is received by the receiver.

    • Raw Packetstr

      The raw packet content.

    • Source Nodeint

      The ID of the source node.

    • Destination Nodeint

      The ID of the destination node.

    • Statusstr

      The status of the packet, can be added or removed.

    • Total Packet Countint

      The total number of packets on the ring at the time of the operation.

add_packet(node_id, destination_id, packet, generation_timestamp, transmission_timestamp)[source]

Packet addition to the ring. The packet added will be in the format [raw_packet, timestamp, node_id].

Parameters
  • node_id (int) – The ID of the node at which the packet is added.

  • destination_id (int) – The ID of the destination node of the packet.

  • packet (str) – The packet string added onto the ring.

  • generation_timestamp (float) – The timestamp when the packet is generated.

  • transmission_timestamp (float) – The timestamp when the packet is added.

check_packet(current_time, node_id)[source]

Packet existence check.

Parameters
  • current_time (float) – Current time when the packet is checked.

  • node_id (int) – Id of the node at which the check is performed.

Returns

  • existence (bool) – The existence of the packet. True when a packet exists.

  • packet (packet) – The packet information, containing:

    • raw_packet

    • generation_timestamp

    • transmission_timestamp

    • packet_entry_point

    • entry_node_id

    • destination_node_id

get_nodes_location()[source]

Get locations of all nodes in the ring.

Returns

locations – An array of node locations.

Return type

numpy array

remove_packet(node_id, packet, reception_timestamp)[source]

Packet removal from the ring.

Parameters
  • node_id (int) – The ID of the node where the packet is removed.

  • packet (packet) – The packet to be removed from the ring, containing:

    • raw_packet

    • generation_timestamp

    • transmission_timestamp

    • packet_entry_point

    • entry_node_id

    • destination_node_id

  • reception_timestamp (float) – The timestamp at which the packet is removed.