A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ns3::lorawan::LoraChannel Class Reference

The class that delivers packets among PHY layers. More...

#include "lora-channel.h"

+ Inheritance diagram for ns3::lorawan::LoraChannel:
+ Collaboration diagram for ns3::lorawan::LoraChannel:

Public Member Functions

 LoraChannel ()
 Default constructor.
 
 LoraChannel (Ptr< PropagationLossModel > loss, Ptr< PropagationDelayModel > delay)
 Construct a LoraChannel with a loss and delay model.
 
 ~LoraChannel () override
 Destructor.
 
void Add (Ptr< LoraPhy > phy)
 Connect a LoraPhy object to the LoraChannel.
 
Ptr< NetDeviceGetDevice (std::size_t i) const override
 
std::size_t GetNDevices () const override
 
double GetRxPower (double txPowerDbm, Ptr< MobilityModel > senderMobility, Ptr< MobilityModel > receiverMobility) const
 Compute the received power when transmitting from a point to another one.
 
void Remove (Ptr< LoraPhy > phy)
 Remove a physical layer from the LoraChannel.
 
void Send (Ptr< LoraPhy > sender, Ptr< Packet > packet, double txPowerDbm, LoraTxParameters txParams, Time duration, double frequencyMHz) const
 Send a packet in the channel.
 
- Public Member Functions inherited from ns3::Channel
 Channel ()
 
 ~Channel () override
 
virtual Ptr< NetDeviceGetDevice (std::size_t i) const =0
 
uint32_t GetId () const
 
virtual std::size_t GetNDevices () const =0
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
virtual TypeId GetInstanceTypeId () const =0
 Get the most derived TypeId for this Object.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::Channel
static TypeId GetTypeId ()
 Get the type ID.
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type.
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID.
 

Private Member Functions

void Receive (uint32_t i, Ptr< Packet > packet, LoraChannelParameters parameters) const
 Private method that is scheduled by LoraChannel's Send method to happen after the channel delay, for each of the connected PHY layers.
 

Private Attributes

Ptr< PropagationDelayModelm_delay
 Pointer to the delay model.
 
Ptr< PropagationLossModelm_loss
 Pointer to the loss model.
 
TracedCallback< Ptr< const Packet > > m_packetSent
 Callback for when a packet is being sent on the channel.
 
std::vector< Ptr< LoraPhy > > m_phyList
 The vector containing the PHYs that are currently connected to the channel.
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object.
 
virtual void DoDispose ()
 Destructor implementation.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Detailed Description

The class that delivers packets among PHY layers.

This class is tasked with taking packets that PHY layers want to send and, based on some factors like the transmission power and the node positions, computing the power at every receiver using a PropagationLossModel and notifying them of the reception event after a delay based on some PropagationDelayModel.

Definition at line 81 of file lora-channel.h.

Constructor & Destructor Documentation

◆ LoraChannel() [1/2]

ns3::lorawan::LoraChannel::LoraChannel ( )

Default constructor.

Definition at line 67 of file lora-channel.cc.

◆ ~LoraChannel()

ns3::lorawan::LoraChannel::~LoraChannel ( )
override

Destructor.

Definition at line 71 of file lora-channel.cc.

References m_phyList.

◆ LoraChannel() [2/2]

ns3::lorawan::LoraChannel::LoraChannel ( Ptr< PropagationLossModel loss,
Ptr< PropagationDelayModel delay 
)

Construct a LoraChannel with a loss and delay model.

Parameters
lossThe loss model to associate to this channel.
delayThe delay model to associate to this channel.

Definition at line 76 of file lora-channel.cc.

Member Function Documentation

◆ Add()

void ns3::lorawan::LoraChannel::Add ( Ptr< LoraPhy phy)

Connect a LoraPhy object to the LoraChannel.

This method is needed so that the channel knows it has to notify this PHY of incoming transmissions.

Parameters
phyThe physical layer to add.

Definition at line 83 of file lora-channel.cc.

References m_phyList, and NS_LOG_FUNCTION.

Referenced by PhyConnectivityTest::Reset().

+ Here is the caller graph for this function:

◆ GetDevice()

Ptr< NetDevice > ns3::lorawan::LoraChannel::GetDevice ( std::size_t  i) const
overridevirtual
Parameters
iindex of NetDevice to retrieve
Returns
one of the NetDevices connected to this channel.

This method must be implemented by subclasses.

Implements ns3::Channel.

Definition at line 107 of file lora-channel.cc.

References m_phyList.

◆ GetNDevices()

std::size_t ns3::lorawan::LoraChannel::GetNDevices ( ) const
overridevirtual
Returns
the number of NetDevices connected to this Channel.

This method must be implemented by subclasses.

Implements ns3::Channel.

Definition at line 101 of file lora-channel.cc.

References m_phyList.

◆ GetRxPower()

