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

Duplex quantum channel with configurable delay, jitter, and transit maps. More...

#include <q2ns-qchannel.h>

Inheritance diagram for q2ns::QChannel:
Collaboration diagram for q2ns::QChannel:

Public Member Functions

 QChannel ()
 Default constructor.
 
void SetDelay (ns3::Time d)
 Set the same propagation delay in both directions.
 
ns3::Time GetDelay () const
 Get the A->B propagation delay.
 
void SetJitter (ns3::Time j)
 Set the same jitter in both directions.
 
ns3::Time GetJitter () const
 Get the A->B jitter.
 
void SetQMap (ns3::Ptr< QMap > m)
 Set the same transit QMap in both directions.
 
ns3::Ptr< QMapGetQMap () const
 Get the A->B transit QMap.
 
void SetDelayAB (ns3::Time d)
 Set the one-way delay from A to B.
 
ns3::Time GetDelayAB () const
 Get the one-way delay from A to B.
 
void SetDelayBA (ns3::Time d)
 Set the one-way delay from B to A.
 
ns3::Time GetDelayBA () const
 Get the one-way delay from B to A.
 
void SetJitterAB (ns3::Time j)
 Set the one-way jitter from A to B.
 
ns3::Time GetJitterAB () const
 Get the one-way jitter from A to B.
 
void SetJitterBA (ns3::Time j)
 Set the one-way jitter from B to A.
 
ns3::Time GetJitterBA () const
 Get the one-way jitter from B to A.
 
void SetQMapAB (ns3::Ptr< QMap > m)
 Set the one-way transit QMap from A to B.
 
ns3::Ptr< QMapGetQMapAB () const
 Get the one-way transit QMap from A to B.
 
void SetQMapBA (ns3::Ptr< QMap > m)
 Set the one-way transit QMap from B to A.
 
ns3::Ptr< QMapGetQMapBA () const
 Get the one-way transit QMap from B to A.
 
void Connect (ns3::Ptr< QNetDevice > a, ns3::Ptr< QNetDevice > b)
 Connect two QNetDevice endpoints to this channel.
 
std::size_t GetNDevices () const override
 Return the number of attached devices.
 
ns3::Ptr< ns3::NetDevice > GetDevice (std::size_t i) const override
 Return an attached device by endpoint index.
 
int64_t AssignStreams (int64_t stream)
 Assign RNG streams used by this channel.
 

Static Public Member Functions

static ns3::TypeId GetTypeId (void)
 Get the ns-3 TypeId.
 

Protected Member Functions

 ~QChannel () override=default
 Protected destructor to prevent stack allocation.
 

Private Member Functions

bool SendFrom (QNetDevice *src, std::shared_ptr< Qubit > q)
 Send a qubit from one endpoint to the opposite endpoint.
 

Private Attributes

ns3::Ptr< QNetDeviceaDev_
 Device attached to endpoint A.
 
ns3::Ptr< QNetDevicebDev_
 Device attached to endpoint B.
 
ns3::Time delayAB_ {}
 Propagation delay from A to B.
 
ns3::Time delayBA_ {}
 Propagation delay from B to A.
 
ns3::Time jitterAB_ {ns3::Time(0.0)}
 Jitter magnitude from A to B.
 
ns3::Time jitterBA_ {ns3::Time(0.0)}
 Jitter magnitude from B to A.
 
ns3::Ptr< ns3::UniformRandomVariable > jitterRv_
 Jitter sampler.
 
ns3::Ptr< QMapqmapAB_
 Transit QMap from A to B. Null means identity.
 
ns3::Ptr< QMapqmapBA_
 Transit QMap from B to A. Null means identity.
 
ns3::Ptr< ns3::UniformRandomVariable > mapRv_
 QMap sampler.
 
friend QNetDevice
 

Detailed Description

Duplex quantum channel with configurable delay, jitter, and transit maps.

QChannel connects exactly two QNetDevice endpoints, referred to as A and B. Delay, jitter, and QMap configuration may be set symmetrically for both directions or independently for A->B and B->A.

On each transmission, the channel selects the direction-specific delay, applies an optional random jitter to that delay, samples the direction- specific QMap to obtain a per-transmission QMapInstance, and schedules delivery to the opposite endpoint.

