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

(-)a/src/wifi/model/spectrum-wifi-phy.cc (+56 lines)
 Lines 126-131    Link Here 
126
}
126
}
127
127
128
void
128
void
129
SpectrumWifiPhy::ResetSpectrumModel (void)
130
{
131
  NS_LOG_FUNCTION (this);
132
  NS_ASSERT_MSG (IsInitialized (), "Executing method before run-time");
133
  NS_LOG_DEBUG ("Run-time change of spectrum model from frequency/width pair of (" << GetFrequency () << ", " << (uint16_t)GetChannelWidth () << ")");
134
  // Replace existing spectrum model with new one, and must call AddRx ()
135
  // on the SpectrumChannel to provide this new spectrum model to it
136
  m_rxSpectrumModel = WifiSpectrumValueHelper::GetSpectrumModel (GetFrequency (), GetChannelWidth (), GetBandBandwidth (), GetGuardBandwidth ());
137
  m_channel->AddRx (m_wifiSpectrumPhyInterface);
138
}
139
140
void
141
SpectrumWifiPhy::SetChannelNumber (uint8_t nch)
142
{
143
  NS_LOG_FUNCTION (this << (uint16_t) nch);
144
  WifiPhy::SetChannelNumber (nch);
145
  if (IsInitialized ())
146
    {
147
      ResetSpectrumModel ();
148
    }
149
}
150
151
void
152
SpectrumWifiPhy::SetFrequency (uint16_t freq)
153
{
154
  NS_LOG_FUNCTION (this << freq);
155
  WifiPhy::SetFrequency (freq);
156
  if (IsInitialized ())
157
    {
158
      ResetSpectrumModel ();
159
    }
160
}
161
162
void
163
SpectrumWifiPhy::SetChannelWidth (uint8_t channelwidth)
164
{
165
  NS_LOG_FUNCTION (this << (uint16_t) channelwidth);
166
  WifiPhy::SetChannelWidth (channelwidth);
167
  if (IsInitialized ())
168
    {
169
      ResetSpectrumModel ();
170
    }
171
}
172
173
void 
174
SpectrumWifiPhy::ConfigureStandard (WifiPhyStandard standard)
175
{
176
  NS_LOG_FUNCTION (this << standard);
177
  WifiPhy::ConfigureStandard (standard);
178
  if (IsInitialized ())
179
    {
180
      ResetSpectrumModel ();
181
    }
182
}
183
184
void
129
SpectrumWifiPhy::AddOperationalChannel (uint8_t channelNumber)
185
SpectrumWifiPhy::AddOperationalChannel (uint8_t channelNumber)
130
{
186
{
131
  m_operationalChannelList.push_back (channelNumber);
187
  m_operationalChannelList.push_back (channelNumber);
(-)a/src/wifi/model/spectrum-wifi-phy.h (+15 lines)
 Lines 160-165    Link Here 
160
160
161
  Ptr<Channel> GetChannel (void) const;
161
  Ptr<Channel> GetChannel (void) const;
162
162
163
  // The following four methods call to the base WifiPhy class method
164
  // but also generate a new SpectrumModel if called during runtime
165
166
  virtual void SetChannelNumber (uint8_t id);
167
168
  virtual void SetFrequency (uint16_t freq);
169
170
  virtual void SetChannelWidth (uint8_t channelwidth);
171
172
  virtual void ConfigureStandard (WifiPhyStandard standard);
163
173
164
protected:
174
protected:
165
  // Inherited
175
  // Inherited
 Lines 180-185    Link Here 
180
   */
190
   */
181
  Ptr<SpectrumValue> GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW, WifiModulationClass modulationClass) const;
191
  Ptr<SpectrumValue> GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t channelWidth, double txPowerW, WifiModulationClass modulationClass) const;
182
192
193
  /**
194
   * Perform run-time spectrum model change
195
   */
196
  void ResetSpectrumModel (void);
197
183
  Ptr<SpectrumChannel> m_channel;        //!< SpectrumChannel that this SpectrumWifiPhy is connected to
198
  Ptr<SpectrumChannel> m_channel;        //!< SpectrumChannel that this SpectrumWifiPhy is connected to
184
  std::vector<uint8_t> m_operationalChannelList; //!< List of possible channels
199
  std::vector<uint8_t> m_operationalChannelList; //!< List of possible channels
185
200
(-)a/src/wifi/model/wifi-phy.h (-6 / +5 lines)
 Lines 588-601    Link Here 
588
   *
588
   *
589
   * Channel center frequency = Channel starting frequency + 5 MHz * (nch - 1)
589
   * Channel center frequency = Channel starting frequency + 5 MHz * (nch - 1)
590
   *
590
   *
591
   * where Starting channel frequency is standard-dependent, see SetStandard()
591
   * where Starting channel frequency is standard-dependent,
592
   * as defined in (Section 18.3.8.4.2 "Channel numbering"; IEEE Std 802.11-2012).
592
   * as defined in (Section 18.3.8.4.2 "Channel numbering"; IEEE Std 802.11-2012).
593
   * This method may fail to take action if the Phy model determines that
593
   * This method may fail to take action if the Phy model determines that
594
   * the channel number cannot be switched for some reason (e.g. sleep state)
594
   * the channel number cannot be switched for some reason (e.g. sleep state)
595
   *
595
   *
596
   * \param id the channel number
596
   * \param id the channel number
597
   */
597
   */
598
  void SetChannelNumber (uint8_t id);
598
  virtual void SetChannelNumber (uint8_t id);
599
  /**
599
  /**
600
   * Return current channel number.
600
   * Return current channel number.
601
   *
601
   *
 Lines 612-618    Link Here 
612
   *
612
   *
613
   * \param standard the Wi-Fi standard
613
   * \param standard the Wi-Fi standard
614
   */
614
   */
615
  void ConfigureStandard (WifiPhyStandard standard);
615
  virtual void ConfigureStandard (WifiPhyStandard standard);
616
616
617
  /**
617
  /**
618
   * Get the configured Wi-Fi standard
618
   * Get the configured Wi-Fi standard
 Lines 1488-1494    Link Here 
1488
  /**
1488
  /**
1489
   * \param freq the operating center frequency (MHz) on this node.
1489
   * \param freq the operating center frequency (MHz) on this node.
1490
   */
1490
   */
1491
  void SetFrequency (uint16_t freq);
1491
  virtual void SetFrequency (uint16_t freq);
1492
  /**
1492
  /**
1493
   * \return the operating center frequency (MHz)
1493
   * \return the operating center frequency (MHz)
1494
   */
1494
   */
 Lines 1628-1634    Link Here 
1628
  /**
1628
  /**
1629
   * \param channelwidth channel width
1629
   * \param channelwidth channel width
1630
   */
1630
   */
1631
  void SetChannelWidth (uint8_t channelwidth);
1631
  virtual void SetChannelWidth (uint8_t channelwidth);
1632
  /**
1632
  /**
1633
   * \param channelwidth channel width (in MHz) to support
1633
   * \param channelwidth channel width (in MHz) to support
1634
   */
1634
   */
 Lines 1695-1701    Link Here 
1695
  EventId m_endRxEvent;                //!< the end reeive event
1695
  EventId m_endRxEvent;                //!< the end reeive event
1696
  EventId m_endPlcpRxEvent;            //!< the end PLCP receive event
1696
  EventId m_endPlcpRxEvent;            //!< the end PLCP receive event
1697
1697
1698
1699
private:
1698
private:
1700
  /**
1699
  /**
1701
   * \brief post-construction setting of frequency and/or channel number
1700
   * \brief post-construction setting of frequency and/or channel number

Return to bug 2673