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

(-)a/src/spectrum/model/wifi-spectrum-value-helper.cc (-14 / +11 lines)
 Lines 54-62    Link Here 
54
static std::map<WifiSpectrumModelId, Ptr<SpectrumModel> > g_wifiSpectrumModelMap;
54
static std::map<WifiSpectrumModelId, Ptr<SpectrumModel> > g_wifiSpectrumModelMap;
55
55
56
Ptr<SpectrumModel>
56
Ptr<SpectrumModel>
57
WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint32_t channelWidth)
57
WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth)
58
{
58
{
59
  NS_LOG_FUNCTION (centerFrequency << channelWidth);
59
  NS_LOG_FUNCTION (centerFrequency << channelWidth << bandBandwidth);
60
  Ptr<SpectrumModel> ret;
60
  Ptr<SpectrumModel> ret;
61
  WifiSpectrumModelId key (centerFrequency, channelWidth);
61
  WifiSpectrumModelId key (centerFrequency, channelWidth);
62
  std::map<WifiSpectrumModelId, Ptr<SpectrumModel> >::iterator it = g_wifiSpectrumModelMap.find (key);
62
  std::map<WifiSpectrumModelId, Ptr<SpectrumModel> >::iterator it = g_wifiSpectrumModelMap.find (key);
 Lines 70-77    Link Here 
70
      double centerFrequencyHz = centerFrequency * 1e6;
70
      double centerFrequencyHz = centerFrequency * 1e6;
71
      // Overall bandwidth will be channelWidth plus 10 MHz guards on each side
71
      // Overall bandwidth will be channelWidth plus 10 MHz guards on each side
72
      double bandwidth = (channelWidth + 20) * 1e6;
72
      double bandwidth = (channelWidth + 20) * 1e6;
73
      // Use OFDM subcarrier width of 312.5 KHz as band granularity
74
      double bandBandwidth = 312500;
75
      // For OFDM, the center subcarrier is null (at center frequency)
73
      // For OFDM, the center subcarrier is null (at center frequency)
76
      uint32_t numBands = static_cast<uint32_t> (bandwidth / bandBandwidth + 0.5);
74
      uint32_t numBands = static_cast<uint32_t> (bandwidth / bandBandwidth + 0.5);
77
      NS_ASSERT (numBands > 0);
75
      NS_ASSERT (numBands > 0);
 Lines 109-115    Link Here 
109
WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW)
107
WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW)
110
{
108
{
111
  NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW);
109
  NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW);
112
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth));
110
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, 312500));
113
  Values::iterator vit = c->ValuesBegin ();
111
  Values::iterator vit = c->ValuesBegin ();
114
  Bands::const_iterator bit = c->ConstBandsBegin ();
112
  Bands::const_iterator bit = c->ConstBandsBegin ();
115
  double txPowerPerBand;
113
  double txPowerPerBand;
 Lines 202-208    Link Here 
202
WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW)
200
WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double txPowerW)
203
{
201
{
204
  NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW);
202
  NS_LOG_FUNCTION (centerFrequency << channelWidth << txPowerW);
205
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth));
203
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, 312500));
206
  Values::iterator vit = c->ValuesBegin ();
204
  Values::iterator vit = c->ValuesBegin ();
207
  Bands::const_iterator bit = c->ConstBandsBegin ();
205
  Bands::const_iterator bit = c->ConstBandsBegin ();
208
  double txPowerPerBand;
206
  double txPowerPerBand;
 Lines 287-293    Link Here 
287
{
285
{
288
  NS_LOG_FUNCTION (centerFrequency << txPowerW);
286
  NS_LOG_FUNCTION (centerFrequency << txPowerW);
289
  uint32_t channelWidth = 22;  // DSSS channels are 22 MHz wide
287
  uint32_t channelWidth = 22;  // DSSS channels are 22 MHz wide
290
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth));
288
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, 312500));
291
  Values::iterator vit = c->ValuesBegin ();
289
  Values::iterator vit = c->ValuesBegin ();
292
  Bands::const_iterator bit = c->ConstBandsBegin ();
290
  Bands::const_iterator bit = c->ConstBandsBegin ();
293
  double txPowerPerBand;
291
  double txPowerPerBand;
 Lines 305-313    Link Here 
305
}
303
}
306
304
307
Ptr<SpectrumValue>
305
Ptr<SpectrumValue>
308
WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double noiseFigure)
306
WifiSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth, double noiseFigure)
309
{
307
{
310
  Ptr<SpectrumModel> model = GetSpectrumModel (centerFrequency, channelWidth);
308
  Ptr<SpectrumModel> model = GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth);
311
  return CreateNoisePowerSpectralDensity (noiseFigure, model);
309
  return CreateNoisePowerSpectralDensity (noiseFigure, model);
312
}
310
}
313
311
 Lines 330-344    Link Here 