double ns3::lorawan::LoraChannel::GetRxPower ( double  txPowerDbm,
Ptr< MobilityModel senderMobility,
Ptr< MobilityModel receiverMobility 
) const

Compute the received power when transmitting from a point to another one.

This method can be used by external object to see the receive power of a transmission from one point to another using this Channel's PropagationLossModel.

Parameters
txPowerDbmThe power the transmitter is using, in dBm.
senderMobilityThe mobility model of the sender.
receiverMobilityThe mobility model of the receiver.
Returns
The received power in dBm.

Definition at line 205 of file lora-channel.cc.

References ns3::PropagationLossModel::CalcRxPower(), and m_loss.

Referenced by Send().

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

◆ GetTypeId()

TypeId ns3::lorawan::LoraChannel::GetTypeId ( )
static

Register this type.

Returns
The object TypeId.

Definition at line 43 of file lora-channel.cc.

References m_delay, m_loss, m_packetSent, ns3::MakePointerAccessor(), ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ Receive()

void ns3::lorawan::LoraChannel::Receive ( uint32_t  i,
Ptr< Packet packet,
LoraChannelParameters  parameters 
) const
private

Private method that is scheduled by LoraChannel's Send method to happen after the channel delay, for each of the connected PHY layers.

It's here that the Receive method of the PHY is called to initiate packet reception at the PHY.

Parameters
iThe index of the phy to start reception on.
packetThe packet the phy will receive.
parametersThe parameters that characterize this transmission.

Definition at line 192 of file lora-channel.cc.

References ns3::lorawan::LoraChannelParameters::duration, ns3::lorawan::LoraChannelParameters::frequencyMHz, m_phyList, NS_LOG_FUNCTION, ns3::lorawan::LoraChannelParameters::rxPowerDbm, and ns3::lorawan::LoraChannelParameters::sf.

Referenced by Send().

+ Here is the caller graph for this function:

◆ Remove()

void ns3::lorawan::LoraChannel::Remove ( Ptr< LoraPhy phy)

Remove a physical layer from the LoraChannel.

This method removes a phy from the list of devices we have to notify. Removing unused PHY layers from the channel can improve performance, since it is not necessary to notify them about each transmission.

Parameters
phyThe physical layer to remove.

Definition at line 92 of file lora-channel.cc.

References m_phyList, and NS_LOG_FUNCTION.

◆ Send()

void ns3::lorawan::LoraChannel::Send ( Ptr< LoraPhy sender,
Ptr< Packet packet,
double  txPowerDbm,
LoraTxParameters  txParams,
Time  duration,
double  frequencyMHz 
) const

Send a packet in the channel.

This method is typically invoked by a PHY that needs to send a packet. Every connected Phy will be notified of this packet send through a call to their StartReceive methods after a delay based on the channel's PropagationDelayModel.

Parameters
senderThe phy that is sending this packet.
packetThe PHY layer packet that is being sent over the channel.
txPowerDbmThe power of the transmission.
txParamsThe set of parameters that are used by the transmitter.
durationThe on-air duration of this packet.
frequencyMHzThe frequency this transmission will happen at.
Internal:

When this method is called, the channel schedules an internal Receive call that performs the actual call to the PHY's StartReceive function.

Definition at line 113 of file lora-channel.cc.

References ns3::lorawan::LoraChannelParameters::duration, ns3::lorawan::LoraChannelParameters::frequencyMHz, GetRxPower(), m_delay, m_packetSent, m_phyList, NS_ASSERT, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_INFO, Receive(), ns3::lorawan::LoraChannelParameters::rxPowerDbm, ns3::Simulator::ScheduleWithContext(), ns3::lorawan::LoraChannelParameters::sf, and ns3::lorawan::LoraTxParameters::sf.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_delay

Ptr<PropagationDelayModel> ns3::lorawan::LoraChannel::m_delay
private

Pointer to the delay model.

Definition at line 200 of file lora-channel.h.

Referenced by GetTypeId(), and Send().

◆ m_loss

Ptr<PropagationLossModel> ns3::lorawan::LoraChannel::m_loss
private

Pointer to the loss model.

This loss model can be a concatenation of multiple loss models, obtained via PropagationLossModel's SetNext method.

Definition at line 195 of file lora-channel.h.

Referenced by GetRxPower(), and GetTypeId().

◆ m_packetSent

TracedCallback<Ptr<const Packet> > ns3::lorawan::LoraChannel::m_packetSent
private

Callback for when a packet is being sent on the channel.

Definition at line 205 of file lora-channel.h.

Referenced by GetTypeId(), and Send().

◆ m_phyList

std::vector<Ptr<LoraPhy> > ns3::lorawan::LoraChannel::m_phyList
private

The vector containing the PHYs that are currently connected to the channel.

Definition at line 187 of file lora-channel.h.

Referenced by ~LoraChannel(), Add(), GetDevice(), GetNDevices(), Receive(), Remove(), and Send().


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