The sampled QMapInstance is not applied immediately in the channel. Instead, it is delivered alongside the qubit and later executed at the receiving node after the qubit becomes local there.

See also
QNetDevice
QMap

Definition at line 53 of file q2ns-qchannel.h.

Constructor & Destructor Documentation

◆ QChannel()

q2ns::QChannel::QChannel ( )

Default constructor.

Definition at line 84 of file q2ns-qchannel.cc.

References jitterRv_, and mapRv_.

◆ ~QChannel()

q2ns::QChannel::~QChannel ( )
overrideprotecteddefault

Protected destructor to prevent stack allocation.

Member Function Documentation

◆ AssignStreams()

int64_t q2ns::QChannel::AssignStreams ( int64_t  stream)

Assign RNG streams used by this channel.

Streams are assigned to the jitter and QMap sampling random variables.

Parameters
streamStarting stream index.
Returns
Number of streams consumed.

Definition at line 370 of file q2ns-qchannel.cc.

References jitterRv_, and mapRv_.

◆ Connect()

void q2ns::QChannel::Connect ( ns3::Ptr< QNetDevice a,
ns3::Ptr< QNetDevice b 
)

Connect two QNetDevice endpoints to this channel.

The provided devices become endpoints A and B. Each device is also updated to reference this channel.

Parameters
aEndpoint A device.
bEndpoint B device.
See also
QNetDevice::AttachChannel

Definition at line 256 of file q2ns-qchannel.cc.

References aDev_, and bDev_.

◆ GetDelay()

ns3::Time q2ns::QChannel::GetDelay ( ) const

Get the A->B propagation delay.

If the channel is configured asymmetrically, this returns the A->B delay. Use GetDelayBA() to query the opposite direction explicitly.

Returns
A->B propagation delay.
See also
GetDelayAB
GetDelayBA

Definition at line 103 of file q2ns-qchannel.cc.

References delayAB_, and delayBA_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ GetDelayAB()

ns3::Time q2ns::QChannel::GetDelayAB ( ) const

Get the one-way delay from A to B.

Returns
Propagation delay from A to B.

Definition at line 167 of file q2ns-qchannel.cc.

References delayAB_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ GetDelayBA()

ns3::Time q2ns::QChannel::GetDelayBA ( ) const

Get the one-way delay from B to A.

Returns
Propagation delay from B to A.

Definition at line 184 of file q2ns-qchannel.cc.

References delayBA_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ GetDevice()

ns3::Ptr< ns3::NetDevice > q2ns::QChannel::GetDevice ( std::size_t  i) const
override

Return an attached device by endpoint index.

Parameters
iEndpoint index, where 0 selects A and 1 selects B.
Returns
Attached device pointer, or nullptr if the index is invalid or the endpoint is not attached.

Definition at line 358 of file q2ns-qchannel.cc.

References aDev_, and bDev_.

◆ GetJitter()

ns3::Time q2ns::QChannel::GetJitter ( ) const

Get the A->B jitter.

If the channel is configured asymmetrically, this returns the A->B jitter. Use GetJitterBA() to query the opposite direction explicitly.

Returns
A->B jitter magnitude.
See also
GetJitterAB
GetJitterBA

Definition at line 125 of file q2ns-qchannel.cc.

References jitterAB_, and jitterBA_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ GetJitterAB()

ns3::Time q2ns::QChannel::GetJitterAB ( ) const

Get the one-way jitter from A to B.

Returns
Jitter magnitude from A to B.

Definition at line 201 of file q2ns-qchannel.cc.

References jitterAB_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ GetJitterBA()

ns3::Time q2ns::QChannel::GetJitterBA ( ) const

Get the one-way jitter from B to A.

Returns
Jitter magnitude from B to A.

Definition at line 218 of file q2ns-qchannel.cc.

References jitterBA_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ GetNDevices()

std::size_t q2ns::QChannel::GetNDevices ( ) const
override

Return the number of attached devices.

Returns
Number of attached devices in the range [0, 2].

Definition at line 345 of file q2ns-qchannel.cc.

References aDev_, and bDev_.

◆ GetQMap()

ns3::Ptr< QMap > q2ns::QChannel::GetQMap ( ) const

Get the A->B transit QMap.

If the channel is configured asymmetrically, this returns the A->B map. Use GetQMapBA() to query the opposite direction explicitly.