330
}
328
}
331
329
332
Ptr<SpectrumValue>
330
Ptr<SpectrumValue>
333
WifiSpectrumValueHelper::CreateRfFilter (uint32_t centerFrequency, uint32_t channelWidth)
331
WifiSpectrumValueHelper::CreateRfFilter (uint32_t centerFrequency, uint32_t channelWidth, double bandGranularity)
334
{
332
{
335
  NS_LOG_FUNCTION (centerFrequency << channelWidth);
333
  NS_LOG_FUNCTION (centerFrequency << channelWidth << bandGranularity);
336
  Ptr<SpectrumValue> c = Create <SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth));
334
  Ptr<SpectrumValue> c = Create <SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandGranularity));
337
  size_t numBands = c->GetSpectrumModel ()->GetNumBands ();
335
  size_t numBands = c->GetSpectrumModel ()->GetNumBands ();
338
  Bands::const_iterator bit = c->ConstBandsBegin ();
336
  Bands::const_iterator bit = c->ConstBandsBegin ();
339
  Values::iterator vit = c->ValuesBegin ();
337
  Values::iterator vit = c->ValuesBegin ();
340
  uint32_t bandBandwidth = static_cast<uint32_t> (((bit->fh - bit->fl) + 0.5));
338
  uint32_t bandBandwidth = static_cast<uint32_t> (bandGranularity);
341
  NS_LOG_DEBUG ("Band bandwidth: " << bandBandwidth);
342
  size_t numBandsInFilter = static_cast<size_t> (channelWidth * 1e6 / bandBandwidth); 
339
  size_t numBandsInFilter = static_cast<size_t> (channelWidth * 1e6 / bandBandwidth); 
343
  if (channelWidth % bandBandwidth != 0)
340
  if (channelWidth % bandBandwidth != 0)
