qns.network package
Subpackages
- qns.network.protocol package
- Submodules
- qns.network.protocol.bb84 module
- qns.network.protocol.classicforward module
- qns.network.protocol.entanglement_distribution module
EntanglementDistributionApp
EntanglementDistributionApp.RecvClassicPacketHandler()
EntanglementDistributionApp.RecvQubitHandler()
EntanglementDistributionApp.generate_qubit()
EntanglementDistributionApp.handle_response()
EntanglementDistributionApp.install()
EntanglementDistributionApp.new_distribution()
EntanglementDistributionApp.request_distrbution()
EntanglementDistributionApp.response_distribution()
EntanglementDistributionApp.set_first_epr()
EntanglementDistributionApp.set_second_epr()
Transmit
- qns.network.protocol.node_process_delay module
- Module contents
BB84RecvApp
BB84SendApp
ClassicPacketForwardApp
EntanglementDistributionApp
EntanglementDistributionApp.RecvClassicPacketHandler()
EntanglementDistributionApp.RecvQubitHandler()
EntanglementDistributionApp.generate_qubit()
EntanglementDistributionApp.handle_response()
EntanglementDistributionApp.install()
EntanglementDistributionApp.new_distribution()
EntanglementDistributionApp.request_distrbution()
EntanglementDistributionApp.response_distribution()
EntanglementDistributionApp.set_first_epr()
EntanglementDistributionApp.set_second_epr()
NodeProcessDelayApp
- qns.network.route package
- qns.network.topology package
- Submodules
- qns.network.topology.basictopo module
- qns.network.topology.gridtopo module
- qns.network.topology.linetopo module
- qns.network.topology.randomtopo module
- qns.network.topology.topo module
- qns.network.topology.treetopo module
- qns.network.topology.waxmantopo module
- qns.network.topology.erdosrenyitopo module
- qns.network.topology.barabasialberttopo module
- qns.network.topology.dualbarabasialberttopo module
- Module contents
Submodules
qns.network.network module
- class qns.network.network.QuantumNetwork(topo: Topology | None = None, route: RouteImpl | None = None, classic_topo: ClassicTopology | None = ClassicTopology.Empty, name: str | None = None)[source]
Bases:
object
QuantumNetwork includes several quantum nodes, channels and a special topology
- add_cchannel(cchannel: ClassicChannel)[source]
add a ClassicChannel into this network.
- Parameters:
cchannel (qns.entity.cchannel.cchannel.ClassicChannel) – the inserting ClassicChannel
- add_memories(capacity: int = 0, decoherence_rate: float | None = 0, store_error_model_args: dict = {})[source]
Add quantum memories to every nodes in this network
- Parameters:
capacity (int) – the capacity of the quantum memory
decoherence_rate (float) – the decoherence rate
store_error_model_args – the arguments for store_error_model
- add_node(node: QNode)[source]
add a QNode into this network.
- Parameters:
node (qns.entity.node.node.QNode) – the inserting node
- add_qchannel(qchannel: QuantumChannel)[source]
add a QuantumChannel into this network.
- Parameters:
qchannel (qns.entity.qchannel.qchannel.QuantumChannel) – the inserting QuantumChannel
- add_request(src: QNode, dest: QNode, attr: Dict = {})[source]
Add a request (SD-pair) to the network
- Parameters:
src – the source node
dest – the destination node
attr – other attributions
- get_cchannel(name: str)[source]
get the ClassicChannel by its name
- Parameters:
name (str) – its name
- Returns:
the ClassicChannel
- get_node(name: str)[source]
get the QNode by its name
- Parameters:
name (str) – its name
- Returns:
the QNode
- get_qchannel(name: str)[source]
get the QuantumChannel by its name
- Parameters:
name (str) – its name
- Returns:
the QuantumChannel
- install(s: Simulator)[source]
install all nodes (including channels, memories and applications) in this network
- Parameters:
simulator (qns.simulator.simulator.Simulator) – the simulator
- query_route(src: QNode, dest: QNode) List[Tuple[float, QNode, List[QNode]]] [source]
query the metric, nexthop and the path
- Parameters:
src – the source node
dest – the destination node
- Returns:
A list of route paths. The result should be sortted by the priority. The element is a tuple containing: metric, the next-hop and the whole path.
qns.network.requests module
Module contents
- class qns.network.BarabasiAlbertTopology(nodes_number, new_nodes_egdes: int, nodes_apps: List[Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: List[Dict] | None = {})[source]
Bases:
Topology
BarabasiAlbertTopology is a random topology generator based on the Barabasi-Albert model. Each new QNode added has new_nodes_egdes to existing QNodes. The probability of a new QNode connecting to an existing QNode is proportional to the degree of the existing QNode.
- build() Tuple[List[QNode], List[QuantumChannel]] [source]
build the special topology
- Returns:
the list of QNodes and the list of QuantumChannel
- class qns.network.BasicTopology(nodes_number, nodes_apps: List[Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: List[Dict] | None = {})[source]
Bases:
Topology
BasicTopology includes nodes_number Qnodes. None of them are connected with each other
- build() Tuple[List[QNode], List[QuantumChannel]] [source]
build the special topology
- Returns:
the list of QNodes and the list of QuantumChannel
- class qns.network.DijkstraRouteAlgorithm(name: str = 'dijkstra', metric_func: Callable[[QuantumChannel | ClassicChannel], float] | None = None)[source]
Bases:
RouteImpl
This is the dijkstra route algorithm implement
- INF = inf
- build(nodes: List[QNode], channels: List[QuantumChannel | ClassicChannel])[source]
build static route tables for each nodes
- Parameters:
channels – a list of quantum channels or classic channels
- query(src: QNode, dest: QNode) List[Tuple[float, QNode, List[QNode]]] [source]
query the metric, nexthop and the path
- Parameters:
src – the source node
dest – the destination node
- Returns:
A list of route paths. The result should be sortted by the priority. The element is a tuple containing: metric, the next-hop and the whole path.
- class qns.network.DualBarabasiAlbertTopology(nodes_number, edges_num1: int, edges_num2: int, prob: float, nodes_apps: List[Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: List[Dict] | None = {})[source]
Bases:
Topology
DualBarabasiAlbertTopology is a random topology generator based on the Dual Barabasi-Albert model. Each new QNode added has either edges_num1 or edges_num2 edges to existing QNodes. The probability of a new QNode connecting to an existing QNode is proportional to the degree of the existing QNode.
- build() Tuple[List[QNode], List[QuantumChannel]] [source]
build the special topology
- Returns:
the list of QNodes and the list of QuantumChannel
- class qns.network.ErdosRenyiTopology(nodes_number, generate_prob: float, nodes_apps: List[Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: List[Dict] | None = {})[source]
Bases:
Topology
ErdosRenyiTopology includes nodes_number Qnodes. The topology is randomly generated following the Erdos-Renyi model(G(n,p) Model). Each pair of Qnodes has a probability generate_prob to be connected by a QuantumChannel.
- build() Tuple[List[QNode], List[QuantumChannel]] [source]
build the special topology
- Returns:
the list of QNodes and the list of QuantumChannel
- class qns.network.GridTopology(nodes_number, nodes_apps: List[Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: List[Dict] | None = {})[source]
Bases:
Topology
GridTopology includes nodes_number Qnodes. nodes_number should be a perfect square number. The topology is a square grid pattern, where each node has 4 neighbors.
- build() Tuple[List[QNode], List[QuantumChannel]] [source]
build the special topology
- Returns:
the list of QNodes and the list of QuantumChannel
- class qns.network.LineTopology(nodes_number, nodes_apps: List[Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: List[Dict] | None = {})[source]
Bases:
Topology
LineTopology includes nodes_number Qnodes. The topology is a line pattern.
- build() Tuple[List[QNode], List[QuantumChannel]] [source]
build the special topology
- Returns:
the list of QNodes and the list of QuantumChannel
- class qns.network.QuantumNetwork(topo: Topology | None = None, route: RouteImpl | None = None, classic_topo: ClassicTopology | None = ClassicTopology.Empty, name: str | None = None)[source]
Bases:
object
QuantumNetwork includes several quantum nodes, channels and a special topology
- add_cchannel(cchannel: ClassicChannel)[source]
add a ClassicChannel into this network.
- Parameters:
cchannel (qns.entity.cchannel.cchannel.ClassicChannel) – the inserting ClassicChannel
- add_memories(capacity: int = 0, decoherence_rate: float | None = 0, store_error_model_args: dict = {})[source]
Add quantum memories to every nodes in this network
- Parameters:
capacity (int) – the capacity of the quantum memory
decoherence_rate (float) – the decoherence rate
store_error_model_args – the arguments for store_error_model
- add_node(node: QNode)[source]
add a QNode into this network.
- Parameters:
node (qns.entity.node.node.QNode) – the inserting node
- add_qchannel(qchannel: QuantumChannel)[source]
add a QuantumChannel into this network.
- Parameters:
qchannel (qns.entity.qchannel.qchannel.QuantumChannel) – the inserting QuantumChannel
- add_request(src: QNode, dest: QNode, attr: Dict = {})[source]
Add a request (SD-pair) to the network
- Parameters:
src – the source node
dest – the destination node
attr – other attributions
- get_cchannel(name: str)[source]
get the ClassicChannel by its name
- Parameters:
name (str) – its name
- Returns:
the ClassicChannel
- get_node(name: str)[source]
get the QNode by its name
- Parameters:
name (str) – its name
- Returns:
the QNode
- get_qchannel(name: str)[source]
get the QuantumChannel by its name
- Parameters:
name (str) – its name
- Returns:
the QuantumChannel
- install(s: Simulator)[source]
install all nodes (including channels, memories and applications) in this network
- Parameters:
simulator (qns.simulator.simulator.Simulator) – the simulator
- query_route(src: QNode, dest: QNode) List[Tuple[float, QNode, List[QNode]]] [source]
query the metric, nexthop and the path
- Parameters:
src – the source node
dest – the destination node
- Returns:
A list of route paths. The result should be sortted by the priority. The element is a tuple containing: metric, the next-hop and the whole path.
- class qns.network.RandomTopology(nodes_number, lines_number: int, nodes_apps: List[Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: List[Dict] | None = {})[source]
Bases:
Topology
RandomTopology includes nodes_number Qnodes. The topology is randomly generated.
- build() Tuple[List[QNode], List[QuantumChannel]] [source]
build the special topology
- Returns:
the list of QNodes and the list of QuantumChannel
- class qns.network.Request(src, dest, attr: Dict = {})[source]
Bases:
object
A request is a source-destination pair represents a quantum transmitting request.
- class qns.network.RouteImpl(name: str = 'route')[source]
Bases:
object
This is the route protocol interface
- build(nodes: List[QNode], channels: List[QuantumChannel | ClassicChannel])[source]
build static route tables for each nodes
- Parameters:
channels – a list of quantum channels or classic channels
- query(src: QNode, dest: QNode) List[Tuple[float, QNode, List[QNode]]] [source]
query the metric, nexthop and the path
- Parameters:
src – the source node
dest – the destination node
- Returns:
A list of route paths. The result should be sortted by the priority. The element is a tuple containing: metric, the next-hop and the whole path.
- class qns.network.Topology(nodes_number: int, nodes_apps: List[Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: List[Dict] | None = {})[source]
Bases:
object
Topology is a factory for QuantumNetwork
- add_cchannels(classic_topo: ClassicTopology = ClassicTopology.Empty, nl: List[QNode] = [], ll: List[QuantumChannel] | None = None)[source]
build classic network topology
- Parameters:
classic_topo (ClassicTopology) – Classic topology, ClassicTopology.Empty -> no connection ClassicTopology.All -> every nodes are connected directly ClassicTopology.Follow -> follow the quantum topology
nl (List[qns.entity.node.node.QNode]) – a list of quantum nodes
ll (List[qns.entity.qchannel.qchannel.QuantumChannel]) – a list of quantum channels
- build() Tuple[List[QNode], List[QuantumChannel]] [source]
build the special topology
- Returns:
the list of QNodes and the list of QuantumChannel
- class qns.network.TreeTopology(nodes_number, children_number: int = 2, nodes_apps: List[Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: List[Dict] | None = {})[source]
Bases:
Topology
TreeTopology includes nodes_number Qnodes. The topology is a tree pattern, where each parent has children_num children.
- build() Tuple[List[QNode], List[QuantumChannel]] [source]
build the special topology
- Returns:
the list of QNodes and the list of QuantumChannel
- class qns.network.WaxmanTopology(nodes_number: int, size: float, alpha: float, beta: float, nodes_apps: List[Application] = [], qchannel_args: Dict = {}, cchannel_args: Dict = {}, memory_args: List[Dict] | None = {})[source]
Bases:
Topology
WaxmanTopology is the random topology generator using Waxman’s model.
- build() Tuple[List[QNode], List[QuantumChannel]] [source]
build the special topology
- Returns:
the list of QNodes and the list of QuantumChannel