Q2NS dev
ns-3 module
Loading...
Searching...
No Matches
q2ns::QNetworker Class Reference

Internal helper owned by QNode for node-local quantum networking. More...

#include <q2ns-qnetworker.h>

Collaboration diagram for q2ns::QNetworker:

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

QNodeowner_
 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.
 

Detailed Description

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:

  • Maintain a list of node-local quantum interfaces backed by QNetDevice.
  • Maintain a minimal host-route table mapping destination node id to outgoing interface index.
  • Send local qubits toward a destination node using the configured route.
  • Accept qubits delivered from a channel, adopt them into the owning node, apply any sampled channel map, and notify the registered receive callback.

Definition at line 54 of file q2ns-qnetworker.h.

Constructor & Destructor Documentation

◆ QNetworker()

q2ns::QNetworker::QNetworker ( QNode owner_)
explicit

Construct a networker bound to an owning node.

Parameters
[in]ownerOwning node.

Definition at line 31 of file q2ns-qnetworker.cc.

Member Function Documentation

◆ AddInterface()

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.

Parameters
devNetDevice to register.
Returns
Interface index assigned to the registered device.

Definition at line 35 of file q2ns-qnetworker.cc.

References m_ifaces.

◆ AddRoute()

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.

Parameters
dstNodeIdDestination node identifier.
oifOutgoing interface index.

Definition at line 46 of file q2ns-qnetworker.cc.

References m_hostRoutes.

◆ GetInterfaces()

const std::vector< ns3::Ptr< QNetDevice > > & q2ns::QNetworker::GetInterfaces ( ) const
inline

Get the registered outgoing interfaces.

Returns
Read-only reference to the interface table.

Definition at line 122 of file q2ns-qnetworker.h.

References m_ifaces.

◆ ReceiveFromDevice()

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.

Parameters
qDelivered qubit.
mapSampled 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Send()

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.

Parameters
qQubit to send.
dstNodeIdDestination node identifier.
Returns
True if the outgoing device accepted the transmission request, false otherwise.

Definition at line 52 of file q2ns-qnetworker.cc.

References q2ns::Lost, m_hostRoutes, m_ifaces, q2ns::Node, and owner_.

◆ SetRecvCallback()

void q2ns::QNetworker::SetRecvCallback ( RecvCallback  cb)

Set the application-level receive callback.

Parameters
cbCallback invoked for qubits successfully delivered to this node.

Definition at line 123 of file q2ns-qnetworker.cc.

References recvCallback_.

Member Data Documentation

◆ m_hostRoutes

std::unordered_map<uint32_t, uint32_t> q2ns::QNetworker::m_hostRoutes
private

Host routes: dst node id to oif.

Definition at line 130 of file q2ns-qnetworker.h.

Referenced by AddRoute(), and Send().

◆ m_ifaces

std::vector<ns3::Ptr<QNetDevice> > q2ns::QNetworker::m_ifaces
private

Outgoing interfaces by index.

Definition at line 129 of file q2ns-qnetworker.h.

Referenced by AddInterface(), GetInterfaces(), and Send().

◆ owner_

QNode& q2ns::QNetworker::owner_
private

Owning node.

Definition at line 127 of file q2ns-qnetworker.h.

Referenced by ReceiveFromDevice(), and Send().

◆ recvCallback_

RecvCallback q2ns::QNetworker::recvCallback_
private

Application-level receive callback.

Definition at line 131 of file q2ns-qnetworker.h.

Referenced by ReceiveFromDevice(), and SetRecvCallback().


The documentation for this class was generated from the following files: