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

(-)a/src/spectrum/model/wifi-spectrum-value-helper.cc (-9 / +4 lines)
 Lines 135-141    Link Here 
135
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
135
  Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
136
  uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
136
  uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
137
  uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
137
  uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
138
  NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands");
138
  NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumBands ());
139
  double txPowerPerBand = 0;
139
  double txPowerPerBand = 0;
140
  uint32_t start1 = 0;
140
  uint32_t start1 = 0;
141
  uint32_t stop1 = 0;
141
  uint32_t stop1 = 0;
 Lines 144-149    Link Here 
144
  switch (channelWidth)
144
  switch (channelWidth)
145
    {
145
    {
146
    case 20:
146
    case 20:
147
    default:
147
      // 52 subcarriers (48 data + 4 pilot)
148
      // 52 subcarriers (48 data + 4 pilot)
148
      // skip guard band and 6 subbands, then place power in 26 subbands, then
149
      // skip guard band and 6 subbands, then place power in 26 subbands, then
149
      // skip the center subband, then place power in 26 subbands, then skip
150
      // skip the center subband, then place power in 26 subbands, then skip
 Lines 176-184    Link Here 
176
      start2 = stop1 + 2;
177
      start2 = stop1 + 2;
177
      stop2 = start2 + 8 - 1;
178
      stop2 = start2 + 8 - 1;
178
      break;
179
      break;
179
    default:
180
      NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported");
181
      break;
182
    }
180
    }
183
  NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
181
  NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
184
  Values::iterator vit = c->ValuesBegin ();
182
  Values::iterator vit = c->ValuesBegin ();
 Lines 210-216    Link Here 
210
  Bands::const_iterator bit = c->ConstBandsBegin ();
208
  Bands::const_iterator bit = c->ConstBandsBegin ();
211
  uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
209
  uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
212
  uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
210
  uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
213
  NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands");
211
  NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumBands ());
214
  double txPowerPerBand;
212
  double txPowerPerBand;
215
  // skip the guard band and 4 subbands, then place power in 28 subbands, then
213
  // skip the guard band and 4 subbands, then place power in 28 subbands, then
216
  // skip the center subband, then place power in 28 subbands, then skip
214
  // skip the center subband, then place power in 28 subbands, then skip
 Lines 362-370    Link Here 
362
                    ", " << start15 << "-" << stop15 <<
360
                    ", " << start15 << "-" << stop15 <<
363
                    ", " << start16 << "-" << stop16);
361
                    ", " << start16 << "-" << stop16);
364
      break;
362
      break;
365
    default:
366
      NS_FATAL_ERROR ("ChannelWidth " << channelWidth << " unsupported");
367
      break;
368
    }
363
    }
369
  NS_LOG_DEBUG ("Integrated power " << Integral (*c));
364
  NS_LOG_DEBUG ("Integrated power " << Integral (*c));
370
  NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed");
365
  NS_ASSERT_MSG (std::abs (txPowerW - Integral (*c)) < 1e-6, "Power allocation failed");
 Lines 381-387    Link Here 
381
  Bands::const_iterator bit = c->ConstBandsBegin ();
376
  Bands::const_iterator bit = c->ConstBandsBegin ();
382
  uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
377
  uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
383
  uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
378
  uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
384
  NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands");
379
  NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumBands ());
385
  double txPowerPerBand;
380
  double txPowerPerBand;
386
  uint32_t start1;
381
  uint32_t start1;
387
  uint32_t stop1;
382
  uint32_t stop1;
(-)a/src/wifi/model/spectrum-wifi-phy.cc (-15 / +11 lines)
 Lines 228-260    Link Here 
228
}
228
}
229
229
230
Ptr<SpectrumValue>
230
Ptr<SpectrumValue>
231
SpectrumWifiPhy::GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW) const
231
SpectrumWifiPhy::GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW, WifiModulationClass modulationClass) const
232
{
232
{
233
  NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW);
233
  NS_LOG_FUNCTION (centerFrequency << (uint16_t)channelWidth << txPowerW);
234
  Ptr<SpectrumValue> v;
234
  Ptr<SpectrumValue> v;
235
  switch (GetStandard ())
235
  switch (modulationClass)
236
    {
236
    {
237
    case WIFI_PHY_STANDARD_80211a:
237
    case WIFI_MOD_CLASS_OFDM:
238
    case WIFI_PHY_STANDARD_80211g:
238
    case WIFI_MOD_CLASS_ERP_OFDM:
239
    case WIFI_PHY_STANDARD_holland:
240
    case WIFI_PHY_STANDARD_80211_10MHZ:
241
    case WIFI_PHY_STANDARD_80211_5MHZ:
242
      v = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth ());
239
      v = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth ());
243
      break;
240
      break;
244
    case WIFI_PHY_STANDARD_80211b:
241
    case WIFI_MOD_CLASS_DSSS:
242
    case WIFI_MOD_CLASS_HR_DSSS:
245
      v = WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (centerFrequency, txPowerW, GetGuardBandwidth ());
243
      v = WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (centerFrequency, txPowerW, GetGuardBandwidth ());
246
      break;
244
      break;
247
    case WIFI_PHY_STANDARD_80211n_2_4GHZ:
245
    case WIFI_MOD_CLASS_HT:
248
    case WIFI_PHY_STANDARD_80211n_5GHZ:
246
    case WIFI_MOD_CLASS_VHT:
249
    case WIFI_PHY_STANDARD_80211ac:
250
      v = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth ());
247
      v = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth ());
251
      break;
248
      break;
252
    case WIFI_PHY_STANDARD_80211ax_2_4GHZ:
249
    case WIFI_MOD_CLASS_HE:
253
    case WIFI_PHY_STANDARD_80211ax_5GHZ:
254
      v = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth ());
250
      v = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (centerFrequency, channelWidth, txPowerW, GetGuardBandwidth ());
255
      break;
251
      break;
256
    default:
252
    default:
257
      NS_FATAL_ERROR ("Standard unknown: " << GetStandard ());
253
      NS_FATAL_ERROR ("modulation class unknown: " << modulationClass);
258
      break;
254
      break;
259
    }
255
    }
260
  return v;
256
  return v;
 Lines 265-271    Link Here 
265
{
261
{
266
  NS_LOG_DEBUG ("Start transmission: signal power before antenna gain=" << GetPowerDbm (txVector.GetTxPowerLevel ()) << "dBm");
262
  NS_LOG_DEBUG ("Start transmission: signal power before antenna gain=" << GetPowerDbm (txVector.GetTxPowerLevel ()) << "dBm");
267
  double txPowerWatts = DbmToW (GetPowerDbm (txVector.GetTxPowerLevel ()) + GetTxGain ());
263
  double txPowerWatts = DbmToW (GetPowerDbm (txVector.GetTxPowerLevel ()) + GetTxGain ());
268
  Ptr<SpectrumValue> txPowerSpectrum = GetTxPowerSpectralDensity (GetFrequency (), GetChannelWidth (), txPowerWatts);
264
  Ptr<SpectrumValue> txPowerSpectrum = GetTxPowerSpectralDensity (GetFrequency (), GetChannelWidth (), txPowerWatts, txVector.GetMode ().GetModulationClass ());
269
  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
265
  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
270
  txParams->duration = txDuration;
266
  txParams->duration = txDuration;
271
  txParams->psd = txPowerSpectrum;
267
  txParams->psd = txPowerSpectrum;
(-)a/src/wifi/model/spectrum-wifi-phy.h (-1 / +2 lines)
 Lines 172-183    Link Here 
172
   * \param centerFrequency center frequency (MHz)
172
   * \param centerFrequency center frequency (MHz)
173
   * \param channelWidth channel width (MHz) of the channel
173
   * \param channelWidth channel width (MHz) of the channel
174
   * \param txPowerW power in W to spread across the bands
174
   * \param txPowerW power in W to spread across the bands
175
   * \param modulationClass the modulation class
175
   * \return Ptr to SpectrumValue
176
   * \return Ptr to SpectrumValue
176
   *
177
   *
177
   * This is a helper function to create the right Tx PSD corresponding
178
   * This is a helper function to create the right Tx PSD corresponding
178
   * to the standard in use.
179
   * to the standard in use.
179
   */
180
   */
180
  Ptr<SpectrumValue> GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW) const;
181
  Ptr<SpectrumValue> GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW, WifiModulationClass modulationClass) const;
181
182
182
  Ptr<SpectrumChannel> m_channel;        //!< SpectrumChannel that this SpectrumWifiPhy is connected to
183
  Ptr<SpectrumChannel> m_channel;        //!< SpectrumChannel that this SpectrumWifiPhy is connected to
183
  std::vector<uint8_t> m_operationalChannelList; //!< List of possible channels
184
  std::vector<uint8_t> m_operationalChannelList; //!< List of possible channels

Return to bug 2722