LEFT | RIGHT |
(no file at all) | |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005,2006 INRIA | 3 * Copyright (c) 2005,2006 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 WifiMode m_payloadMode; | 60 WifiMode m_payloadMode; |
61 enum WifiPreamble m_preamble; | 61 enum WifiPreamble m_preamble; |
62 Time m_startTime; | 62 Time m_startTime; |
63 Time m_endTime; | 63 Time m_endTime; |
64 double m_rxPowerW; | 64 double m_rxPowerW; |
65 }; | 65 }; |
66 struct SnrPer | 66 struct SnrPer |
67 { | 67 { |
68 double snr; | 68 double snr; |
69 double per; | 69 double per; |
| 70 /* |
| 71 * Average RSS of the entire packet, used for jamming detection. In the |
| 72 * case of detecting a reactive jammer. The average RSS value is compared |
| 73 * to the initial RSS value. |
| 74 */ |
| 75 double packetRss; |
70 }; | 76 }; |
71 | 77 |
72 InterferenceHelper (); | 78 InterferenceHelper (); |
73 ~InterferenceHelper (); | 79 ~InterferenceHelper (); |
74 | 80 |
75 void SetNoiseFigure (double value); | 81 void SetNoiseFigure (double value); |
76 void SetErrorRateModel (Ptr<ErrorRateModel> rate); | 82 void SetErrorRateModel (Ptr<ErrorRateModel> rate); |
77 | 83 |
78 double GetNoiseFigure (void) const; | 84 double GetNoiseFigure (void) const; |
79 Ptr<ErrorRateModel> GetErrorRateModel (void) const; | 85 Ptr<ErrorRateModel> GetErrorRateModel (void) const; |
80 | 86 |
81 | 87 |
82 /** | 88 /** |
83 * \param energyW the minimum energy (W) requested | 89 * \param energyW the minimum energy (W) requested |
84 * \returns the expected amount of time the observed | 90 * \returns the expected amount of time the observed |
85 * energy on the medium will be higher than | 91 * energy on the medium will be higher than |
86 * the requested threshold. | 92 * the requested threshold. |
87 */ | 93 */ |
88 Time GetEnergyDuration (double energyW); | 94 Time GetEnergyDuration (double energyW); |
89 | 95 |
90 | 96 |
91 Ptr<InterferenceHelper::Event> Add (uint32_t size, WifiMode payloadMode, | 97 Ptr<InterferenceHelper::Event> Add (uint32_t size, WifiMode payloadMode, |
92 enum WifiPreamble preamble, | 98 enum WifiPreamble preamble, |
93 Time duration, double rxPower); | 99 Time duration, double rxPower); |
94 | 100 |
95 struct InterferenceHelper::SnrPer CalculateSnrPer (Ptr<InterferenceHelper::Eve
nt> event); | 101 struct InterferenceHelper::SnrPer CalculateSnrPer (Ptr<InterferenceHelper::Eve
nt> event); |
96 void NotifyRxStart (); | 102 void NotifyRxStart (); |
97 void NotifyRxEnd (); | 103 void NotifyRxEnd (); |
98 void EraseEvents (void); | 104 void EraseEvents (void); |
| 105 |
| 106 /** |
| 107 * \brief Get current node Received Signal Strength. |
| 108 * \param mode WifiMode. |
| 109 * \returns current RSS value (W). |
| 110 * |
| 111 * This function calculates the current RSS value at the node. Current RSS at |
| 112 * node is given by accumulating all signal present at node and noise floor. |
| 113 */ |
| 114 double CurrentNodeRss (WifiMode mode); |
| 115 |
99 private: | 116 private: |
100 class NiChange | 117 class NiChange |
101 { | 118 { |
102 public: | 119 public: |
103 NiChange (Time time, double delta); | 120 NiChange (Time time, double delta); |
104 Time GetTime (void) const; | 121 Time GetTime (void) const; |
105 double GetDelta (void) const; | 122 double GetDelta (void) const; |
106 bool operator < (const NiChange& o) const; | 123 bool operator < (const NiChange& o) const; |
107 private: | 124 private: |
108 Time m_time; | 125 Time m_time; |
109 double m_delta; | 126 double m_delta; |
110 }; | 127 }; |
111 typedef std::vector <NiChange> NiChanges; | 128 typedef std::vector <NiChange> NiChanges; |
112 typedef std::list<Ptr<Event> > Events; | 129 typedef std::list<Ptr<Event> > Events; |
113 | 130 |
114 InterferenceHelper (const InterferenceHelper &o); | 131 InterferenceHelper (const InterferenceHelper &o); |
115 InterferenceHelper &operator = (const InterferenceHelper &o); | 132 InterferenceHelper &operator = (const InterferenceHelper &o); |
116 void AppendEvent (Ptr<Event> event); | 133 void AppendEvent (Ptr<Event> event); |
117 double CalculateNoiseInterferenceW (Ptr<Event> event, NiChanges *ni) const; | 134 double CalculateNoiseInterferenceW (Ptr<Event> event, NiChanges *ni) const; |
118 double CalculateSnr (double signal, double noiseInterference, WifiMode mode) c
onst; | 135 double CalculateSnr (double signal, double noiseInterference, WifiMode mode) c
onst; |
119 double CalculateChunkSuccessRate (double snir, Time delay, WifiMode mode) cons
t; | 136 double CalculateChunkSuccessRate (double snir, Time delay, WifiMode mode) cons
t; |
120 double CalculatePer (Ptr<const Event> event, NiChanges *ni) const; | 137 double CalculatePer (Ptr<const Event> event, NiChanges *ni) const; |
| 138 /** |
| 139 * \brief Calculate noise floor. |
| 140 * \param mode Wifi mode. |
| 141 * \returns Noise floor (W). |
| 142 */ |
| 143 double CalculateNoiseFloor (WifiMode mode) const; |
| 144 /** |
| 145 * \brief This function calculate average RSS of a packet. |
| 146 * \param event EndSync event of the packet. |
| 147 * \param ni list of interference changes. |
| 148 * \returns average RSS over the entire packet. |
| 149 * |
| 150 * This function goes over all interference events over the entire packet and |
| 151 * calculates a time weighted RSS value. |
| 152 */ |
| 153 double CalculatePacketRss (Ptr<const Event> event, NiChanges *ni) const; |
121 | 154 |
122 double m_noiseFigure; /**< noise figure (linear) */ | 155 double m_noiseFigure; /**< noise figure (linear) */ |
123 Ptr<ErrorRateModel> m_errorRateModel; | 156 Ptr<ErrorRateModel> m_errorRateModel; |
124 ///Experimental: needed for energy duration calculation | 157 ///Experimental: needed for energy duration calculation |
125 NiChanges m_niChanges; | 158 NiChanges m_niChanges; |
126 double m_firstPower; | 159 double m_firstPower; |
127 bool m_rxing; | 160 bool m_rxing; |
128 /// Returns an iterator to the first nichange, which is later than moment | 161 /// Returns an iterator to the first nichange, which is later than moment |
129 NiChanges::iterator GetPosition (Time moment); | 162 NiChanges::iterator GetPosition (Time moment); |
130 void AddNiChangeEvent (NiChange change); | 163 void AddNiChangeEvent (NiChange change); |
131 }; | 164 }; |
132 | 165 |
133 } // namespace ns3 | 166 } // namespace ns3 |
134 | 167 |
135 #endif /* INTERFERENCE_HELPER_H */ | 168 #endif /* INTERFERENCE_HELPER_H */ |
LEFT | RIGHT |