View | Details | Raw Unified | Return to bug 2791
Collapse All | Expand All

(-)a/src/wifi/model/interference-helper.cc (-94 / +80 lines)
 Lines 88-110    Link Here 
88
 *       short period of time.
88
 *       short period of time.
89
 ****************************************************************/
89
 ****************************************************************/
90
90
91
InterferenceHelper::NiChange::NiChange (Time time, double delta, Ptr<InterferenceHelper::Event> event)
91
InterferenceHelper::NiChange::NiChange (double power, Ptr<InterferenceHelper::Event> event)
92
  : m_time (time),
92
  : m_power (power),
93
    m_delta (delta),
94
    m_event (event)
93
    m_event (event)
95
{
94
{
96
}
95
}
97
96
98
Time
97
double
99
InterferenceHelper::NiChange::GetTime (void) const
98
InterferenceHelper::NiChange::GetPower (void) const
100
{
99
{
101
  return m_time;
100
  return m_power;
102
}
101
}
103
102
104
double
103
void
105
InterferenceHelper::NiChange::GetDelta (void) const
104
InterferenceHelper::NiChange::AddPower (double power)
106
{
105
{
107
  return m_delta;
106
  m_power += power;
108
}
107
}
109
108
110
Ptr<InterferenceHelper::Event>
109
Ptr<InterferenceHelper::Event>
 Lines 113-124    Link Here 
113
  return m_event;
112
  return m_event;
