23#include "ns3/simulator.h"
43 : m_nextAggregatedTransmissionTime(
Seconds(0)),
44 m_aggregatedDutyCycle(1)
54std::vector<Ptr<LogicalLoraChannel>>
60 std::vector<Ptr<LogicalLoraChannel>> vector;
67std::vector<Ptr<LogicalLoraChannel>>
73 std::vector<Ptr<LogicalLoraChannel>> vector;
77 std::back_inserter(vector));
79 std::vector<Ptr<LogicalLoraChannel>> channels;
80 std::vector<Ptr<LogicalLoraChannel>>::iterator it;
81 for (it = vector.begin(); it != vector.end(); it++)
83 if ((*it)->IsEnabledForUplink())
85 channels.push_back(*it);
102 std::list<Ptr<SubBand>>::iterator it;
105 if ((*it)->BelongsToSubBand(frequency))
112 NS_ABORT_MSG(
"Warning: frequency is outside any known SubBand.");
151 double lastFrequency,
153 double maxTxPowerDbm)
157 Ptr<SubBand> subBand = Create<SubBand>(firstFrequency, lastFrequency, dutyCycle, maxTxPowerDbm);
174 std::vector<Ptr<LogicalLoraChannel>>::iterator it;
178 if (currentChannel == logicalChannel)
193 aggregatedWaitingTime =
Seconds(std::max(aggregatedWaitingTime.
GetSeconds(),
double(0)));
197 return aggregatedWaitingTime;
206 Time subBandWaitingTime =
210 subBandWaitingTime =
Seconds(std::max(subBandWaitingTime.
GetSeconds(),
double(0)));
214 return subBandWaitingTime;
224 double dutyCycle = subBand->GetDutyCycle();
237 NS_LOG_DEBUG(
"Next transmission on this sub-band allowed at time: "
238 << (subBand->GetNextTransmissionTime()).GetSeconds());
239 NS_LOG_DEBUG(
"Next aggregated transmission allowed at time "
249 std::list<Ptr<SubBand>>::iterator it;
253 if ((*it)->BelongsToSubBand(logicalChannel->GetFrequency()))
255 return (*it)->GetMaxTxPowerDbm();
258 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.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.