26 #include <ns3/simulator.h>
31 NS_LOG_COMPONENT_DEFINE(
"LoraLogicalChannelHelper");
33 NS_OBJECT_ENSURE_REGISTERED(LoraLogicalChannelHelper);
38 static TypeId tid = TypeId(
"ns3::LoraLogicalChannelHelper").SetParent<Object>();
43 : m_nextAggregatedTransmissionTime(Seconds(0)),
44 m_aggregatedDutyCycle(1)
46 NS_LOG_FUNCTION(
this);
51 NS_LOG_FUNCTION(
this);
54 std::vector<Ptr<LoraLogicalChannel>>
57 NS_LOG_FUNCTION(
this);
60 std::vector<Ptr<LoraLogicalChannel>> vector;
67 std::vector<Ptr<LoraLogicalChannel>>
70 NS_LOG_FUNCTION(
this);
73 std::vector<Ptr<LoraLogicalChannel>> vector;
77 std::back_inserter(vector));
79 std::vector<Ptr<LoraLogicalChannel>> channels;
80 std::vector<Ptr<LoraLogicalChannel>>::iterator it;
81 for (it = vector.begin(); it != vector.end(); it++)
83 if ((*it)->IsEnabledForUplink())
85 channels.push_back(*it);
101 NS_LOG_FUNCTION(
this << frequency);
103 std::list<Ptr<LoraSubBand>>::iterator it;
106 if ((*it)->BelongsToLoraSubBand(frequency))
112 NS_LOG_ERROR(
"Requested frequency: " << frequency);
113 NS_ABORT_MSG(
"Warning: frequency is outside any known LoraSubBand.");
121 NS_LOG_FUNCTION(
this << frequency);
124 Ptr<LoraLogicalChannel> channel = Create<LoraLogicalChannel>(frequency);
129 NS_LOG_DEBUG(
"Added a channel. Current number of channels in list is " <<
m_channelList.size());
135 NS_LOG_FUNCTION(
this << logicalChannel);
145 NS_LOG_FUNCTION(
this << chIndex << logicalChannel);
152 double lastFrequency,
154 double maxTxPowerDbm)
156 NS_LOG_FUNCTION(
this << firstFrequency << lastFrequency);
158 Ptr<LoraSubBand> subBand =
159 Create<LoraSubBand>(firstFrequency, lastFrequency, dutyCycle, maxTxPowerDbm);
167 NS_LOG_FUNCTION(
this << subBand);
176 std::vector<Ptr<LoraLogicalChannel>>::iterator it;
179 Ptr<LoraLogicalChannel> currentChannel = *it;
180 if (currentChannel == logicalChannel)
195 aggregatedWaitingTime = Seconds(std::max(aggregatedWaitingTime.GetSeconds(),
double(0)));
197 NS_LOG_DEBUG(
"Aggregated waiting time: " << aggregatedWaitingTime.GetSeconds());
199 return aggregatedWaitingTime;
205 NS_LOG_FUNCTION(
this << channel);
208 Time subBandWaitingTime =
212 subBandWaitingTime = Seconds(std::max(subBandWaitingTime.GetSeconds(),
double(0)));
214 NS_LOG_DEBUG(
"Waiting time: " << subBandWaitingTime.GetSeconds());
216 return subBandWaitingTime;
222 NS_LOG_FUNCTION(
this << duration << channel);
226 double dutyCycle = subBand->GetDutyCycle();
227 double timeOnAir = duration.GetSeconds();
230 subBand->SetNextTransmissionTime(Simulator::Now() + Seconds(timeOnAir / dutyCycle - timeOnAir));
236 NS_LOG_DEBUG(
"Time on air: " << timeOnAir);
238 NS_LOG_DEBUG(
"Current time: " << Simulator::Now().GetSeconds());
239 NS_LOG_DEBUG(
"Next transmission on this sub-band allowed at time: "
240 << (subBand->GetNextTransmissionTime()).GetSeconds());
241 NS_LOG_DEBUG(
"Next aggregated transmission allowed at time "
248 NS_LOG_FUNCTION_NOARGS();
251 std::list<Ptr<LoraSubBand>>::iterator it;
255 if ((*it)->BelongsToLoraSubBand(logicalChannel->GetFrequency()))
257 return (*it)->GetMaxTxPowerDbm();
260 NS_ABORT_MSG(
"Logical channel doesn't belong to a known LoraSubBand");
268 NS_LOG_FUNCTION(
this << index);
Time GetWaitingTime(Ptr< LoraLogicalChannel > channel)
Get the time it is necessary to wait for before transmitting on a given channel.
Ptr< LoraSubBand > GetLoraSubBandFromChannel(Ptr< LoraLogicalChannel > channel)
Get the LoraSubBand a channel belongs to.
void RemoveChannel(Ptr< LoraLogicalChannel > channel)
Remove a channel.
std::vector< Ptr< LoraLogicalChannel > > m_channelList
A vector of the LoraLogicalChannels that are currently registered within this helper.
void AddLoraSubBand(double firstFrequency, double lastFrequency, double dutyCycle, double maxTxPowerDbm)
Add a new LoraSubBand to this helper.
std::list< Ptr< LoraSubBand > > m_subBandList
A list of the LoraSubBands that are currently registered within this helper.
Ptr< LoraSubBand > GetLoraSubBandFromFrequency(double frequency)
Get the LoraSubBand a frequency belongs to.
void AddEvent(Time duration, Ptr< LoraLogicalChannel > channel)
Register the transmission of a packet.
Time m_nextAggregatedTransmissionTime
The next time at which.
void SetChannel(uint8_t chIndex, Ptr< LoraLogicalChannel > logicalChannel)
Set a new channel at a fixed index.
void DisableChannel(int index)
Disable the channel at a specified index.
virtual ~LoraLogicalChannelHelper()
void AddChannel(double frequency)
Add a new channel to the list.
LoraLogicalChannelHelper()
std::vector< Ptr< LoraLogicalChannel > > GetChannelList(void)
Get the list of LoraLogicalChannels currently registered on this helper.
Time GetAggregatedWaitingTime(void)
Get the time it is necessary to wait before transmitting again, according to the aggregate duty cycle...
static TypeId GetTypeId(void)
std::vector< Ptr< LoraLogicalChannel > > GetEnabledChannelList(void)
Get the list of LoraLogicalChannels currently registered on this helper that have been enabled for Up...
double GetTxPowerForChannel(Ptr< LoraLogicalChannel > logicalChannel)
Returns the maximum transmission power [dBm] that is allowed on a channel.
double m_aggregatedDutyCycle
transmission will be possible according to the aggregated transmission timer
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.