114
}
113
}
115
114
116
bool
117
InterferenceHelper::NiChange::operator < (const InterferenceHelper::NiChange& o) const
118
{
119
  return (m_time < o.m_time);
120
}
121
122
115
123
/****************************************************************
116
/****************************************************************
124
 *       The actual InterferenceHelper
117
 *       The actual InterferenceHelper
 Lines 130-135    Link Here 
130
    m_firstPower (0),
123
    m_firstPower (0),
131
    m_rxing (false)
124
    m_rxing (false)
132
{
125
{
126
  // Always have a zero power noise event in the list
127
  AddNiChangeEvent (Time (0), NiChange (0.0, 0));
133
}
128
}
134
129
135
InterferenceHelper::~InterferenceHelper ()
130
InterferenceHelper::~InterferenceHelper ()
 Lines 141-148    Link Here 
141
Ptr<InterferenceHelper::Event>
136
Ptr<InterferenceHelper::Event>
142
InterferenceHelper::Add (Ptr<const Packet> packet, WifiTxVector txVector, Time duration, double rxPowerW)
137
InterferenceHelper::Add (Ptr<const Packet> packet, WifiTxVector txVector, Time duration, double rxPowerW)
143
{
138
{
144
  Ptr<InterferenceHelper::Event> event;
139
  Ptr<InterferenceHelper::Event> event = Create<InterferenceHelper::Event> (packet, txVector, duration, rxPowerW);
145
  event = Create<InterferenceHelper::Event> (packet, txVector, duration, rxPowerW);
146
  AppendEvent (event);
140
  AppendEvent (event);
147
  return event;
141
  return event;
148
}
142
}
 Lines 191-207    Link Here 
191
InterferenceHelper::GetEnergyDuration (double energyW) const
185
InterferenceHelper::GetEnergyDuration (double energyW) const
192
{
186
{
193
  Time now = Simulator::Now ();
187
  Time now = Simulator::Now ();
194
  double noiseInterferenceW = 0;
188
  auto i = GetPreviousPosition (now);
195
  Time end = now;
189
  Time end = i->first;
196
  noiseInterferenceW = m_firstPower;
190
  for ( ; i != m_niChanges.end (); ++i)
197
  for (NiChanges::const_iterator i = m_niChanges.begin (); i != m_niChanges.end (); i++)
198
    {
191
    {
199
      noiseInterferenceW += i->GetDelta ();
192
      double noiseInterferenceW = i->second.GetPower ();
200
      end = i->GetTime ();
193
      end = i->first;
201
      if (end < now)
202
        {
203
          continue;
204
        }
205
      if (noiseInterferenceW < energyW)
194
      if (noiseInterferenceW < energyW)
206
        {
195
        {
207
          break;
196
          break;
 Lines 213-230    Link Here 
213
void
202
void
214
InterferenceHelper::AppendEvent (Ptr<InterferenceHelper::Event> event)
203
InterferenceHelper::AppendEvent (Ptr<InterferenceHelper::Event> event)
215
{
204
{
216
  Time now = Simulator::Now ();
205
  NS_LOG_FUNCTION (this);
206
  double previousPowerStart = 0;
207
  double previousPowerEnd = 0;
208
  previousPowerStart = GetPreviousPosition (event->GetStartTime ())->second.GetPower ();
209
  previousPowerEnd = GetPreviousPosition (event->GetEndTime ())->second.GetPower ();
210
217
  if (!m_rxing)
211
  if (!m_rxing)
218
    {
212
    {
219
      NiChanges::const_iterator nowIterator = GetPosition (now);
213
      m_firstPower = previousPowerStart;
220
      for (NiChanges::const_iterator i = m_niChanges.begin (); i != nowIterator; i++)
214
      // Always leave the first zero power noise event in the list
221
        {
215
      m_niChanges.erase (++(m_niChanges.begin ()),
222
          m_firstPower += i->GetDelta ();
216
                         GetNextPosition (event->GetStartTime ()));
223
        }
224
      m_niChanges.erase (m_niChanges.begin (), nowIterator);
225
    }
217
    }
226
  AddNiChangeEvent (NiChange (event->GetStartTime (), event->GetRxPowerW (), event));
218
  auto first = AddNiChangeEvent (event->GetStartTime (), NiChange (previousPowerStart, event));
227
  AddNiChangeEvent (NiChange (event->GetEndTime (), -event->GetRxPowerW (), event));
219
  auto last = AddNiChangeEvent (event->GetEndTime (), NiChange (previousPowerEnd, event));
220
  for (auto i = first; i != last; ++i)
221
    {
222
      i->second.AddPower (event->GetRxPowerW ());
223
    }
228
}
224
}
229
225
230
double
226
double
 Lines 246-286    Link Here 
246
InterferenceHelper::CalculateNoiseInterferenceW (Ptr<InterferenceHelper::Event> event, NiChanges *ni) const
242
InterferenceHelper::CalculateNoiseInterferenceW (Ptr<InterferenceHelper::Event> event, NiChanges *ni) const
247
{
243
{
248
  double noiseInterference = m_firstPower;
244
  double noiseInterference = m_firstPower;
249
  NiChanges::const_iterator eventIterator = m_niChanges.begin ();
245
  auto it = m_niChanges.find (event->GetStartTime ());
250
  while (eventIterator != m_niChanges.end ())
246
  for (; it != m_niChanges.end () && it->second.GetEvent () != event; ++it)
251
    {
247
    {
252
      // Iterate the NI change list from the beginning to the end
248
      noiseInterference = it->second.GetPower ();
253
      // until find the position of the event in the NI change list
254
      // The reason of using the event that causes the NI change to identify
255
      // different NI changes is because in some special cases
256
      // different NI changes happen at the same time with the same delta
257
      // value. Therefore, it may be impossible to identify a NI change that belongs
258
      // to which event based on just the NI time and NI delta value
259
      if (eventIterator->GetEvent () != event)
260
        {
261
          // The NI changes which happen before the event should be considered
262
          // as the interference. This considers the case that the receiving event
263
          // arrives while another receiving event is going on. The SINR of
264
          // the newly arrived event is calculated for checking the possibility of frame capture
265
          noiseInterference += eventIterator->GetDelta ();
266
        }
267
      else
268
        {
269
          break;
270
        }
271
      ++eventIterator;
272
    }
249
    }
273
250
  ni->emplace (event->GetStartTime (), NiChange (0, event));
274
  for (NiChanges::const_iterator i = eventIterator + 1; i != m_niChanges.end (); ++i)
251
  while (++it != m_niChanges.end () && it->second.GetEvent () != event)
275
    {
252
    {
276
      if (event->GetEndTime () == i->GetTime () && event == i->GetEvent ())
253
      ni->insert (*it);
277
        {
278
          break;
279
        }
280
      ni->push_back (*i);
281
    }
254
    }
282
  ni->insert (ni->begin (), NiChange (event->GetStartTime (), noiseInterference, event));
255
  ni->emplace(event->GetEndTime (), NiChange (0, event));
283
  ni->push_back (NiChange (event->GetEndTime (), 0, event));
256
  NS_ABORT_MSG_IF (noiseInterference < 0, "noiseInterference < 0: " <<
257
                   noiseInterference);
284
  return noiseInterference;
258
  return noiseInterference;
285
}
259
}
286
260
 Lines 312-331    Link Here 
312
  NS_LOG_FUNCTION (this);
286
  NS_LOG_FUNCTION (this);
313
  const WifiTxVector txVector = event->GetTxVector ();
287
  const WifiTxVector txVector = event->GetTxVector ();
314
  double psr = 1.0; /* Packet Success Rate */
