qns.network.protocol package

Submodules

qns.network.protocol.bb84 module

class qns.network.protocol.bb84.BB84RecvApp(src: qns.entity.node.node.QNode, qchannel: qns.entity.qchannel.qchannel.QuantumChannel, cchannel: qns.entity.cchannel.cchannel.ClassicChannel)[source]

Bases: qns.entity.node.app.Application

check_basis(event: qns.entity.cchannel.cchannel.RecvClassicPacket)[source]
handleClassicPacket(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event)[source]
handleQuantumPacket(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event)[source]
recv(event: qns.entity.qchannel.qchannel.RecvQubitPacket)[source]
class qns.network.protocol.bb84.BB84SendApp(dest: qns.entity.node.node.QNode, qchannel: qns.entity.qchannel.qchannel.QuantumChannel, cchannel: qns.entity.cchannel.cchannel.ClassicChannel, send_rate=1000)[source]

Bases: qns.entity.node.app.Application

check_basis(event: qns.entity.cchannel.cchannel.RecvClassicPacket)[source]
handleClassicPacket(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event)[source]
install(node: qns.entity.node.node.QNode, simulator: qns.simulator.simulator.Simulator)[source]

install initial events for this QNode

Parameters
  • node (QNode) – the node that will handle this event

  • simulator (Simulator) – the simulator

send_qubit()[source]
class qns.network.protocol.bb84.QubitWithError(state=array([[1. + 0.j], [0. + 0.j]]), rho: Optional[numpy.ndarray] = None, operate_decoherence_rate: float = 0, measure_decoherence_rate: float = 0, name: Optional[str] = None)[source]

Bases: qns.models.qubit.qubit.Qubit

transfer_error_model(length: float, decoherence_rate: float = 0, **kwargs)[source]

The default error model for transmitting this qubit The default behavior is doing nothing

Parameters
  • length (float) – the length of the channel

  • decoherence_rate (float) – the decoherence rate

  • kwargs – other parameters

qns.network.protocol.classicforward module

class qns.network.protocol.classicforward.ClassicPacketForwardApp(route: qns.network.route.route.RouteImpl)[source]

Bases: qns.entity.node.app.Application

This application will generate routing table for classic networks and allow nodes to forward classic packats to the destination.

handleClassicPacket(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event)[source]
install(node: qns.entity.node.node.QNode, simulator: qns.simulator.simulator.Simulator)[source]

install initial events for this QNode

Parameters
  • node (QNode) – the node that will handle this event

  • simulator (Simulator) – the simulator

qns.network.protocol.entanglement_distribution module

class qns.network.protocol.entanglement_distribution.EntanglementDistributionApp(send_rate: Optional[int] = None, init_fidelity: int = 0.99)[source]

Bases: qns.entity.node.app.Application

RecvClassicPacketHandler(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event)[source]
RecvQubitHandler(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event)[source]
generate_qubit(src: qns.entity.node.node.QNode, dst: qns.entity.node.node.QNode, transmit_id: Optional[str] = None) qns.models.core.backend.QuantumModel[source]
handle_response(packet: qns.entity.cchannel.cchannel.RecvClassicPacket)[source]
install(node: qns.entity.node.node.QNode, simulator: qns.simulator.simulator.Simulator)[source]

install initial events for this QNode

Parameters
  • node (QNode) – the node that will handle this event

  • simulator (Simulator) – the simulator

new_distribution()[source]
request_distrbution(transmit_id: str)[source]
response_distribution(packet: qns.entity.qchannel.qchannel.RecvQubitPacket)[source]
set_first_epr(epr: qns.models.core.backend.QuantumModel, transmit_id: str)[source]
set_second_epr(epr: qns.models.core.backend.QuantumModel, transmit_id: str)[source]
class qns.network.protocol.entanglement_distribution.Transmit(id: str, src: qns.entity.node.node.QNode, dst: qns.entity.node.node.QNode, first_epr_name: Optional[str] = None, second_epr_name: Optional[str] = None)[source]

Bases: object

qns.network.protocol.node_process_delay module

class qns.network.protocol.node_process_delay.NodeProcessDelayApp(delay: float = 0, delay_event_list: Optional[Union[type, Tuple[type]]] = None)[source]

Bases: qns.entity.node.app.Application

This application will add an addition delay whenever the node received an event. It is used to represent the processing delay on quantum nodes.

