26 #include <ns3/simulator.h>
36 NS_LOG_COMPONENT_DEFINE(
"LoraLogicalChannelHelper");
38 NS_OBJECT_ENSURE_REGISTERED(LoraLogicalChannelHelper);
43 static TypeId tid = TypeId(
"ns3::LoraLogicalChannelHelper").SetParent<Object>();
48 : m_nextAggregatedTransmissionTime(Seconds(0)),
49 m_aggregatedDutyCycle(1)
51 NS_LOG_FUNCTION(
this);
56 NS_LOG_FUNCTION(
this);
59 std::vector<Ptr<LoraLogicalChannel>>
62 NS_LOG_FUNCTION(
this);
65 std::vector<Ptr<LoraLogicalChannel>> vector;
72 std::vector<Ptr<LoraLogicalChannel>>
75 NS_LOG_FUNCTION(
this);
78 std::vector<Ptr<LoraLogicalChannel>> vector;
82 std::back_inserter(vector));
84 std::vector<Ptr<LoraLogicalChannel>> channels;
85 std::vector<Ptr<LoraLogicalChannel>>::iterator it;
86 for (it = vector.begin(); it != vector.end(); it++)
88 if ((*it)->IsEnabledForUplink())
90 channels.push_back(*it);
106 NS_LOG_FUNCTION(
this << frequency);
108 std::list<Ptr<LoraSubBand>>::iterator it;
111 if ((*it)->BelongsToLoraSubBand(frequency))
117 NS_LOG_ERROR(
"Requested frequency: " << frequency);
118 NS_ABORT_MSG(
"Warning: frequency is outside any known LoraSubBand.");
126 NS_LOG_FUNCTION(
this << frequency);
129 Ptr<LoraLogicalChannel> channel = Create<LoraLogicalChannel>(frequency);
134 NS_LOG_DEBUG(
"Added a channel. Current number of channels in list is " <<
m_channelList.size());
140 NS_LOG_FUNCTION(
this << logicalChannel);
150 NS_LOG_FUNCTION(
this << chIndex << logicalChannel);
157 double lastFrequency,
159 double maxTxPowerDbm)
161 NS_LOG_FUNCTION(
this << firstFrequency << lastFrequency);
163 Ptr<LoraSubBand> subBand =
164 Create<LoraSubBand>(firstFrequency, lastFrequency, dutyCycle, maxTxPowerDbm);
172 NS_LOG_FUNCTION(
this << subBand);
181 std::vector<Ptr<LoraLogicalChannel>>::iterator it;
184 Ptr<LoraLogicalChannel> currentChannel = *it;
185 if (currentChannel == logicalChannel)
200 aggregatedWaitingTime = Seconds(std::max(aggregatedWaitingTime.GetSeconds(),
double(0)));
202 NS_LOG_DEBUG(
"Aggregated waiting time: " << aggregatedWaitingTime.GetSeconds());
204 return aggregatedWaitingTime;
210 NS_LOG_FUNCTION(
this << channel);
213 Time subBandWaitingTime =
217 subBandWaitingTime = Seconds(std::max(subBandWaitingTime.GetSeconds(),
double(0)));
219 NS_LOG_DEBUG(
"Waiting time: " << subBandWaitingTime.GetSeconds());
221 return subBandWaitingTime;
227 NS_LOG_FUNCTION(
this << duration << channel);
231 double dutyCycle = subBand->GetDutyCycle();
232 double timeOnAir = duration.GetSeconds();
235 subBand->SetNextTransmissionTime(Simulator::Now() + Seconds(timeOnAir / dutyCycle - timeOnAir));
241 NS_LOG_DEBUG(
"Time on air: " << timeOnAir);
243 NS_LOG_DEBUG(
"Current time: " << Simulator::Now().GetSeconds());
244 NS_LOG_DEBUG(
"Next transmission on this sub-band allowed at time: "
245 << (subBand->GetNextTransmissionTime()).GetSeconds());
246 NS_LOG_DEBUG(
"Next aggregated transmission allowed at time "
253 NS_LOG_FUNCTION_NOARGS();
256 std::list<Ptr<LoraSubBand>>::iterator it;
260 if ((*it)->BelongsToLoraSubBand(logicalChannel->GetFrequency()))
262 return (*it)->GetMaxTxPowerDbm();
265 NS_ABORT_MSG(
"Logical channel doesn't belong to a known LoraSubBand");
273 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.