288
  double psr = 1.0; /* Packet Success Rate */
315
  NiChanges::const_iterator j = ni->begin ();
289
  auto j = ni->begin ();
316
  Time previous = (*j).GetTime ();
290
  Time previous = j->first;
317
  WifiMode payloadMode = event->GetPayloadMode ();
291
  WifiMode payloadMode = event->GetPayloadMode ();
318
  WifiPreamble preamble = txVector.GetPreambleType ();
292
  WifiPreamble preamble = txVector.GetPreambleType ();
319
  Time plcpHeaderStart = (*j).GetTime () + WifiPhy::GetPlcpPreambleDuration (txVector); //packet start time + preamble
293
  Time plcpHeaderStart = j->first + WifiPhy::GetPlcpPreambleDuration (txVector); //packet start time + preamble
320
  Time plcpHsigHeaderStart = plcpHeaderStart + WifiPhy::GetPlcpHeaderDuration (txVector); //packet start time + preamble + L-SIG
294
  Time plcpHsigHeaderStart = plcpHeaderStart + WifiPhy::GetPlcpHeaderDuration (txVector); //packet start time + preamble + L-SIG
321
  Time plcpTrainingSymbolsStart = plcpHsigHeaderStart + WifiPhy::GetPlcpHtSigHeaderDuration (preamble) + WifiPhy::GetPlcpSigA1Duration (preamble) + WifiPhy::GetPlcpSigA2Duration (preamble); //packet start time + preamble + L-SIG + HT-SIG or SIG-A
295
  Time plcpTrainingSymbolsStart = plcpHsigHeaderStart + WifiPhy::GetPlcpHtSigHeaderDuration (preamble) + WifiPhy::GetPlcpSigA1Duration (preamble) + WifiPhy::GetPlcpSigA2Duration (preamble); //packet start time + preamble + L-SIG + HT-SIG or SIG-A
322
  Time plcpPayloadStart = plcpTrainingSymbolsStart + WifiPhy::GetPlcpTrainingSymbolDuration (txVector) + WifiPhy::GetPlcpSigBDuration (preamble); //packet start time + preamble + L-SIG + HT-SIG or SIG-A + Training + SIG-B
296
  Time plcpPayloadStart = plcpTrainingSymbolsStart + WifiPhy::GetPlcpTrainingSymbolDuration (txVector) + WifiPhy::GetPlcpSigBDuration (preamble); //packet start time + preamble + L-SIG + HT-SIG or SIG-A + Training + SIG-B
323
  double noiseInterferenceW = (*j).GetDelta ();
297
  double noiseInterferenceW = m_firstPower;
324
  double powerW = event->GetRxPowerW ();
298
  double powerW = event->GetRxPowerW ();
325
  j++;
299
  while (++j != ni->end ())
326
  while (ni->end () != j)
327
    {
300
    {
328
      Time current = (*j).GetTime ();
301
      Time current = j->first;
329
      NS_LOG_DEBUG ("previous= " << previous << ", current=" << current);
302
      NS_LOG_DEBUG ("previous= " << previous << ", current=" << current);
330
      NS_ASSERT (current >= previous);
303
      NS_ASSERT (current >= previous);
331
      //Case 1: Both previous and current point to the payload
304
      //Case 1: Both previous and current point to the payload
 Lines 348-356    Link Here 
348
                                            payloadMode, txVector);
321
                                            payloadMode, txVector);
