|
mathieu@4325
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
|
mathieu@4325
|
2 |
/*
|
|
mathieu@4325
|
3 |
* Copyright (c) 2005,2006 INRIA
|
|
mathieu@4325
|
4 |
*
|
|
mathieu@4325
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
mathieu@4325
|
6 |
* it under the terms of the GNU General Public License version 2 as
|
|
mathieu@4325
|
7 |
* published by the Free Software Foundation;
|
|
mathieu@4325
|
8 |
*
|
|
mathieu@4325
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
mathieu@4325
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
mathieu@4325
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
mathieu@4325
|
12 |
* GNU General Public License for more details.
|
|
mathieu@4325
|
13 |
*
|
|
mathieu@4325
|
14 |
* You should have received a copy of the GNU General Public License
|
|
mathieu@4325
|
15 |
* along with this program; if not, write to the Free Software
|
|
mathieu@4325
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
mathieu@4325
|
17 |
*
|
|
mathieu@4325
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
|
mathieu@4325
|
19 |
*/
|
|
mathieu@3905
|
20 |
#ifndef INTERFERENCE_HELPER_H
|
|
mathieu@3905
|
21 |
#define INTERFERENCE_HELPER_H
|
|
mathieu@3905
|
22 |
|
|
mathieu@3905
|
23 |
#include <stdint.h>
|
|
mathieu@3905
|
24 |
#include <vector>
|
|
mathieu@3905
|
25 |
#include <list>
|
|
mathieu@3905
|
26 |
#include "wifi-mode.h"
|
|
mathieu@3905
|
27 |
#include "wifi-preamble.h"
|
|
guangyu@4470
|
28 |
#include "wifi-phy-standard.h"
|
|
mathieu@3905
|
29 |
#include "ns3/nstime.h"
|
|
mathieu@5505
|
30 |
#include "ns3/simple-ref-count.h"
|
|
mathieu@3905
|
31 |
|
|
mathieu@3905
|
32 |
namespace ns3 {
|
|
mathieu@3905
|
33 |
|
|
mathieu@3905
|
34 |
class ErrorRateModel;
|
|
mathieu@3905
|
35 |
|
|
mathieu@3905
|
36 |
class InterferenceHelper
|
|
mathieu@3905
|
37 |
{
|
|
mathieu@3905
|
38 |
public:
|
|
mathieu@5505
|
39 |
class Event : public SimpleRefCount<InterferenceHelper::Event>
|
|
mathieu@3905
|
40 |
{
|
|
mathieu@3905
|
41 |
public:
|
|
mathieu@3905
|
42 |
Event (uint32_t size, WifiMode payloadMode,
|
|
mathieu@3905
|
43 |
enum WifiPreamble preamble,
|
|
mathieu@3905
|
44 |
Time duration, double rxPower);
|
|
mathieu@5505
|
45 |
~Event ();
|
|
mathieu@3905
|
46 |
|
|
mathieu@3905
|
47 |
Time GetDuration (void) const;
|
|
mathieu@3905
|
48 |
Time GetStartTime (void) const;
|
|
mathieu@3905
|
49 |
Time GetEndTime (void) const;
|
|
mathieu@3905
|
50 |
bool Overlaps (Time time) const;
|
|
mathieu@3905
|
51 |
double GetRxPowerW (void) const;
|
|
mathieu@3905
|
52 |
uint32_t GetSize (void) const;
|
|
mathieu@3905
|
53 |
WifiMode GetPayloadMode (void) const;
|
|
mathieu@3905
|
54 |
enum WifiPreamble GetPreambleType (void) const;
|
|
mathieu@3905
|
55 |
private:
|
|
mathieu@3905
|
56 |
uint32_t m_size;
|
|
mathieu@3905
|
57 |
WifiMode m_payloadMode;
|
|
mathieu@3905
|
58 |
enum WifiPreamble m_preamble;
|
|
mathieu@3905
|
59 |
Time m_startTime;
|
|
mathieu@3905
|
60 |
Time m_endTime;
|
|
mathieu@3905
|
61 |
double m_rxPowerW;
|
|
mathieu@3905
|
62 |
};
|
|
mathieu@3905
|
63 |
struct SnrPer
|
|
mathieu@3905
|
64 |
{
|
|
mathieu@3905
|
65 |
double snr;
|
|
mathieu@3905
|
66 |
double per;
|
|
mathieu@3905
|
67 |
};
|
|
mathieu@3905
|
68 |
|
|
mathieu@3905
|
69 |
InterferenceHelper ();
|
|
mathieu@3906
|
70 |
~InterferenceHelper ();
|
|
mathieu@3905
|
71 |
|
|
nbaldo@4315
|
72 |
void SetNoiseFigure (double value);
|
|
mathieu@3905
|
73 |
void SetErrorRateModel (Ptr<ErrorRateModel> rate);
|
|
mathieu@3905
|
74 |
|
|
nbaldo@4315
|
75 |
double GetNoiseFigure (void) const;
|
|
mathieu@3905
|
76 |
Ptr<ErrorRateModel> GetErrorRateModel (void) const;
|
|
mathieu@3905
|
77 |
|
|
mathieu@3905
|
78 |
|
|
mathieu@3905
|
79 |
/**
|
|
mathieu@3905
|
80 |
* \param energyW the minimum energy (W) requested
|
|
mathieu@3905
|
81 |
* \returns the expected amount of time the observed
|
|
mathieu@3905
|
82 |
* energy on the medium will be higher than
|
|
mathieu@3905
|
83 |
* the requested threshold.
|
|
mathieu@3905
|
84 |
*/
|
|
mathieu@3905
|
85 |
Time GetEnergyDuration (double energyW);
|
|
nbaldo@4681
|
86 |
|
|
nbaldo@4681
|
87 |
|
|
nbaldo@4681
|
88 |
static WifiMode GetPlcpHeaderMode (WifiMode payloadMode, WifiPreamble preamble);
|
|
nbaldo@4681
|
89 |
static uint32_t GetPlcpHeaderDurationMicroSeconds (WifiMode payloadMode, WifiPreamble preamble);
|
|
nbaldo@4681
|
90 |
static uint32_t GetPlcpPreambleDurationMicroSeconds (WifiMode mode, WifiPreamble preamble);
|
|
nbaldo@4681
|
91 |
static uint32_t GetPayloadDurationMicroSeconds (uint32_t size, WifiMode payloadMode);
|
|
nbaldo@4681
|
92 |
static Time CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiPreamble preamble);
|
|
mathieu@3905
|
93 |
Ptr<InterferenceHelper::Event> Add (uint32_t size, WifiMode payloadMode,
|
|
mathieu@3905
|
94 |
enum WifiPreamble preamble,
|
|
mathieu@3905
|
95 |
Time duration, double rxPower);
|
|
mathieu@3905
|
96 |
|
|
mathieu@3905
|
97 |
struct InterferenceHelper::SnrPer CalculateSnrPer (Ptr<InterferenceHelper::Event> event);
|
|
Ramon@5189
|
98 |
void EraseEvents (void);
|
|
mathieu@3905
|
99 |
private:
|
|
mathieu@3905
|
100 |
class NiChange {
|
|
mathieu@3905
|
101 |
public:
|
|
mathieu@3905
|
102 |
NiChange (Time time, double delta);
|
|
mathieu@3905
|
103 |
Time GetTime (void) const;
|
|
mathieu@3905
|
104 |
double GetDelta (void) const;
|
|
mathieu@3905
|
105 |
bool operator < (NiChange const &o) const;
|
|
mathieu@3905
|
106 |
private:
|
|
mathieu@3905
|
107 |
Time m_time;
|
|
mathieu@3905
|
108 |
double m_delta;
|
|
mathieu@3905
|
109 |
};
|
|
mathieu@3905
|
110 |
typedef std::vector <NiChange> NiChanges;
|
|
mathieu@3905
|
111 |
typedef std::list<Ptr<Event> > Events;
|
|
mathieu@3905
|
112 |
|
|
craigdo@5413
|
113 |
void EraseEvents (Events::iterator start, Events::iterator end);
|
|
craigdo@5413
|
114 |
|
|
mathieu@3906
|
115 |
InterferenceHelper (const InterferenceHelper &o);
|
|
mathieu@3906
|
116 |
InterferenceHelper &operator = (const InterferenceHelper &o);
|
|
mathieu@3905
|
117 |
void AppendEvent (Ptr<Event> event);
|
|
mathieu@3905
|
118 |
double CalculateNoiseInterferenceW (Ptr<Event> event, NiChanges *ni) const;
|
|
mathieu@3905
|
119 |
double CalculateSnr (double signal, double noiseInterference, WifiMode mode) const;
|
|
mathieu@3905
|
120 |
double CalculateChunkSuccessRate (double snir, Time delay, WifiMode mode) const;
|
|
mathieu@3905
|
121 |
double CalculatePer (Ptr<const Event> event, NiChanges *ni) const;
|
|
mathieu@3905
|
122 |
Time GetMaxPacketDuration (void) const;
|
|
mathieu@3905
|
123 |
|
|
mathieu@3905
|
124 |
Time m_maxPacketDuration;
|
|
nbaldo@4315
|
125 |
double m_noiseFigure; /**< noise figure (linear) */
|
|
mathieu@3905
|
126 |
Events m_events;
|
|
mathieu@3905
|
127 |
Ptr<ErrorRateModel> m_errorRateModel;
|
|
mathieu@3905
|
128 |
};
|
|
mathieu@3905
|
129 |
|
|
mathieu@3905
|
130 |
} // namespace ns3
|
|
mathieu@3905
|
131 |
|
|
mathieu@3905
|
132 |
#endif /* INTERFERENCE_HELPER_H */
|