![]() |
Q2NS dev
ns-3 module
|
Internal helper owned by QNode for node-local quantum networking. More...
#include <q2ns-qnetworker.h>
Public Member Functions | |
| QNetworker (QNode &owner_) | |
| Construct a networker bound to an owning node. | |
| uint32_t | AddInterface (ns3::Ptr< ns3::NetDevice > dev) |
| Register a quantum device as an outgoing interface. Analogue of Ipv4L3Protocol::AddInterface(dev). | |
| void | AddRoute (uint32_t dstNodeId, uint32_t oif) |
| Add or replace a host route for a destination node. | |
| bool | Send (std::shared_ptr< Qubit > q, uint32_t dstNodeId) |
| Send a local qubit toward a destination node. | |
| void | ReceiveFromDevice (std::shared_ptr< Qubit > q, const QMapInstance &map) |
| Handle a qubit delivered from a channel. | |
| void | SetRecvCallback (RecvCallback cb) |
| Set the application-level receive callback. | |
| const std::vector< ns3::Ptr< QNetDevice > > & | GetInterfaces () const |
| Get the registered outgoing interfaces. | |
Private Attributes | |
| QNode & | owner_ |
| Owning node. | |
| std::vector< ns3::Ptr< QNetDevice > > | m_ifaces |
| Outgoing interfaces by index. | |
| std::unordered_map< uint32_t, uint32_t > | m_hostRoutes |
| Host routes: dst node id to oif. | |
| RecvCallback | recvCallback_ |
| Application-level receive callback. | |
Internal helper owned by QNode for node-local quantum networking.
QNetworker is not intended to be the main user-facing API. Instead, users should send qubits and register receive callbacks through QNode, which delegates network-facing behavior to its internal QNetworker.
Responsibilities:
Definition at line 54 of file q2ns-qnetworker.h.
|
explicit |
Construct a networker bound to an owning node.
| [in] | owner | Owning node. |
Definition at line 31 of file q2ns-qnetworker.cc.
| uint32_t q2ns::QNetworker::AddInterface | ( | ns3::Ptr< ns3::NetDevice > | dev | ) |
Register a quantum device as an outgoing interface. Analogue of Ipv4L3Protocol::AddInterface(dev).
The supplied device must be a QNetDevice.
| dev | NetDevice to register. |
Definition at line 35 of file q2ns-qnetworker.cc.
References m_ifaces.
| void q2ns::QNetworker::AddRoute | ( | uint32_t | dstNodeId, |
| uint32_t | oif | ||
| ) |
Add or replace a host route for a destination node.
The route maps a destination node id to an outgoing interface index.
| dstNodeId | Destination node identifier. |
| oif | Outgoing interface index. |
Definition at line 46 of file q2ns-qnetworker.cc.
References m_hostRoutes.
|
inline |
Get the registered outgoing interfaces.
Definition at line 122 of file q2ns-qnetworker.h.
References m_ifaces.
| void q2ns::QNetworker::ReceiveFromDevice | ( | std::shared_ptr< Qubit > | q, |
| const QMapInstance & | map | ||
| ) |
Handle a qubit delivered from a channel.
The qubit is first adopted into the owning node. If a sampled QMapInstance is provided, it is then applied. If the qubit is not lost after that processing, the registered receive callback is invoked.
| q | Delivered qubit. |
| map | Sampled per-transmission channel map to apply on receipt. |
Definition at line 98 of file q2ns-qnetworker.cc.
References q2ns::QNode::AdoptQubit(), q2ns::Lost, owner_, and recvCallback_.
Referenced by q2ns::QNetDevice::ReceiveFromChannel().
| bool q2ns::QNetworker::Send | ( | std::shared_ptr< Qubit > | q, |
| uint32_t | dstNodeId | ||
| ) |
Send a local qubit toward a destination node.
The qubit must be local to the owning node and not lost. The destination must have a configured host route that resolves to a valid outgoing interface and attached channel.
On successful acceptance by the outgoing device, the qubit location is updated to the channel before transmission proceeds.
| q | Qubit to send. |
| dstNodeId | Destination node identifier. |
Definition at line 52 of file q2ns-qnetworker.cc.
References q2ns::Lost, m_hostRoutes, m_ifaces, q2ns::Node, and owner_.
| void q2ns::QNetworker::SetRecvCallback | ( | RecvCallback | cb | ) |
Set the application-level receive callback.
| cb | Callback invoked for qubits successfully delivered to this node. |
Definition at line 123 of file q2ns-qnetworker.cc.
References recvCallback_.
|
private |
Host routes: dst node id to oif.
Definition at line 130 of file q2ns-qnetworker.h.
Referenced by AddRoute(), and Send().
|
private |
Outgoing interfaces by index.
Definition at line 129 of file q2ns-qnetworker.h.
Referenced by AddInterface(), GetInterfaces(), and Send().
|
private |
Owning node.
Definition at line 127 of file q2ns-qnetworker.h.
Referenced by ReceiveFromDevice(), and Send().
|
private |
Application-level receive callback.
Definition at line 131 of file q2ns-qnetworker.h.
Referenced by ReceiveFromDevice(), and SetRecvCallback().