349
          NS_LOG_DEBUG ("previous is before payload and current is in the payload: mode=" << payloadMode << ", psr=" << psr);
322
          NS_LOG_DEBUG ("previous is before payload and current is in the payload: mode=" << payloadMode << ", psr=" << psr);
350
        }
323
        }
351
      noiseInterferenceW += (*j).GetDelta ();
324
      noiseInterferenceW = j->second.GetPower () - powerW;
352
      previous = (*j).GetTime ();
325
      previous = j->first;
353
      j++;
354
    }
326
    }
355
  double per = 1 - psr;
327
  double per = 1 - psr;
356
  return per;
328
  return per;
 Lines 362-369    Link Here 
362
  NS_LOG_FUNCTION (this);
334
  NS_LOG_FUNCTION (this);
363
  const WifiTxVector txVector = event->GetTxVector ();
335
  const WifiTxVector txVector = event->GetTxVector ();
364
  double psr = 1.0; /* Packet Success Rate */
336
  double psr = 1.0; /* Packet Success Rate */
365
  NiChanges::const_iterator j = ni->begin ();
337
  auto j = ni->begin ();
366
  Time previous = (*j).GetTime ();
338
  Time previous = j->first;
367
  WifiPreamble preamble = txVector.GetPreambleType ();
339
  WifiPreamble preamble = txVector.GetPreambleType ();
368
  WifiMode mcsHeaderMode;
340
  WifiMode mcsHeaderMode;
369
  if (preamble == WIFI_PREAMBLE_HT_MF || preamble == WIFI_PREAMBLE_HT_GF)
341
  if (preamble == WIFI_PREAMBLE_HT_MF || preamble == WIFI_PREAMBLE_HT_GF)
 Lines 382-397    Link Here 
382
      mcsHeaderMode = WifiPhy::GetHePlcpHeaderMode ();
354
      mcsHeaderMode = WifiPhy::GetHePlcpHeaderMode ();
383
    }
355
    }
384
  WifiMode headerMode = WifiPhy::GetPlcpHeaderMode (txVector);
356
  WifiMode headerMode = WifiPhy::GetPlcpHeaderMode (txVector);
385
  Time plcpHeaderStart = (*j).GetTime () + WifiPhy::GetPlcpPreambleDuration (txVector); //packet start time + preamble
357
  Time plcpHeaderStart = j->first + WifiPhy::GetPlcpPreambleDuration (txVector); //packet start time + preamble
386
  Time plcpHsigHeaderStart = plcpHeaderStart + WifiPhy::GetPlcpHeaderDuration (txVector); //packet start time + preamble + L-SIG
358
  Time plcpHsigHeaderStart = plcpHeaderStart + WifiPhy::GetPlcpHeaderDuration (txVector); //packet start time + preamble + L-SIG
387
  Time plcpTrainingSymbolsStart = plcpHsigHeaderStart + WifiPhy::GetPlcpHtSigHeaderDuration (preamble) + WifiPhy::GetPlcpSigA1Duration (preamble) + WifiPhy::GetPlcpSigA2Duration (preamble); //packet start time + preamble + L-SIG + HT-SIG or SIG-A
359
  Time plcpTrainingSymbolsStart = plcpHsigHeaderStart + WifiPhy::GetPlcpHtSigHeaderDuration (preamble) + WifiPhy::GetPlcpSigA1Duration (preamble) + WifiPhy::GetPlcpSigA2Duration (preamble); //packet start time + preamble + L-SIG + HT-SIG or SIG-A
388
  Time plcpPayloadStart = plcpTrainingSymbolsStart + WifiPhy::GetPlcpTrainingSymbolDuration (txVector) + WifiPhy::GetPlcpSigBDuration (preamble); //packet start time + preamble + L-SIG + HT-SIG or SIG-A + Training + SIG-B
360
  Time plcpPayloadStart = plcpTrainingSymbolsStart + WifiPhy::GetPlcpTrainingSymbolDuration (txVector) + WifiPhy::GetPlcpSigBDuration (preamble); //packet start time + preamble + L-SIG + HT-SIG or SIG-A + Training + SIG-B
