12#include "ns3/simulator.h"
32 : m_nextAggregatedTransmissionTime(
Seconds(0)),
33 m_aggregatedDutyCycle(1)
43std::vector<Ptr<LogicalLoraChannel>>
49 std::vector<Ptr<LogicalLoraChannel>> vector;
56std::vector<Ptr<LogicalLoraChannel>>
62 std::vector<Ptr<LogicalLoraChannel>> vector;
66 std::back_inserter(vector));
68 std::vector<Ptr<LogicalLoraChannel>> channels;
69 std::vector<Ptr<LogicalLoraChannel>>::iterator it;
70 for (it = vector.begin(); it != vector.end(); it++)
72 if ((*it)->IsEnabledForUplink())
74 channels.push_back(*it);
91 std::list<Ptr<SubBand>>::iterator it;
94 if ((*it)->BelongsToSubBand(frequency))
101 NS_ABORT_MSG(
"Warning: frequency is outside any known SubBand.");
140 double lastFrequency,
142 double maxTxPowerDbm)
163 std::vector<Ptr<LogicalLoraChannel>>::iterator it;
167 if (currentChannel == logicalChannel)
182 aggregatedWaitingTime =
Seconds(std::max(aggregatedWaitingTime.
GetSeconds(),
double(0)));
186 return aggregatedWaitingTime;
195 Time subBandWaitingTime =
199 subBandWaitingTime =
Seconds(std::max(subBandWaitingTime.
GetSeconds(),
double(0)));
203 return subBandWaitingTime;
213 double dutyCycle = subBand->GetDutyCycle();
226 NS_LOG_DEBUG(
"Next transmission on this sub-band allowed at time: "
227 << (subBand->GetNextTransmissionTime()).GetSeconds());
228 NS_LOG_DEBUG(
"Next aggregated transmission allowed at time "
238 std::list<Ptr<SubBand>>::iterator it;
242 if ((*it)->BelongsToSubBand(logicalChannel->GetFrequency()))
244 return (*it)->GetMaxTxPowerDbm();
247 NS_ABORT_MSG(
"Logical channel doesn't belong to a known SubBand");
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
LogicalLoraChannelHelper()
Default constructor.
void RemoveChannel(Ptr< LogicalLoraChannel > channel)
Remove a channel.
double GetTxPowerForChannel(Ptr< LogicalLoraChannel > logicalChannel)
Returns the maximum transmission power [dBm] that is allowed on a channel.
Time GetAggregatedWaitingTime()
Get the time it is necessary to wait before transmitting again, according to the aggregate duty cycle...
Ptr< SubBand > GetSubBandFromFrequency(double frequency)
Get the SubBand a frequency belongs to.
~LogicalLoraChannelHelper() override
Destructor.
void SetChannel(uint8_t chIndex, Ptr< LogicalLoraChannel > logicalChannel)
Set a new channel at a fixed index.
void DisableChannel(int index)
Disable the channel at a specified index.
double m_aggregatedDutyCycle
transmission will be possible according to the aggregated transmission timer
std::vector< Ptr< LogicalLoraChannel > > GetChannelList()
Get the list of LogicalLoraChannels currently registered on this helper.
static TypeId GetTypeId()
Register this type.
std::vector< Ptr< LogicalLoraChannel > > m_channelList
A vector of the LogicalLoraChannels that are currently registered within this helper.
Time m_nextAggregatedTransmissionTime
The next time at which.
std::vector< Ptr< LogicalLoraChannel > > GetEnabledChannelList()
Get the list of LogicalLoraChannels currently registered on this helper that have been enabled for Up...
void AddSubBand(double firstFrequency, double lastFrequency, double dutyCycle, double maxTxPowerDbm)
Add a new SubBand to this helper.
Time GetWaitingTime(Ptr< LogicalLoraChannel > channel)
Get the time it is necessary to wait for before transmitting on a given channel.
void AddEvent(Time duration, Ptr< LogicalLoraChannel > channel)
Register the transmission of a packet.
std::list< Ptr< SubBand > > m_subBandList
A list of the SubBands that are currently registered within this helper.
Ptr< SubBand > GetSubBandFromChannel(Ptr< LogicalLoraChannel > channel)
Get the SubBand a channel belongs to.
void AddChannel(double frequency)
Add a new channel to the list.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#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_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.