344
    {
341
    {
(-)a/src/spectrum/model/wifi-spectrum-value-helper.h (-3 / +6 lines)
 Lines 48-57    Link Here 
48
   *
48
   *
49
   * \param centerFrequency center frequency (MHz)
49
   * \param centerFrequency center frequency (MHz)
50
   * \param channelWidth channel width (MHz)
50
   * \param channelWidth channel width (MHz)
51
   * \param bandBandwidth width of each band (Hz)
51
   * \return the static SpectrumModel instance corresponding to the
52
   * \return the static SpectrumModel instance corresponding to the
52
   * given carrier frequency and channel width configuration. 
53
   * given carrier frequency and channel width configuration. 
53
   */
54
   */
54
  static Ptr<SpectrumModel> GetSpectrumModel (uint32_t centerFrequency, uint32_t channelWidth);
55
  static Ptr<SpectrumModel> GetSpectrumModel (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth);
55
56
56
  /**
57
  /**
57
   * Create a transmit power spectral density corresponding to OFDM 
58
   * Create a transmit power spectral density corresponding to OFDM 
 Lines 89-98    Link Here 
89
   *
90
   *
90
   * \param centerFrequency center frequency (MHz)
91
   * \param centerFrequency center frequency (MHz)
91
   * \param channelWidth channel width (MHz)
92
   * \param channelWidth channel width (MHz)
93
   * \param bandBandwidth width of each band (Hz)
92
   * \param noiseFigure the noise figure in dB w.r.t. a reference temperature of 290K
94
   * \param noiseFigure the noise figure in dB w.r.t. a reference temperature of 290K
93
   * \return a pointer to a newly allocated SpectrumValue representing the noise Power Spectral Density in W/Hz for each Band
95
   * \return a pointer to a newly allocated SpectrumValue representing the noise Power Spectral Density in W/Hz for each Band
94
   */
96
   */
95
  static Ptr<SpectrumValue> CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double noiseFigure);
97
  static Ptr<SpectrumValue> CreateNoisePowerSpectralDensity (uint32_t centerFrequency, uint32_t channelWidth, double bandBandwidth, double noiseFigure);
96
98
97
  /**
99
  /**
98
   * \param centerFrequency center frequency (MHz)
100
   * \param centerFrequency center frequency (MHz)
 Lines 104-113    Link Here 
104
  /**
106
  /**
105
   * \param centerFrequency center frequency (MHz)
107
   * \param centerFrequency center frequency (MHz)
106
   * \param channelWidth channel width (MHz)
108
   * \param channelWidth channel width (MHz)
109
   * \param bandGranularity band granularity (Hz)
107
   * \return a pointer to a SpectrumValue representing the RF filter applied
110
   * \return a pointer to a SpectrumValue representing the RF filter applied
108
   * to an received power spectral density
111
   * to an received power spectral density
109
   */
112
   */
110
  static Ptr<SpectrumValue> CreateRfFilter (uint32_t centerFrequency, uint32_t channelWidth);
113
  static Ptr<SpectrumValue> CreateRfFilter (uint32_t centerFrequency, uint32_t channelWidth, double bandGranularity);
111
};
114
};
112
115
113
/**
116
/**
(-)a/src/wifi/model/spectrum-wifi-phy.cc (-2 / +27 lines)
 Lines 107-113    Link Here 
107
      else
107
      else
108
        {
108
        {
109
          NS_LOG_DEBUG ("Creating spectrum model from frequency/width pair of (" << GetFrequency () << ", " << (uint16_t)GetChannelWidth () << ")");
109
          NS_LOG_DEBUG ("Creating spectrum model from frequency/width pair of (" << GetFrequency () << ", " << (uint16_t)GetChannelWidth () << ")");
110
          m_rxSpectrumModel = WifiSpectrumValueHelper::GetSpectrumModel (GetFrequency (), GetChannelWidth ());
110
          m_rxSpectrumModel = WifiSpectrumValueHelper::GetSpectrumModel (GetFrequency (), GetChannelWidth (), GetBandBandwidth ());
111
        }
111
        }
112
    }
112
    }
113
  return m_rxSpectrumModel;
113
  return m_rxSpectrumModel;
 Lines 168-174    Link Here 
168
  // Integrate over our receive bandwidth (i.e., all that the receive
168
  // Integrate over our receive bandwidth (i.e., all that the receive
169
  // spectral mask representing our filtering allows) to find the
169
  // spectral mask representing our filtering allows) to find the
170
  // total energy apparent to the "demodulator".
170
  // total energy apparent to the "demodulator".
171
  Ptr<SpectrumValue> filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), GetChannelWidth ());
171
  Ptr<SpectrumValue> filter = WifiSpectrumValueHelper::CreateRfFilter (GetFrequency (), GetChannelWidth (), GetBandBandwidth ());
172
  SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
172
  SpectrumValue filteredSignal = (*filter) * (*receivedSignalPsd);
173
  // Add receiver antenna gain
173
  // Add receiver antenna gain
174
  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain: " << Integral (filteredSignal));
174
  NS_LOG_DEBUG ("Signal power received (watts) before antenna gain: " << Integral (filteredSignal));
 Lines 274-277    Link Here 
274
  m_channel->StartTx (txParams);
274
  m_channel->StartTx (txParams);
275
}
275
}
276
276
277
double
278
SpectrumWifiPhy::GetBandBandwidth (void) const
279
{
280
  double bandBandwidth = 0;
281
  switch (GetStandard ())
282
    {
283
    case WIFI_PHY_STANDARD_80211a:
284
    case WIFI_PHY_STANDARD_80211g:
285
    case WIFI_PHY_STANDARD_holland:
286
    case WIFI_PHY_STANDARD_80211_10MHZ:
287
    case WIFI_PHY_STANDARD_80211_5MHZ:
288
    case WIFI_PHY_STANDARD_80211b:
289
    case WIFI_PHY_STANDARD_80211n_2_4GHZ:
290
    case WIFI_PHY_STANDARD_80211n_5GHZ:
291
    case WIFI_PHY_STANDARD_80211ac:
292
      // Use OFDM subcarrier width of 312.5 KHz as band granularity
293
      bandBandwidth = 312500;
294
      break;
295
    default:
296
      NS_FATAL_ERROR ("Standard unknown: " << GetStandard ());
297
      break;
298
    }
299
  return bandBandwidth ;
300
}
301
277
} //namespace ns3
302
} //namespace ns3
(-)a/src/wifi/model/spectrum-wifi-phy.h (+5 lines)
 Lines 139-144    Link Here 
139
  Ptr<const SpectrumModel> GetRxSpectrumModel () const;
139
  Ptr<const SpectrumModel> GetRxSpectrumModel () const;
140
140
141
  /**
141
  /**
142
   * \return the width of each band (Hz)
143
   */
144
  double GetBandBandwidth (void) const;
145
146
  /**
142
   * Callback invoked when the Phy model starts to process a signal
147
   * Callback invoked when the Phy model starts to process a signal
143
   *
148
   *
144
   * \param signalType Whether signal is WiFi (true) or foreign (false)
149
   * \param signalType Whether signal is WiFi (true) or foreign (false)

Return to bug 2718