Network

The Network component plays an important role in QuNetSim. In each simulation, one must configure a network with hosts. Each host defines its classical and quantum connections and when the host is added to the network, the network builds on the two graph objects for each type of connection it maintains. With these two network graphs, one can define their own routing algorithms for each type of network (e.g. there can be different routing algorithms for quantum and classical information). The default routing algorithm is set to the shortest path route between the two hosts.

The most commonly used methods for Network are:

  • add_host(host)
    • Add a host to the network

  • remove_host(host)
    • Remove a host from the network

  • update_host(host)
    • Updates the network graph when the connections of a host change

  • get_host(host_id)
    • Get the host object given the host_id

  • get_APR()
    • Get the information for all the hosts in the network

  • (property) quantum_routing_algo(function)
    • Property for the quantum routing algorithm. It should be a function with parameters that take a source ID and a destination ID and returns an ordered list which represents the route.

  • (property) classical_routing_algo(function)
    • Property for the classical routing algorithm. It should be a function with parameters that take a source ID and a destination ID and returns an ordered list which represents the route.

  • (property) use_hop_by_hop(bool)
    • If the network should recalculate the route at each node in the route (set to True) or just once at the beginning (set to False)

  • (property) delay(float)
    • the amount of delay the network should have. The network has the ability to throttle packet transmissions which is sometimes neccessary for different types of qubit / network backends.

  • (property) packet_drop_rate(float)
    • The probability that a packet is dropped on transmission in the network

  • (property) x_error_rate(float)
    • The probability that a qubit has an \(X\) gate applied to in at each host in the route

  • (property) z_error_rate(float)
    • The probability that a qubit has an \(Z\) gate applied to in at each host in the route

  • draw_classical_network
    • Generate a depiction of the classical network

  • draw_quantum_network
    • Generate a depiction of the quantum network (via matplotlib)

class qunetsim.components.network.Network

Bases: object

A network control singleton object.

_encode(route, payload, ttl=10)

Adds another layer to the packet if route length between sender and receiver is greater than 2. Sets the protocol flag in this layer to RELAY and payload_type as SIGNAL and adds a variable Time-To-Live information in this layer.

Parameters
  • route – route of the packet from sender to receiver

  • payload (Object) – Lower layers of the packet

  • ttl (int) – Time-to-Live parameter

Returns

Encoded RELAY packet

Return type

RoutingPacket

_entanglement_swap(sender, receiver, route, q_id, o_seq_num, blocked)

Performs a chain of entanglement swaps with the hosts between sender and receiver to create a shared EPR pair between sender and receiver.

Parameters
  • sender (Host) – Sender of the EPR pair

  • receiver (Host) – Receiver of the EPR pair

  • route (list) – Route between the sender and receiver

  • q_id (str) – Qubit ID of the sent EPR pair

  • o_seq_num (int) – The original sequence number

  • blocked (bool) – If the pair being distributed is blocked or not

_establish_epr(sender, receiver, q_id, o_seq_num, blocked)

Instead doing an entanglement swap, for efficiency we establish EPR pairs directly for simulation, if an entanglement swap would have been possible.

Parameters
  • sender (Host) – Sender of the EPR pair

  • receiver (Host) – Receiver of the EPR pair

  • q_id (str) – Qubit ID of the sent EPR pair

  • o_seq_num (int) – The original sequence number

  • blocked (bool) – If the pair being distributed is blocked or not

_process_queue()

Runs a thread for processing the packets in the packet queue.

_remove_network_node(host)

Removes the host from the ARP table.

Parameters

host (Host) – The host to be removed from the network.

_route_quantum_info(sender, receiver, qubits)

Routes qubits from sender to receiver.

Parameters
  • sender (Host) – Sender of qubits

  • receiver (Host) – Receiver qubits

  • qubits (List of Qubits) – The qubits to be sent

_update_network_graph(host)

Add host host to the network and update the graph representation of the network

Parameters

host – The host to be added

add_host(host)

Adds the host to ARP table and updates the network graph.

Parameters

host (Host) – The host to be added to the network.

add_hosts(hosts)

Adds the hosts to ARP table and updates the network graph.

Parameters

hosts (list) – The hosts to be added to the network.

property classical_routing_algo

Get the routing algorithm for the network.

property delay

Get the delay interval of the network.

draw_classical_network()

Draws a plot of the network.

draw_quantum_network()

Draws a plot of the network.

generate_c_topology(host_names: list, topology: str = 'mesh') → None

Adjusts a network that already exists by adding quantum connections that fit the desired network topology. This method either adds new nodes or adds connections to existing hosts within the network.

The supported network topologies are mesh, star, ring, linear, and tree.

Parameters
  • host_names (list) – The names for the new hosts.

  • topology (str) – The network topology that will be created.

generate_q_topology(host_names: list, topology: str = 'mesh') → None

Adjusts a network that already exists by adding quantum connections that fit the desired network topology. This method either adds new nodes or adds connections to existing hosts within the network.

The supported network topologies are mesh, star, ring, linear, and tree.

Parameters
  • host_names (list) – The names for the new hosts.

  • topology (str) – The network topology that will be created.

generate_topology(host_names: list, topology: str = 'mesh') → None

Adjusts a network that already exists by adding both classic and quantum connections that fit the desired network topology. This method either adds new nodes or adds connections to existing hosts within the network.

The supported network topologies are mesh, star, ring, linear, and tree.

Parameters
  • host_names (list) – The names for the new hosts.

  • topology (str) – The network topology that will be created.

get_ARP()

Returns the ARP table.

Returns

The ARP table

Return type

dict

get_classical_route(source, dest)

Gets the route for classical information from source to destination.

Parameters
  • source (str) – ID of the source host

  • dest (str) – ID of the destination host

Returns

An ordered list of ID numbers on the shortest path from source to destination.

Return type

route (list)

get_host(host_id)

Returns the host with the host_id.

Parameters

host_id (str) – ID number of the host that is returned.

Returns

Host with the host_id

Return type

Host (Host)

get_host_name(host_id)
Parameters

host_id (str) – ID number of the host whose name is returned if it is in ARP table

Returns the name of the host with host_id if the host is in ARP table , otherwise returns None.

Returns

Name of the host

Return type

dict or None

get_quantum_route(source, dest)

Gets the route for quantum information from source to destination.

Parameters
  • source (str) – ID of the source host

  • dest (str) – ID of the destination host

Returns

An ordered list of ID numbers on the shortest path from source to destination.

Return type

route (list)

property packet_drop_rate

Get the drop rate of the network.

property quantum_routing_algo

Gets the quantum routing algorithm of the network.

Returns

The quantum routing algorithm of the network

Return type

algorithm (function)

remove_host(host)

Removes the host from the network.

Parameters

host (Host) – The host to be removed from the network.

send(packet)

Puts the packet to the packet queue of the network.

Parameters

packet (Packet) – Packet to be sent

shares_epr(sender, receiver)

Returns boolean value dependent on if the sender and receiver share an EPR pair.

Parameters
  • receiver (Host) – The receiver

  • sender (Host) – The sender

Returns

(bool) whether the sender and receiver share an EPR pair.

start(nodes=None, backend=None)

Starts the network.

stop(stop_hosts=False)

Stops the network.

update_host(host)

Update the connections of a host in the network. :param host:

Returns:

property use_hop_by_hop

Get the routing style for the network.

Returns

If the network uses hop by hop routing.