389
  double noiseInterferenceW = (*j).GetDelta ();
361
  double noiseInterferenceW = m_firstPower;
390
  double powerW = event->GetRxPowerW ();
362
  double powerW = event->GetRxPowerW ();
391
  j++;
363
  while (++j != ni->end ())
392
  while (ni->end () != j)
393
    {
364
    {
394
      Time current = (*j).GetTime ();
365
      Time current = j->first;
395
      NS_LOG_DEBUG ("previous= " << previous << ", current=" << current);
366
      NS_LOG_DEBUG ("previous= " << previous << ", current=" << current);
396
      NS_ASSERT (current >= previous);
367
      NS_ASSERT (current >= previous);
397
      //Case 1: previous and current after playload start: nothing to do
368
      //Case 1: previous and current after playload start: nothing to do
 Lines 764-772    Link Here 
764
            }
735
            }
765
        }
736
        }
766
737
767
      noiseInterferenceW += (*j).GetDelta ();
738
      noiseInterferenceW = j->second.GetPower () - powerW;
768
      previous = (*j).GetTime ();
739
      previous = j->first;
769
      j++;
770
    }
740
    }
771
741
772
  double per = 1 - psr;
742
  double per = 1 - psr;
 Lines 774-780    Link Here 
774
}
744
}
775
745
776
struct InterferenceHelper::SnrPer
746
struct InterferenceHelper::SnrPer
777
InterferenceHelper::CalculatePlcpPayloadSnrPer (Ptr<InterferenceHelper::Event> event)
747
InterferenceHelper::CalculatePlcpPayloadSnrPer (Ptr<InterferenceHelper::Event> event) const
778
{
748
{
779
  NiChanges ni;
749
  NiChanges ni;
780
  double noiseInterferenceW = CalculateNoiseInterferenceW (event, &ni);
750
  double noiseInterferenceW = CalculateNoiseInterferenceW (event, &ni);
 Lines 794-800    Link Here 
794
}
764
}
795
765
796
struct InterferenceHelper::SnrPer
766
struct InterferenceHelper::SnrPer
797
InterferenceHelper::CalculatePlcpHeaderSnrPer (Ptr<InterferenceHelper::Event> event)
767
InterferenceHelper::CalculatePlcpHeaderSnrPer (Ptr<InterferenceHelper::Event> event) const
798
{
768
{
799
  NiChanges ni;
769
  NiChanges ni;
800
  double noiseInterferenceW = CalculateNoiseInterferenceW (event, &ni);
770
  double noiseInterferenceW = CalculateNoiseInterferenceW (event, &ni);
 Lines 817-836    Link Here 
817
InterferenceHelper::EraseEvents (void)
787
InterferenceHelper::EraseEvents (void)
818
{
788
{
819
  m_niChanges.clear ();
789
  m_niChanges.clear ();
790
  // Always have a zero power noise event in the list
791
  AddNiChangeEvent (Time (0), NiChange (0.0, 0));
820
  m_rxing = false;
792
  m_rxing = false;
821
  m_firstPower = 0;
793
  m_firstPower = 0;
822
}
794
}
823
795
824
InterferenceHelper::NiChanges::const_iterator
796
InterferenceHelper::NiChanges::const_iterator
825
InterferenceHelper::GetPosition (Time moment)
797
InterferenceHelper::GetNextPosition (Time moment) const
826
{
798
{
827
  return std::upper_bound (m_niChanges.begin (), m_niChanges.end (), NiChange (moment, 0, NULL));
799
  return m_niChanges.upper_bound (moment);
828
}
800
}
829
801
830
void
802
InterferenceHelper::NiChanges::const_iterator
831
InterferenceHelper::AddNiChangeEvent (NiChange change)
803
InterferenceHelper::GetPreviousPosition (Time moment) const
832
{
804
{
833
  m_niChanges.insert (GetPosition (change.GetTime ()), change);
805
  auto it = GetNextPosition (moment);
806
  // This is safe since there is always an NiChange at time 0,
807
  // before moment.
808
  --it;
809
  return it;
810
}
811
812
InterferenceHelper::NiChanges::iterator
813
InterferenceHelper::AddNiChangeEvent (Time moment, NiChange change)
814
{
815
  return m_niChanges.insert (GetNextPosition (moment), std::make_pair (moment, change));
834
}
816
}
835
817
836
void
818
void
 Lines 845-850    Link Here 
845
{
827
{
846
  NS_LOG_FUNCTION (this);
828
  NS_LOG_FUNCTION (this);
847
  m_rxing = false;
829
  m_rxing = false;
830
  //Update m_firstPower for frame capture
831
  auto it = m_niChanges.find (Simulator::Now ());
832
  it--;
833
  m_firstPower = it->second.GetPower ();
848
}
834
}
849
835
850
} //namespace ns3
836
} //namespace ns3
(-)a/src/wifi/model/interference-helper.h (-33 / +46 lines)
 Lines 25-30    Link Here 
