16#include "ns3/q2ns-qnet-device.h"
17#include "ns3/q2ns-qnode.h"
18#include "ns3/q2ns-qubit.h"
20#include "ns3/channel.h"
27NS_LOG_COMPONENT_DEFINE(
"QNetworker");
37 ns3::Ptr<QNetDevice> qdev = DynamicCast<QNetDevice>(dev);
38 NS_ABORT_MSG_IF(qdev ==
nullptr,
"QNetworker requires QNetDevice interfaces");
41 return static_cast<uint32_t
>(
m_ifaces.size() - 1);
54 NS_LOG_WARN(
"Send rejected: null qubit.");
58 const auto loc = q->GetLocation();
60 NS_LOG_WARN(
"Send rejected: qubit " << q->GetQubitId() <<
" is lost.");
65 NS_LOG_WARN(
"Send rejected: qubit " << q->GetQubitId() <<
" is not local to this node.");
71 NS_LOG_WARN(
"Send rejected: no route to destination node " << dstNodeId <<
".");
75 const uint32_t oif = itRoutes->second;
77 NS_LOG_WARN(
"Send rejected: route references invalid interface index.");
83 NS_LOG_WARN(
"Send rejected: outgoing interface has no device.");
87 if (!dev->GetChannel()) {
88 NS_LOG_WARN(
"Send rejected: outgoing device is not attached to a channel.");
92 q->SetLocationChannel(dev->GetChannel()->GetId());
93 return dev->Send(std::move(q));
109 NS_LOG_WARN(
"ReceiveFromDevice terminated early with no adopted qubit: QMapInstance appears to "
111 "the qubit pointer to become null.");
115 const auto loc = q->GetLocation();
void AddRoute(uint32_t dstNodeId, uint32_t oif)
Add or replace a host route for a destination node.
void SetRecvCallback(RecvCallback cb)
Set the application-level receive callback.
std::vector< ns3::Ptr< QNetDevice > > m_ifaces
Outgoing interfaces by index.
bool Send(std::shared_ptr< Qubit > q, uint32_t dstNodeId)
Send a local qubit toward a destination node.
QNode & owner_
Owning node.
RecvCallback recvCallback_
Application-level receive callback.
uint32_t AddInterface(ns3::Ptr< ns3::NetDevice > dev)
Register a quantum device as an outgoing interface. Analogue of Ipv4L3Protocol::AddInterface(dev).
void ReceiveFromDevice(std::shared_ptr< Qubit > q, const QMapInstance &map)
Handle a qubit delivered from a channel.
std::unordered_map< uint32_t, uint32_t > m_hostRoutes
Host routes: dst node id to oif.
QNetworker(QNode &owner_)
Construct a networker bound to an owning node.
Main user-facing per-node API for quantum operations and transmission.
void AdoptQubit(const std::shared_ptr< Qubit > &q)
Mark a qubit as local to this node.
ns3::Callback< void, std::shared_ptr< Qubit > > RecvCallback
Callback invoked when a qubit is successfully received at a node.
std::function< void(QNode &, std::shared_ptr< Qubit > &)> QMapInstance
Per-transmission quantum map callable applied to a received qubit.
@ Node
Qubit is local to a node identified by node id.
@ Lost
Qubit was lost and is no longer accessible.
Declares q2ns::QNetworker, an internal per-node networking component for quantum transmission and rec...