30 uint8_t spreadingFactor,
34 m_endTime(m_startTime + duration),
35 m_sf(spreadingFactor),
36 m_rxPowerdBm(rxPowerdBm),
38 m_frequencyMHz(frequencyMHz)
65 return m_endTime - m_startTime;
89 return m_frequencyMHz;
95 stream <<
"(" << m_startTime.GetSeconds() <<
" s - " << m_endTime.GetSeconds() <<
" s), SF"
96 << unsigned(m_sf) <<
", " << m_rxPowerdBm <<
" dBm, " << m_frequencyMHz <<
" MHz";
112double inf = std::numeric_limits<double>::max();
129 {6, -16, -18, -19, -19, -20},
130 {-24, 6, -20, -22, -22, -22},
131 {-27, -27, 6, -23, -25, -25},
132 {-30, -30, -30, 6, -26, -28},
133 {-33, -33, -33, -33, 6, -29},
134 {-36, -36, -36, -36, -36, 6}
186 uint8_t spreadingFactor,
232std::list<Ptr<LoraInterferenceHelper::Event>>
243 stream <<
"Currently registered events:" << std::endl;
247 (*it)->Print(stream);
264 double rxPowerDbm =
event->GetRxPowerdBm();
265 uint8_t sf =
event->GetSpreadingFactor();
266 double frequency =
event->GetFrequency();
270 Time duration =
event->GetDuration();
271 Time packetStartTime = now - duration;
274 std::list<Ptr<LoraInterferenceHelper::Event>>::iterator it;
277 std::vector<double> cumulativeInterferenceEnergy(6, 0);
288 if (!(interferer->GetFrequency() == frequency) || interferer == event)
298 uint8_t interfererSf = interferer->GetSpreadingFactor();
299 double interfererPower = interferer->GetRxPowerdBm();
300 Time interfererStartTime = interferer->GetStartTime();
301 Time interfererEndTime = interferer->GetEndTime();
303 NS_LOG_INFO(
"Found an interferer: sf = " <<
unsigned(interfererSf)
304 <<
", power = " << interfererPower
305 <<
", start time = " << interfererStartTime
306 <<
", end time = " << interfererEndTime);
316 double interfererPowerW = pow(10, interfererPower / 10) / 1000;
318 double interferenceEnergy = overlap.
GetSeconds() * interfererPowerW;
319 cumulativeInterferenceEnergy.at(
unsigned(interfererSf) - 7) += interferenceEnergy;
320 NS_LOG_DEBUG(
"Interferer power in W: " << interfererPowerW);
321 NS_LOG_DEBUG(
"Interference energy: " << interferenceEnergy);
326 for (
auto currentSf = uint8_t(7); currentSf <= uint8_t(12); currentSf++)
329 << cumulativeInterferenceEnergy.at(
unsigned(currentSf) - 7));
333 double signalPowerW = pow(10, rxPowerDbm / 10) / 1000;
334 double signalEnergy = duration.
GetSeconds() * signalPowerW;
339 double snirIsolation =
m_collisionSnir[unsigned(sf) - 7][unsigned(currentSf) - 7];
340 NS_LOG_DEBUG(
"The needed isolation to survive is " << snirIsolation <<
" dB");
342 10 * log10(signalEnergy / cumulativeInterferenceEnergy.at(
unsigned(currentSf) - 7));
345 if (snir >= snirIsolation)
348 NS_LOG_DEBUG(
"Packet survived interference with SF " << currentSf);
352 NS_LOG_DEBUG(
"Packet destroyed by interference with SF" <<
unsigned(currentSf));
382 Time s1 = event1->GetStartTime();
383 Time s2 = event2->GetStartTime();
384 Time e1 = event1->GetEndTime();
385 Time e2 = event2->GetEndTime();
388 if (e1 <= s2 || e2 <= s1)
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
Control the scheduling of simulation events.
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.
A class representing a signal in time.
double GetRxPowerdBm() const
Get the power of the event.
Time GetStartTime() const
Get the starting time of the event.
double GetFrequency() const
Get the frequency this event was on.
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.
Event(Time duration, double rxPowerdBm, uint8_t spreadingFactor, Ptr< Packet > packet, double frequencyMHz)
Construct a new interference signal Event object.
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.
Helper for LoraPhy that manages interference calculations.
Ptr< LoraInterferenceHelper::Event > Add(Time duration, double rxPower, uint8_t spreadingFactor, Ptr< Packet > packet, double frequencyMHz)
Add an event to the InterferenceHelper.
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.
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.
std::ostream & operator<<(std::ostream &os, const EndDeviceStatus &status)
Every class exported by the ns3 library is enclosed in the ns3 namespace.