25
#include "ns3/packet.h"
25
#include "ns3/packet.h"
26
#include "wifi-tx-vector.h"
26
#include "wifi-tx-vector.h"
27
#include "error-rate-model.h"
27
#include "error-rate-model.h"
28
#include <map>
28
29
29
namespace ns3 {
30
namespace ns3 {
30
31
 Lines 40-46    Link Here 
40
   */
41
   */
41
  class Event : public SimpleRefCount<InterferenceHelper::Event>
42
  class Event : public SimpleRefCount<InterferenceHelper::Event>
42
  {
43
  {
43
public:
44
  public:
44
    /**
45
    /**
45
     * Create an Event with the given parameters.
46
     * Create an Event with the given parameters.
46
     *
47
     *
 Lines 89-101    Link Here 
89
    WifiMode GetPayloadMode (void) const;
90
    WifiMode GetPayloadMode (void) const;
90
91
91
92
92
private:
93
  private:
93
    Ptr<const Packet> m_packet; ///< packet
94
    Ptr<const Packet> m_packet; ///< packet
94
    WifiTxVector m_txVector; ///< TXVECTOR
95
    WifiTxVector m_txVector; ///< TXVECTOR
95
    Time m_startTime; ///< start time
96
    Time m_startTime; ///< start time
96
    Time m_endTime; ///< end time
97
    Time m_endTime; ///< end time
97
    double m_rxPowerW; ///< receive power in watts
98
    double m_rxPowerW; ///< receive power in watts
98
  };
99
    
100
  };  // class Event
99
101
100
  /**
102
  /**
101
   * A struct for both SNR and PER
103
   * A struct for both SNR and PER
 Lines 177-183    Link Here 
177
   *
179
   *
178
   * \return struct of SNR and PER
180
   * \return struct of SNR and PER
179
   */
181
   */
180
  struct InterferenceHelper::SnrPer CalculatePlcpPayloadSnrPer (Ptr<InterferenceHelper::Event> event);
182
  struct InterferenceHelper::SnrPer CalculatePlcpPayloadSnrPer (Ptr<InterferenceHelper::Event> event) const;
181
  /**
183
  /**
182
   * Calculate the SNIR at the start of the plcp header and accumulate
184
   * Calculate the SNIR at the start of the plcp header and accumulate
183
   * all SNIR changes in the snir vector.
185
   * all SNIR changes in the snir vector.
 Lines 186-192    Link Here 
186
   *
188
   *
187
   * \return struct of SNR and PER
189
   * \return struct of SNR and PER
188
   */
190
   */
189
  struct InterferenceHelper::SnrPer CalculatePlcpHeaderSnrPer (Ptr<InterferenceHelper::Event> event);
191
  struct InterferenceHelper::SnrPer CalculatePlcpHeaderSnrPer (Ptr<InterferenceHelper::Event> event) const ;
190
192
191
  /**
193
  /**
192
   * Notify that RX has started.
194
   * Notify that RX has started.
 Lines 208-258    Link Here 
208
   */
210
   */
209
  class NiChange
211
  class NiChange
210
  {
212
  {
211
public:
213
  public:
212
    /**
214
    /**
213
     * Create a NiChange at the given time and the amount of NI change.
215
     * Create a NiChange at the given time and the amount of NI change.
214
     *
216
     *
215
     * \param time time of the event
217
     * \param power the power
216
     * \param delta the power
217
     * \param event causes this NI change
218
     * \param event causes this NI change
218
     */
219
     */
219
    NiChange (Time time, double delta, Ptr<InterferenceHelper::Event> event);
220
    NiChange (double power, Ptr<InterferenceHelper::Event> event);
220
    /**
221
     * Return the event time.
222
     *
223
     * \return the event time.
224
     */
225
    Time GetTime (void) const;
226
    /**
221
    /**
227
     * Return the power
222
     * Return the power
228
     *
223
     *
229
     * \return the power
224
     * \return the power
230
     */
225
     */
231
    double GetDelta (void) const;
226
    double GetPower (void) const;
227
    /**
228
     * Add a given amount of power.
229
     *
230
     * \param power the power to be added to the existing value
231
     */
232
    void AddPower (double power);
232
    /**
233
    /**
233
     * Return the event causes the corresponding NI change
234
     * Return the event causes the corresponding NI change
234
     *
235
     *
235
     * \return the event
236
     * \return the event
236
     */
237
     */
237
    Ptr<InterferenceHelper::Event> GetEvent (void) const;
238
    Ptr<InterferenceHelper::Event> GetEvent (void) const;
238
    /**
239
     * Compare the event time of two NiChange objects (a < o).
240
     *
241
     * \param o
242
     * \return true if a < o.time, false otherwise
243
     */
244
    bool operator < (const NiChange& o) const;
245
239
246
240
247
private:
241
  private:
248
    Time m_time; ///< time
242
    double m_power; ///< power
249
    double m_delta; ///< delta
250
    Ptr<InterferenceHelper::Event> m_event; ///< event
243
    Ptr<InterferenceHelper::Event> m_event; ///< event
251
  };
244
    
245
  };  // class NiChange
246
  
252
  /**
247
  /**
253
   * typedef for a vector of NiChanges
248
   * typedef for a multimap of NiChanges
254
   */
249
   */
255
  typedef std::vector <NiChange> NiChanges;
250
  typedef std::multimap<Time, NiChange> NiChanges;
256
251
257
  /**
252
  /**
258
   * Append the given Event.
253
   * Append the given Event.
 Lines 322-339    Link Here 
322
  bool m_rxing; ///< flag whether it is in receiving state
317
  bool m_rxing; ///< flag whether it is in receiving state
323
318
324
  /**
319
  /**
325
   * Returns a const iterator to the first nichange, which is later than moment
320
   * Returns an iterator to the first nichange that is later than moment
321
   *
322
   * \param moment time to check from
323
   * \returns an iterator to the list of NiChanges
324
   */
325
  NiChanges::const_iterator GetNextPosition (Time moment) const;
326
  /**
327
   * Returns an iterator to the first nichange that is later than moment
326
   *
328
   *
327
   * \param moment time to check from
329
   * \param moment time to check from
328
   * \returns an iterator to the list of NiChanges
330
   * \returns an iterator to the list of NiChanges
329
   */
331
   */
330
  NiChanges::const_iterator GetPosition (Time moment);
332
  //NiChanges::iterator GetNextPosition (Time moment);
331
  /**
333
  /**
332
   * Add NiChange to the list at the appropriate position.
334
   * Returns an iterator to the last nichange that is before than moment
335
   *
336
   * \param moment time to check from
337
   * \returns an iterator to the list of NiChanges
338
   */
339
  NiChanges::const_iterator GetPreviousPosition (Time moment) const;
340
341
  /**
342
   * Add NiChange to the list at the appropriate position and
343
   * return the iterator of the new event.
333
   *
344
   *
334
   * \param change
345
   * \param change
346
   * \param moment
347
   * \returns the iterator of the new event
335
   */
348
   */
336
  void AddNiChangeEvent (NiChange change);
349
  NiChanges::iterator AddNiChangeEvent (Time moment, NiChange change);
337
};
350
};
338
351
339
} //namespace ns3
352
} //namespace ns3

Return to bug 2791