check_in_delay_event_list(event) bool[source]
handle(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event) bool[source]

process the event on the node.

Parameters
  • node (QNode) – the node that will handle this event

  • event (Event) – the event

Returns

if skip is True, further applications will not handle this event

Return type

skip (bool, None)

install(node: qns.entity.node.node.QNode, simulator: qns.simulator.simulator.Simulator)[source]

install initial events for this QNode

Parameters
  • node (QNode) – the node that will handle this event

  • simulator (Simulator) – the simulator

Module contents

class qns.network.protocol.BB84RecvApp(src: qns.entity.node.node.QNode, qchannel: qns.entity.qchannel.qchannel.QuantumChannel, cchannel: qns.entity.cchannel.cchannel.ClassicChannel)[source]

Bases: qns.entity.node.app.Application

check_basis(event: qns.entity.cchannel.cchannel.RecvClassicPacket)[source]
handleClassicPacket(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event)[source]
handleQuantumPacket(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event)[source]
recv(event: qns.entity.qchannel.qchannel.RecvQubitPacket)[source]
class qns.network.protocol.BB84SendApp(dest: qns.entity.node.node.QNode, qchannel: qns.entity.qchannel.qchannel.QuantumChannel, cchannel: qns.entity.cchannel.cchannel.ClassicChannel, send_rate=1000)[source]

Bases: qns.entity.node.app.Application

check_basis(event: qns.entity.cchannel.cchannel.RecvClassicPacket)[source]
handleClassicPacket(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event)[source]
install(node: qns.entity.node.node.QNode, simulator: qns.simulator.simulator.Simulator)[source]

install initial events for this QNode

Parameters
  • node (QNode) – the node that will handle this event

  • simulator (Simulator) – the simulator

send_qubit()[source]
class qns.network.protocol.ClassicPacketForwardApp(route: qns.network.route.route.RouteImpl)[source]

Bases: qns.entity.node.app.Application

This application will generate routing table for classic networks and allow nodes to forward classic packats to the destination.

handleClassicPacket(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event)[source]
install(node: qns.entity.node.node.QNode, simulator: qns.simulator.simulator.Simulator)[source]

install initial events for this QNode

Parameters
  • node (QNode) – the node that will handle this event

  • simulator (Simulator) – the simulator

class qns.network.protocol.EntanglementDistributionApp(send_rate: Optional[int] = None, init_fidelity: int = 0.99)[source]

Bases: qns.entity.node.app.Application

RecvClassicPacketHandler(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event)[source]
RecvQubitHandler(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event)[source]
generate_qubit(src: qns.entity.node.node.QNode, dst: qns.entity.node.node.QNode, transmit_id: Optional[str] = None) qns.models.core.backend.QuantumModel[source]
handle_response(packet: qns.entity.cchannel.cchannel.RecvClassicPacket)[source]
install(node: qns.entity.node.node.QNode, simulator: qns.simulator.simulator.Simulator)[source]

install initial events for this QNode

Parameters
  • node (QNode) – the node that will handle this event

  • simulator (Simulator) – the simulator

new_distribution()[source]
request_distrbution(transmit_id: str)[source]
response_distribution(packet: qns.entity.qchannel.qchannel.RecvQubitPacket)[source]
set_first_epr(epr: qns.models.core.backend.QuantumModel, transmit_id: str)[source]
set_second_epr(epr: qns.models.core.backend.QuantumModel, transmit_id: str)[source]
class qns.network.protocol.NodeProcessDelayApp(delay: float = 0, delay_event_list: Optional[Union[type, Tuple[type]]] = None)[source]

Bases: qns.entity.node.app.Application

This application will add an addition delay whenever the node received an event. It is used to represent the processing delay on quantum nodes.

check_in_delay_event_list(event) bool[source]
handle(node: qns.entity.node.node.QNode, event: qns.simulator.event.Event) bool[source]

process the event on the node.

Parameters
  • node (QNode) – the node that will handle this event

  • event (Event) – the event

Returns

if skip is True, further applications will not handle this event

Return type

skip (bool, None)

install(node: qns.entity.node.node.QNode, simulator: qns.simulator.simulator.Simulator)[source]

install initial events for this QNode

Parameters
  • node (QNode) – the node that will handle this event

  • simulator (Simulator) – the simulator