15#include "ns3/object-factory.h"
16#include "ns3/packet.h"
17#include "ns3/pointer.h"
18#include "ns3/simulator.h"
37 .SetGroupName(
"lorawan")
39 .AddAttribute(
"PropagationLossModel",
40 "A pointer to the propagation loss model attached to this channel.",
44 .AddAttribute(
"PropagationDelayModel",
45 "A pointer to the propagation delay model attached to this channel.",
49 .AddTraceSource(
"PacketSent",
50 "Trace source fired whenever a packet goes out on the channel",
52 "ns3::Packet::TracedCallback");
107 double frequencyMHz)
const
109 NS_LOG_FUNCTION(
this << sender << packet << txPowerDbm << txParams << duration << frequencyMHz);
117 NS_LOG_INFO(
"Sender mobility: " << senderMobility->GetPosition());
121 std::vector<Ptr<LoraPhy>>::const_iterator i;
130 NS_LOG_INFO(
"Receiver mobility: " << receiverMobility->GetPosition());
133 Time delay =
m_delay->GetDelay(senderMobility, receiverMobility);
136 double rxPowerDbm =
GetRxPower(txPowerDbm, senderMobility, receiverMobility);
139 << txPowerDbm <<
"dbm, rxPower=" << rxPowerDbm <<
"dbm, "
140 <<
"distance=" << senderMobility->GetDistanceFrom(receiverMobility)
141 <<
"m, delay=" << delay);
148 NS_LOG_INFO(
"Getting node index from NetDevice, since it exists");
149 dstNode = dstNetDevice->GetNode()->GetId();
154 NS_LOG_INFO(
"No net device connected to the PHY, using context 0");
160 parameters.
sf = txParams.
sf;
198 return m_loss->CalcRxPower(txPowerDbm, senderMobility, receiverMobility);
204 os <<
"(rxPowerDbm: " << params.rxPowerDbm <<
", SF: " << unsigned(params.sf)
205 <<
", durationSec: " << params.duration.GetSeconds()
206 <<
", frequencyMHz: " << params.frequencyMHz <<
")";
Abstract Channel Base Class.
Keep track of the current position and velocity of an object.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
The class that delivers packets among PHY layers.
std::size_t GetNDevices() const override
~LoraChannel() override
Destructor.
std::vector< Ptr< LoraPhy > > m_phyList
The vector containing the PHYs that are currently connected to the channel.
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.
double GetRxPower(double txPowerDbm, Ptr< MobilityModel > senderMobility, Ptr< MobilityModel > receiverMobility) const
Compute the received power when transmitting from a point to another one.
Ptr< PropagationDelayModel > m_delay
Pointer to the delay model.
LoraChannel()
Default constructor.
TracedCallback< Ptr< const Packet > > m_packetSent
Callback for when a packet is being sent on the channel.
Ptr< NetDevice > GetDevice(std::size_t i) const override
void Add(Ptr< LoraPhy > phy)
Connect a LoraPhy object to the LoraChannel.
Ptr< PropagationLossModel > m_loss
Pointer to the loss model.
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,...
static TypeId GetTypeId()
Register this type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
std::ostream & operator<<(std::ostream &os, const EndDeviceStatus &status)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
A struct that holds meaningful parameters for transmission on a LoraChannel.
uint8_t sf
The Spreading Factor of this transmission.
double rxPowerDbm
The reception power.
double frequencyMHz
The frequency [MHz] of this transmission.
Time duration
The duration of the transmission.
Structure to collect all parameters that are used to compute the duration of a packet (excluding payl...
uint8_t sf
Spreading Factor.