DESERT 3.5.1
Loading...
Searching...
No Matches
uwinterference.h
Go to the documentation of this file.
1//
2// Copyright (c) 2017 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29
39#ifndef UW_INTERFERENCE
40#define UW_INTERFERENCE
41
42#include <interference_miv.h>
43#include <list>
44#include <iostream>
45#include <scheduler.h>
46#include <vector>
47#include <assert.h>
48#include <cmath>
49
50enum PKT_TYPE { CTRL, DATA };
51// enum RX_STATE { START_RX, END_RX};
52
53typedef std::pair<int, int> counter;
56{
57public:
58 double time;
59 double sum_power;
67 {
68 time = 0;
69 sum_power = 0;
70 // n_pkts = 0;
71 ctrl_cnt = 0;
72 data_cnt = 0;
73 }
74
82 ListNode(double t, double sum_pw, /*double n,*/ int ctrl, int data)
83 {
84 time = t;
85 sum_power = sum_pw;
86 ctrl_cnt = ctrl;
87 data_cnt = data;
88 }
89
93 virtual ~ListNode()
94 {
95 }
96};
97
98class EndInterfEvent : public Event
99{
100public:
107 {
108 power = pw;
109 type = tp;
110 }
117 EndInterfEvent(double pw, PKT_TYPE tp, const std::vector<double>& carPwr): carrier_power(carPwr)
118 {
119 power = pw;
120 type = tp;
121 }
122
127 {
128 }
129 double power;
131 std::vector<double> carrier_power;
132};
133
134class uwinterference;
135
136class EndInterfTimer : public Handler
137{
138public:
140 {
141 interference = ptr;
142 }
143 virtual void handle(Event *e);
144
145protected:
147};
148
149class uwinterference : public MInterferenceMIV
150{
151public:
159 virtual ~uwinterference();
164 virtual void addToInterference(Packet *p);
170 virtual void addToInterference(double pw, PKT_TYPE tp);
176 virtual void removeFromInterference(double pw, PKT_TYPE tp);
182 virtual double getInterferencePower(Packet *p);
190 virtual double getInterferencePower(
191 double power, double starttime, double duration);
192 virtual double getCurrentTotalPower();
199 virtual double getTimeOverlap(Packet *p);
207 virtual double getTimeOverlap(double starttime, double duration);
213 virtual counter getCounters(Packet *p);
221 virtual counter getCounters(double starttime, double duration, PKT_TYPE tp);
226 inline double
228 {
229 return start_rx_time;
230 }
235 inline double
237 {
238 return end_rx_time;
239 }
246 inline double
251
252protected:
253 std::list<ListNode> power_list;
261 double end_rx_time;
262};
263
264#endif /*UW_INTERFERENCE*/
virtual ~EndInterfEvent()
Destructor of the class EndInterfEvent.
std::vector< double > carrier_power
EndInterfEvent(double pw, PKT_TYPE tp, const std::vector< double > &carPwr)
Constructor of the class EndInterfEvent for OFDM.
EndInterfEvent(double pw, PKT_TYPE tp)
Constructor of the class EndInterfEvent.
virtual void handle(Event *e)
EndInterfTimer(uwinterference *ptr)
uwinterference * interference
ListNode(double t, double sum_pw, int ctrl, int data)
Constructor of the class ListNode.
virtual ~ListNode()
Destructor of the class ListNode.
int ctrl_cnt
sum of the rx power in the node at the given time
double time
int data_cnt
control packet counter
ListNode()
data packet counter
double sum_power
double end_rx_time
timetamp of the end of reception phase
virtual counter getCounters(Packet *p)
Returns the counters of collisions.
virtual void addToInterference(Packet *p)
Add a packet to the interference calculation.
EndInterfTimer end_timer
Timer for schedules end of interference for a transmission.
double getStartRxTime()
Get the timestamp of the start of reception phase.
double getEndRxTime()
Get the timestamp of the end of reception phase.
double initial_interference_time
timestamp of the begin of reception of the first interferer packet
double start_rx_time
timestamp of the start of reception phase
virtual double getTimeOverlap(Packet *p)
Returns the percentage of overlap between current packet and interference packets.
virtual double getCurrentTotalPower()
double use_maxinterval_
set to 1 to use maxinterval_.
virtual double getInterferencePower(Packet *p)
Compute the average interference power for the given packet.
virtual void removeFromInterference(double pw, PKT_TYPE tp)
Remove a packet to the interference calculation.
std::list< ListNode > power_list
List with power and counters.
virtual ~uwinterference()
Destructor of the class uwinterference.
double getInitialInterferenceTime()
Get the timestamp of the begin of reception of the first interferer packet.
uwinterference()
Constructor of the class uwinterference.
std::pair< int, int > counter
counter of collisions
PKT_TYPE
@ CTRL
@ DATA