Returns
A->B transit QMap, or nullptr for identity behavior.
See also
GetQMapAB
GetQMapBA

Definition at line 146 of file q2ns-qchannel.cc.

References qmapAB_, and qmapBA_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ GetQMapAB()

ns3::Ptr< QMap > q2ns::QChannel::GetQMapAB ( ) const

Get the one-way transit QMap from A to B.

Returns
Transit QMap from A to B, or nullptr for identity behavior.

Definition at line 234 of file q2ns-qchannel.cc.

References qmapAB_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ GetQMapBA()

ns3::Ptr< QMap > q2ns::QChannel::GetQMapBA ( ) const

Get the one-way transit QMap from B to A.

Returns
Transit QMap from B to A, or nullptr for identity behavior.

Definition at line 250 of file q2ns-qchannel.cc.

References qmapBA_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ GetTypeId()

ns3::TypeId q2ns::QChannel::GetTypeId ( void  )
static

Get the ns-3 TypeId.

Returns
TypeId for q2ns::QChannel.

Definition at line 32 of file q2ns-qchannel.cc.

References GetDelay(), GetDelayAB(), GetDelayBA(), GetJitter(), GetJitterAB(), GetJitterBA(), GetQMap(), GetQMapAB(), GetQMapBA(), SetDelay(), SetDelayAB(), SetDelayBA(), SetJitter(), SetJitterAB(), SetJitterBA(), SetQMap(), SetQMapAB(), and SetQMapBA().

Here is the call graph for this function:

◆ SendFrom()

bool q2ns::QChannel::SendFrom ( QNetDevice src,
std::shared_ptr< Qubit q 
)
private

Send a qubit from one endpoint to the opposite endpoint.

The source device must be one of the two attached endpoints. The direction- specific delay, jitter, and QMap are selected from that source endpoint. Delivery is scheduled after the resulting propagation delay.

Parameters
srcSource device. Must be either endpoint A or endpoint B.
qQubit to transmit.
Returns
True if the transmission request was accepted, false otherwise.

Definition at line 278 of file q2ns-qchannel.cc.

References aDev_, bDev_, delayAB_, delayBA_, q2ns::QMapContext::elapsedTime, jitterAB_, jitterBA_, jitterRv_, q2ns::Lost, mapRv_, qmapAB_, and qmapBA_.

◆ SetDelay()

void q2ns::QChannel::SetDelay ( ns3::Time  d)

Set the same propagation delay in both directions.

Parameters
dPropagation delay.
See also
SetDelayAB
SetDelayBA

Definition at line 91 of file q2ns-qchannel.cc.

References delayAB_, and delayBA_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ SetDelayAB()

void q2ns::QChannel::SetDelayAB ( ns3::Time  d)

Set the one-way delay from A to B.

Parameters
dPropagation delay from A to B.
See also
SetDelay
GetDelayAB

Definition at line 156 of file q2ns-qchannel.cc.

References delayAB_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ SetDelayBA()

void q2ns::QChannel::SetDelayBA ( ns3::Time  d)

Set the one-way delay from B to A.

Parameters
dPropagation delay from B to A.
See also
SetDelay
GetDelayBA

Definition at line 173 of file q2ns-qchannel.cc.

References delayBA_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ SetJitter()

void q2ns::QChannel::SetJitter ( ns3::Time  j)

Set the same jitter in both directions.

Jitter is sampled uniformly in [-jitter, +jitter] and added to the base delay on each transmission, with a minimum resulting delay of zero.

Parameters
jSymmetric jitter magnitude.
See also
SetJitterAB
SetJitterBA

Definition at line 113 of file q2ns-qchannel.cc.

References jitterAB_, and jitterBA_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ SetJitterAB()

void q2ns::QChannel::SetJitterAB ( ns3::Time  j)

Set the one-way jitter from A to B.

Parameters
jJitter magnitude from A to B.
See also
SetJitter
GetJitterAB

Definition at line 190 of file q2ns-qchannel.cc.

References jitterAB_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ SetJitterBA()

void q2ns::QChannel::SetJitterBA ( ns3::Time  j)

Set the one-way jitter from B to A.

Parameters
jJitter magnitude from B to A.
See also
SetJitter
GetJitterBA

Definition at line 207 of file q2ns-qchannel.cc.

References jitterBA_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ SetQMap()

