32 uint8_t spreadingFactor,
37 m_sf(spreadingFactor),
114double inf = std::numeric_limits<double>::max();
131 {6, -16, -18, -19, -19, -20},
132 {-24, 6, -20, -22, -22, -22},
133 {-27, -27, 6, -23, -25, -25},
134 {-30, -30, -30, 6, -26, -28},
135 {-33, -33, -33, -33, 6, -29},
136 {-36, -36, -36, -36, -36, 6}
188 uint8_t spreadingFactor,
234std::list<Ptr<LoraInterferenceHelper::Event>>
245 stream <<
"Currently registered events:" << std::endl;
249 (*it)->Print(stream);
266 double rxPowerDbm =
event->GetRxPowerdBm();
267 uint8_t sf =
event->GetSpreadingFactor();
268 uint32_t frequencyHz =
event->GetFrequency();
272 Time duration =
event->GetDuration();
273 Time packetStartTime = now - duration;
276 std::list<Ptr<LoraInterferenceHelper::Event>>::iterator it;
279 std::vector<double> cumulativeInterferenceEnergy(6, 0);
290 if (!(interferer->GetFrequency() == frequencyHz) || interferer == event)
300 uint8_t interfererSf = interferer->GetSpreadingFactor();
301 double interfererPower = interferer->GetRxPowerdBm();
302 Time interfererStartTime = interferer->GetStartTime();
303 Time interfererEndTime = interferer->GetEndTime();
305 NS_LOG_INFO(
"Found an interferer: sf = " <<
unsigned(interfererSf)
306 <<
", power = " << interfererPower
307 <<
", start time = " << interfererStartTime
308 <<
", end time = " << interfererEndTime);
315 double interfererPowerW =
DbmToW(interfererPower);
317 double interferenceEnergy = overlap.
GetSeconds() * interfererPowerW;
318 cumulativeInterferenceEnergy.at(
unsigned(interfererSf) - 7) += interferenceEnergy;
319 NS_LOG_DEBUG(
"Interferer power in W: " << interfererPowerW);
320 NS_LOG_DEBUG(
"Interference energy: " << interferenceEnergy);
325 for (
auto currentSf = uint8_t(7); currentSf <= uint8_t(12); currentSf++)
328 << cumulativeInterferenceEnergy.at(
unsigned(currentSf) - 7));
332 double signalPowerW =
DbmToW(rxPowerDbm);
333 double signalEnergy = duration.
GetSeconds() * signalPowerW;
338 double snirIsolation =
m_collisionSnir[unsigned(sf) - 7][unsigned(currentSf) - 7];
339 NS_LOG_DEBUG(
"The needed isolation to survive is " << snirIsolation <<
" dB");
341 10 * log10(signalEnergy / cumulativeInterferenceEnergy.at(
unsigned(currentSf) - 7));
344 if (snir >= snirIsolation)
347 NS_LOG_DEBUG(
"Packet survived interference with SF " << currentSf);
351 NS_LOG_DEBUG(
"Packet destroyed by interference with SF" <<
unsigned(currentSf));
381 Time s1 = event1->GetStartTime();
382 Time s2 = event2->GetStartTime();
383 Time e1 = event1->GetEndTime();
384 Time e2 = event2->GetEndTime();
387 if (e1 <= s2 || e2 <= s1)
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
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.
A class representing a signal in time.
double GetRxPowerdBm() const
Get the power of the event.
Time m_startTime
The time this signal begins (at the device).
Event(Time duration, double rxPowerdBm, uint8_t spreadingFactor, Ptr< Packet > packet, uint32_t frequencyHz)
Construct a new interference signal Event object.
Time GetStartTime() const
Get the starting time of the event.
Time GetEndTime() const
Get the ending time of the event.
uint8_t GetSpreadingFactor() const
Get the spreading factor used by this signal.
Time GetDuration() const
Get the duration of the event.
Time m_endTime
The time this signal ends (at the device).
uint8_t m_sf
The spreading factor of this signal.
uint32_t m_frequencyHz
The carrier frequency [Hz] this event was on.
Ptr< Packet > GetPacket() const
Get the packet this event was generated for.
void Print(std::ostream &stream) const
Print the current event in a human readable form.
Ptr< Packet > m_packet
The packet this event was generated for.
uint32_t GetFrequency() const
Get the frequency this event was on.
double m_rxPowerdBm
The power of this event in dBm (at the device).
static std::vector< std::vector< double > > collisionSnirGoursaud
GOURSAUD collision matrix.
static Time oldEventThreshold
The threshold after which an event is considered old and removed from the list.
Time GetOverlapTime(Ptr< LoraInterferenceHelper::Event > event1, Ptr< LoraInterferenceHelper::Event > event2)
Compute the time duration in which two given events are overlapping.
Ptr< LoraInterferenceHelper::Event > Add(Time duration, double rxPower, uint8_t spreadingFactor, Ptr< Packet > packet, uint32_t frequencyHz)
Add an event to the InterferenceHelper.
CollisionMatrix
Enumeration of types of collision matrices.
void CleanOldEvents()
Delete old events in this LoraInterferenceHelper.
void ClearAllEvents()
Delete all events in the LoraInterferenceHelper.
virtual ~LoraInterferenceHelper()
Destructor.
static CollisionMatrix collisionMatrix
Collision matrix type set by the constructor.
static std::vector< std::vector< double > > collisionSnirAloha
ALOHA collision matrix.
static TypeId GetTypeId()
Register this type.
std::vector< std::vector< double > > m_collisionSnir
The matrix containing information about how packets survive interference.
void SetCollisionMatrix(enum CollisionMatrix collisionMatrix)
Set the collision matrix.
uint8_t IsDestroyedByInterference(Ptr< LoraInterferenceHelper::Event > event)
Determine whether the event was destroyed by interference or not.
void PrintEvents(std::ostream &stream)
Print the events that are saved in this helper in a human readable format.
LoraInterferenceHelper()
Default constructor.
std::list< Ptr< LoraInterferenceHelper::Event > > GetInterferers()
Get a list of the interferers currently registered at this InterferenceHelper.
std::list< Ptr< LoraInterferenceHelper::Event > > m_events
List of the events this LoraInterferenceHelper is keeping track of.
#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_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< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time Seconds(double value)
Construct a Time in the indicated unit.
double DbmToW(double dBm)
Convert from dBm to Watts.
std::ostream & operator<<(std::ostream &os, const EndDeviceStatus &status)
Every class exported by the ns3 library is enclosed in the ns3 namespace.