Initial multichannel support in Yans Wifi PHY.
1.1 --- a/src/devices/wifi/wifi-phy.h Thu Jul 16 12:31:26 2009 +0200
1.2 +++ b/src/devices/wifi/wifi-phy.h Thu Jul 16 15:56:42 2009 +0400
1.3 @@ -241,7 +241,19 @@
1.4 * the requested ber for the specified transmission mode. (W/W)
1.5 */
1.6 virtual double CalculateSnr (WifiMode txMode, double ber) const = 0;
1.7 -
1.8 +
1.9 + /**
1.10 + * \brief Set channel number.
1.11 + *
1.12 + * Channel center frequency = Channel starting frequency + 5 MHz * (nch - 1)
1.13 + *
1.14 + * where Starting channel frequency is standard-dependent, see SetStandard()
1.15 + * as defined in IEEE 802.11-2007 17.3.8.3.2.
1.16 + */
1.17 + virtual void SetChannelNumber (uint16_t id) = 0;
1.18 + /// Return current channel number, see SetChannelNumber()
1.19 + virtual uint16_t GetChannelNumber () const = 0;
1.20 +
1.21 virtual Ptr<WifiChannel> GetChannel (void) const = 0;
1.22
1.23 static WifiMode Get6mba (void);
2.1 --- a/src/devices/wifi/yans-wifi-channel.cc Thu Jul 16 12:31:26 2009 +0200
2.2 +++ b/src/devices/wifi/yans-wifi-channel.cc Thu Jul 16 15:56:42 2009 +0400
2.3 @@ -77,10 +77,14 @@
2.4 Ptr<MobilityModel> senderMobility = sender->GetMobility ()->GetObject<MobilityModel> ();
2.5 NS_ASSERT (senderMobility != 0);
2.6 uint32_t j = 0;
2.7 - for (PhyList::const_iterator i = m_phyList.begin (); i != m_phyList.end (); i++)
2.8 - {
2.9 + for (PhyList::const_iterator i = m_phyList.begin (); i != m_phyList.end (); i++, j++)
2.10 + {
2.11 if (sender != (*i))
2.12 {
2.13 + // For now don't account for inter channel interference
2.14 + if ((*i)->GetChannelNumber() != sender->GetChannelNumber())
2.15 + continue;
2.16 +
2.17 Ptr<MobilityModel> receiverMobility = (*i)->GetMobility ()->GetObject<MobilityModel> ();
2.18 Time delay = m_delay->GetDelay (senderMobility, receiverMobility);
2.19 double rxPowerDbm = m_loss->CalcRxPower (txPowerDbm, senderMobility, receiverMobility);
2.20 @@ -90,7 +94,6 @@
2.21 Simulator::Schedule (delay, &YansWifiChannel::Receive, this,
2.22 j, copy, rxPowerDbm, wifiMode, preamble);
2.23 }
2.24 - j++;
2.25 }
2.26 }
2.27
3.1 --- a/src/devices/wifi/yans-wifi-phy.cc Thu Jul 16 12:31:26 2009 +0200
3.2 +++ b/src/devices/wifi/yans-wifi-phy.cc Thu Jul 16 15:56:42 2009 +0400
3.3 @@ -112,21 +112,25 @@
3.4 MakeEnumChecker (WIFI_PHY_STANDARD_80211a, "802.11a",
3.5 WIFI_PHY_STANDARD_80211b, "802.11b",
3.6 WIFI_PHY_STANDARD_80211_10Mhz,"802.11_10Mhz",
3.7 - WIFI_PHY_STANDARD_80211_5Mhz,"802-11_5Mhz",
3.8 + WIFI_PHY_STANDARD_80211_5Mhz,"802.11_5Mhz",
3.9 WIFI_PHY_STANDARD_holland, "holland"))
3.10 .AddAttribute ("State", "The state of the PHY layer",
3.11 PointerValue (),
3.12 MakePointerAccessor (&YansWifiPhy::m_state),
3.13 MakePointerChecker<WifiPhyStateHelper> ())
3.14 + .AddAttribute ("ChannelSwitchDelay",
3.15 + "Delay between two short frames transmitted on different frequencies. NOTE: Unused now.",
3.16 + TimeValue (MicroSeconds (250)),
3.17 + MakeTimeAccessor (&YansWifiPhy::m_channelSwitchDelay),
3.18 + MakeTimeChecker ())
3.19 ;
3.20 return tid;
3.21 }
3.22
3.23 YansWifiPhy::YansWifiPhy ()
3.24 - : m_channelFreqMhz(2437),
3.25 - m_endSyncEvent (),
3.26 - m_random (0.0, 1.0)
3.27 -
3.28 + : m_endSyncEvent (),
3.29 + m_random (0.0, 1.0),
3.30 + m_channelStartingFrequency (0)
3.31 {
3.32 NS_LOG_FUNCTION (this);
3.33 m_state = CreateObject<WifiPhyStateHelper> ();
3.34 @@ -163,7 +167,7 @@
3.35 break;
3.36 case WIFI_PHY_STANDARD_80211_5Mhz:
3.37 Configure80211_5Mhz ();
3.38 - break;
3.39 + break;
3.40 case WIFI_PHY_STANDARD_holland:
3.41 ConfigureHolland ();
3.42 break;
3.43 @@ -308,6 +312,33 @@
3.44 {
3.45 m_channel = channel;
3.46 m_channel->Add (this);
3.47 + m_channelId = 1; // always start on channel starting frequency (channel 1)
3.48 +}
3.49 +
3.50 +void
3.51 +YansWifiPhy::SetChannelNumber (uint16_t nch)
3.52 +{
3.53 + // TODO implement channel switching state machine here
3.54 + DoSetChannelNumber (nch);
3.55 +}
3.56 +
3.57 +void
3.58 +YansWifiPhy::DoSetChannelNumber (uint16_t nch)
3.59 +{
3.60 + NS_LOG_DEBUG("switching channel " << m_channelId << " -> " << nch);
3.61 + m_channelId = nch;
3.62 +}
3.63 +
3.64 +uint16_t
3.65 +YansWifiPhy::GetChannelNumber() const
3.66 +{
3.67 + return m_channelId;
3.68 +}
3.69 +
3.70 +double
3.71 +YansWifiPhy::GetChannelFrequencyMhz() const
3.72 +{
3.73 + return m_channelStartingFrequency + 5 * (GetChannelNumber() - 1);
3.74 }
3.75
3.76 void
3.77 @@ -420,7 +451,7 @@
3.78 NotifyTxBegin (packet);
3.79 uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;
3.80 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
3.81 - NotifyPromiscSniffTx (packet, m_channelFreqMhz, dataRate500KbpsUnits, isShortPreamble);
3.82 + NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate500KbpsUnits, isShortPreamble);
3.83 m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower);
3.84 m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble);
3.85 }
3.86 @@ -445,6 +476,7 @@
3.87 YansWifiPhy::Configure80211a (void)
3.88 {
3.89 NS_LOG_FUNCTION (this);
3.90 + m_channelStartingFrequency = 5e3; // 5.000 GHz
3.91 m_modes.push_back (WifiPhy::Get6mba ());
3.92 m_modes.push_back (WifiPhy::Get9mba ());
3.93 m_modes.push_back (WifiPhy::Get12mba ());
3.94 @@ -460,6 +492,7 @@
3.95 YansWifiPhy::Configure80211b (void)
3.96 {
3.97 NS_LOG_FUNCTION (this);
3.98 + m_channelStartingFrequency = 2412; // 2.412 GHz
3.99 m_modes.push_back (WifiPhy::Get1mbb ());
3.100 m_modes.push_back (WifiPhy::Get2mbb ());
3.101 m_modes.push_back (WifiPhy::Get5_5mbb ());
3.102 @@ -470,6 +503,7 @@
3.103 YansWifiPhy::Configure80211_10Mhz (void)
3.104 {
3.105 NS_LOG_FUNCTION (this);
3.106 + m_channelStartingFrequency = 5e3; // 5.000 GHz, suppose 802.11a
3.107 m_modes.push_back (WifiPhy::Get3mb10Mhz ());
3.108 m_modes.push_back (WifiPhy::Get4_5mb10Mhz ());
3.109 m_modes.push_back (WifiPhy::Get6mb10Mhz ());
3.110 @@ -484,6 +518,7 @@
3.111 YansWifiPhy::Configure80211_5Mhz (void)
3.112 {
3.113 NS_LOG_FUNCTION (this);
3.114 + m_channelStartingFrequency = 5e3; // 5.000 GHz, suppose 802.11a
3.115 m_modes.push_back (WifiPhy::Get1_5mb5Mhz ());
3.116 m_modes.push_back (WifiPhy::Get2_25mb5Mhz ());
3.117 m_modes.push_back (WifiPhy::Get3mb5Mhz ());
3.118 @@ -498,6 +533,7 @@
3.119 YansWifiPhy::ConfigureHolland (void)
3.120 {
3.121 NS_LOG_FUNCTION (this);
3.122 + m_channelStartingFrequency = 5e3; // 5.000 GHz
3.123 m_modes.push_back (WifiPhy::Get6mba ());
3.124 m_modes.push_back (WifiPhy::Get12mba ());
3.125 m_modes.push_back (WifiPhy::Get18mba ());
3.126 @@ -621,7 +657,7 @@
3.127 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
3.128 double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
3.129 double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNoiseFigure() + 30 ;
3.130 - NotifyPromiscSniffRx (packet, m_channelFreqMhz, dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
3.131 + NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
3.132 m_state->SwitchFromSyncEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
3.133 }
3.134 else
4.1 --- a/src/devices/wifi/yans-wifi-phy.h Thu Jul 16 12:31:26 2009 +0200
4.2 +++ b/src/devices/wifi/yans-wifi-phy.h Thu Jul 16 15:56:42 2009 +0400
4.3 @@ -69,6 +69,21 @@
4.4 virtual ~YansWifiPhy ();
4.5
4.6 void SetChannel (Ptr<YansWifiChannel> channel);
4.7 +
4.8 + /**
4.9 + * \brief Set channel number.
4.10 + *
4.11 + * Channel center frequency = Channel starting frequency + 5 MHz * (nch - 1)
4.12 + *
4.13 + * where Starting channel frequency is standard-dependent, see SetStandard()
4.14 + * as defined in IEEE 802.11-2007 17.3.8.3.2.
4.15 + */
4.16 + void SetChannelNumber (uint16_t id);
4.17 + /// Return current channel number, see SetChannelNumber()
4.18 + uint16_t GetChannelNumber () const;
4.19 + /// Return current center channel frequency in MHz, see SetСhannelNumber()
4.20 + double GetChannelFrequencyMhz() const;
4.21 +
4.22 void StartReceivePacket (Ptr<Packet> packet,
4.23 double rxPowerDbm,
4.24 WifiMode mode,
4.25 @@ -94,6 +109,8 @@
4.26 Ptr<ErrorRateModel> GetErrorRateModel (void) const;
4.27 Ptr<Object> GetDevice (void) const;
4.28 Ptr<Object> GetMobility (void);
4.29 +
4.30 +
4.31
4.32
4.33 virtual double GetTxPowerStart (void) const;
4.34 @@ -135,6 +152,7 @@
4.35 double RatioToDb (double ratio) const;
4.36 double GetPowerDbm (uint8_t power) const;
4.37 void EndSync (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event);
4.38 + void DoSetChannelNumber(uint16_t id);
4.39
4.40 private:
4.41 double m_edThresholdW;
4.42 @@ -144,17 +162,20 @@
4.43 double m_txPowerBaseDbm;
4.44 double m_txPowerEndDbm;
4.45 uint32_t m_nTxPower;
4.46 - uint16_t m_channelFreqMhz;
4.47
4.48 Ptr<YansWifiChannel> m_channel;
4.49 + uint16_t m_channelId;
4.50 Ptr<Object> m_device;
4.51 Ptr<Object> m_mobility;
4.52 Modes m_modes;
4.53 EventId m_endSyncEvent;
4.54 UniformVariable m_random;
4.55 WifiPhyStandard m_standard;
4.56 + /// Standard-dependent center frequency of 0-th channel, MHz
4.57 + double m_channelStartingFrequency;
4.58 Ptr<WifiPhyStateHelper> m_state;
4.59 InterferenceHelper m_interference;
4.60 + Time m_channelSwitchDelay;
4.61
4.62 };
4.63