void q2ns::QChannel::SetQMap ( ns3::Ptr< QMap m)

Set the same transit QMap in both directions.

A null map is treated as the identity map.

Parameters
mSymmetric transit QMap.
See also
SetQMapAB
SetQMapBA

Definition at line 135 of file q2ns-qchannel.cc.

References qmapAB_, and qmapBA_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ SetQMapAB()

void q2ns::QChannel::SetQMapAB ( ns3::Ptr< QMap m)

Set the one-way transit QMap from A to B.

Parameters
mTransit QMap from A to B.
See also
SetQMap
GetQMapAB

Definition at line 224 of file q2ns-qchannel.cc.

References qmapAB_.

Referenced by GetTypeId().

Here is the caller graph for this function:

◆ SetQMapBA()

void q2ns::QChannel::SetQMapBA ( ns3::Ptr< QMap m)

Set the one-way transit QMap from B to A.

Parameters
mTransit QMap from B to A.
See also
SetQMap
GetQMapBA

Definition at line 240 of file q2ns-qchannel.cc.

References qmapBA_.

Referenced by GetTypeId().

Here is the caller graph for this function:

Member Data Documentation

◆ aDev_

ns3::Ptr<QNetDevice> q2ns::QChannel::aDev_
private

Device attached to endpoint A.

Definition at line 286 of file q2ns-qchannel.h.

Referenced by Connect(), GetDevice(), GetNDevices(), and SendFrom().

◆ bDev_

ns3::Ptr<QNetDevice> q2ns::QChannel::bDev_
private

Device attached to endpoint B.

Definition at line 287 of file q2ns-qchannel.h.

Referenced by Connect(), GetDevice(), GetNDevices(), and SendFrom().

◆ delayAB_

ns3::Time q2ns::QChannel::delayAB_ {}
private

Propagation delay from A to B.

Definition at line 289 of file q2ns-qchannel.h.

Referenced by GetDelay(), GetDelayAB(), SendFrom(), SetDelay(), and SetDelayAB().

◆ delayBA_

ns3::Time q2ns::QChannel::delayBA_ {}
private

Propagation delay from B to A.

Definition at line 290 of file q2ns-qchannel.h.

Referenced by GetDelay(), GetDelayBA(), SendFrom(), SetDelay(), and SetDelayBA().

◆ jitterAB_

ns3::Time q2ns::QChannel::jitterAB_ {ns3::Time(0.0)}
private

Jitter magnitude from A to B.

Definition at line 292 of file q2ns-qchannel.h.

Referenced by GetJitter(), GetJitterAB(), SendFrom(), SetJitter(), and SetJitterAB().

◆ jitterBA_

ns3::Time q2ns::QChannel::jitterBA_ {ns3::Time(0.0)}
private

Jitter magnitude from B to A.

Definition at line 293 of file q2ns-qchannel.h.

Referenced by GetJitter(), GetJitterBA(), SendFrom(), SetJitter(), and SetJitterBA().

◆ jitterRv_

ns3::Ptr<ns3::UniformRandomVariable> q2ns::QChannel::jitterRv_
private

Jitter sampler.

Definition at line 294 of file q2ns-qchannel.h.

Referenced by AssignStreams(), QChannel(), and SendFrom().

◆ mapRv_

ns3::Ptr<ns3::UniformRandomVariable> q2ns::QChannel::mapRv_
private

QMap sampler.

Definition at line 298 of file q2ns-qchannel.h.

Referenced by AssignStreams(), QChannel(), and SendFrom().

◆ qmapAB_

ns3::Ptr<QMap> q2ns::QChannel::qmapAB_
private

Transit QMap from A to B. Null means identity.

Definition at line 296 of file q2ns-qchannel.h.

Referenced by GetQMap(), GetQMapAB(), SendFrom(), SetQMap(), and SetQMapAB().

◆ qmapBA_

ns3::Ptr<QMap> q2ns::QChannel::qmapBA_
private

Transit QMap from B to A. Null means identity.

Definition at line 297 of file q2ns-qchannel.h.

Referenced by GetQMap(), GetQMapBA(), SendFrom(), SetQMap(), and SetQMapBA().

◆ QNetDevice

friend q2ns::QChannel::QNetDevice
private

Definition at line 300 of file q2ns-qchannel.h.


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