26#include "ns3/object-factory.h"
27#include "ns3/packet.h"
28#include "ns3/pointer.h"
29#include "ns3/simulator.h"
48 .SetGroupName(
"lorawan")
50 .AddAttribute(
"PropagationLossModel",
51 "A pointer to the propagation loss model attached to this channel.",
54 MakePointerChecker<PropagationLossModel>())
55 .AddAttribute(
"PropagationDelayModel",
56 "A pointer to the propagation delay model attached to this channel.",
59 MakePointerChecker<PropagationDelayModel>())
60 .AddTraceSource(
"PacketSent",
61 "Trace source fired whenever a packet goes out on the channel",
63 "ns3::Packet::TracedCallback");
118 double frequencyMHz)
const
120 NS_LOG_FUNCTION(
this << sender << packet << txPowerDbm << txParams << duration << frequencyMHz);
128 NS_LOG_INFO(
"Sender mobility: " << senderMobility->GetPosition());
132 std::vector<Ptr<LoraPhy>>::const_iterator i;
141 NS_LOG_INFO(
"Receiver mobility: " << receiverMobility->GetPosition());
144 Time delay =
m_delay->GetDelay(senderMobility, receiverMobility);
147 double rxPowerDbm =
GetRxPower(txPowerDbm, senderMobility, receiverMobility);
150 << txPowerDbm <<
"dbm, rxPower=" << rxPowerDbm <<
"dbm, "
151 <<
"distance=" << senderMobility->GetDistanceFrom(receiverMobility)
152 <<
"m, delay=" << delay);
159 NS_LOG_INFO(
"Getting node index from NetDevice, since it exists");
160 dstNode = dstNetDevice->GetNode()->GetId();
165 NS_LOG_INFO(
"No net device connected to the PHY, using context 0");
171 parameters.
sf = txParams.
sf;
215 os <<
"(rxPowerDbm: " << params.rxPowerDbm <<
", SF: " << unsigned(params.sf)
216 <<
", durationSec: " << params.duration.GetSeconds()
217 <<
", frequencyMHz: " << params.frequencyMHz <<
")";
Abstract Channel Base Class.
Keep track of the current position and velocity of an object.
Network layer to device interface.
AttributeValue implementation for Pointer.
double CalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
Returns the Rx Power taking into account all the PropagationLossModel(s) chained to the current one.
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)
#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.
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.