control_node module¶
- class control_node.ControlNode(id, network_type=None)[source]¶
Bases:
NodeCentral controller node for managing quantum network switching.
- The control node is responsible for:
Maintaining a central registry mapping node names to their object instances.
Receiving heralding signals from switches and forwarding correction messages to the relevant quantum nodes.
Sending switching commands to configure the network, with topology-dependent routing logic (ring, tree, or simple).
Assigning a unique UUID to each routing request for correlation between switching commands and heralded corrections.
- Parameters:
id (int) – Unique integer identifier for the control node, included in its name as
CTRL[{id}].network_type (str, optional) –
Network topology type that determines which internal switching method is used. Supported values are:
"ring"– ring topology with intermediate relay configuration."tree"– hierarchical tree topology with a super-switch."simple"– single-switch topology.
Any other value defaults to no-op switching.
- __registry¶
Central mapping of registered node names to their object instances. Used for name → object resolution during switching and correction handling.
- Type:
dict[str, Node]
- __uuid_queue¶
Maps request UUIDs to the pair of quantum node names involved in the route.
- Type:
dict[str, tuple[str, str]]
- ports¶
Contains the
switch_heraldinput port for receiving heralding messages.- Type:
dict[str, Port]
- __logger¶
Logger instance for controller events.
- Type:
logging.Logger
- __switch_re¶
Compiled regex for parsing switch names (e.g.,
switch_2).- Type:
re.Pattern
- __qnode_re¶
Compiled regex for parsing quantum node names (e.g.,
qnode_5).- Type:
re.Pattern
Examples
>>> ctrl_node = ControlNode(id=0, network_type="ring") >>> ctrl_node.register_nodes([node_a, node_b, switch_0, switch_1]) >>> req_id = ctrl_node.request_route("qnode_0", "qnode_3") >>> isinstance(req_id, str) True
- register_nodes(node_list)[source]¶
Register a set of nodes with the controller.
Adds node objects to the internal registry so they can be referenced by name during switching and correction handling.
- Parameters:
node_list (list[netsquid.nodes.Node]) – List of node objects to register.
- request_route(qnode_1_name, qnode_2_name)[source]¶
Initiate a switching request between two quantum nodes.
Sends topology-dependent switching commands to configure the network, then generates and stores a request UUID to match future heralding corrections to this route.
- Parameters:
qnode_1_name (str) – Name of the first quantum node (e.g.,
"qnode_0").qnode_2_name (str) – Name of the second quantum node.
- Returns:
UUID string identifying this routing request.
- Return type:
str