src/wifi/model/yans-wifi-phy.cc
changeset 10139 17a71cd49da3
parent 9818 cfb12f56257a
child 10204 7a102bb70a36
equal deleted inserted replaced
10138:2f8e35b43d11 10139:17a71cd49da3
    14  * You should have received a copy of the GNU General Public License
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    17  *
    17  *
    18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
    18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
       
    19  * Author: Ghada Badawy <gbadawy@gmail.com>
    19  */
    20  */
    20 
    21 
    21 #include "yans-wifi-phy.h"
    22 #include "yans-wifi-phy.h"
    22 #include "yans-wifi-channel.h"
    23 #include "yans-wifi-channel.h"
    23 #include "wifi-mode.h"
    24 #include "wifi-mode.h"
    32 #include "ns3/uinteger.h"
    33 #include "ns3/uinteger.h"
    33 #include "ns3/enum.h"
    34 #include "ns3/enum.h"
    34 #include "ns3/pointer.h"
    35 #include "ns3/pointer.h"
    35 #include "ns3/net-device.h"
    36 #include "ns3/net-device.h"
    36 #include "ns3/trace-source-accessor.h"
    37 #include "ns3/trace-source-accessor.h"
       
    38 #include "ns3/boolean.h"
    37 #include <cmath>
    39 #include <cmath>
    38 
    40 
    39 NS_LOG_COMPONENT_DEFINE ("YansWifiPhy");
    41 NS_LOG_COMPONENT_DEFINE ("YansWifiPhy");
    40 
    42 
    41 namespace ns3 {
    43 namespace ns3 {
   117                    "Channel center frequency = Channel starting frequency + 5 MHz * nch",
   119                    "Channel center frequency = Channel starting frequency + 5 MHz * nch",
   118                    UintegerValue (1),
   120                    UintegerValue (1),
   119                    MakeUintegerAccessor (&YansWifiPhy::SetChannelNumber,
   121                    MakeUintegerAccessor (&YansWifiPhy::SetChannelNumber,
   120                                          &YansWifiPhy::GetChannelNumber),
   122                                          &YansWifiPhy::GetChannelNumber),
   121                    MakeUintegerChecker<uint16_t> ())
   123                    MakeUintegerChecker<uint16_t> ())
       
   124     .AddAttribute ("Frequency", "The operating frequency.",
       
   125                    UintegerValue (2407),
       
   126                    MakeUintegerAccessor (&YansWifiPhy::GetFrequency,
       
   127                                         &YansWifiPhy::SetFrequency),
       
   128                    MakeUintegerChecker<uint32_t> ())
       
   129     .AddAttribute ("Transmitters", "The number of transmitters.",
       
   130                    UintegerValue (1),
       
   131                    MakeUintegerAccessor (&YansWifiPhy::GetNumberOfTransmitAntennas,
       
   132                                         &YansWifiPhy::SetNumberOfTransmitAntennas),
       
   133                    MakeUintegerChecker<uint32_t> ())
       
   134     .AddAttribute ("Recievers", "The number of recievers.",
       
   135                    UintegerValue (1),
       
   136                    MakeUintegerAccessor (&YansWifiPhy::GetNumberOfReceiveAntennas,
       
   137                                         &YansWifiPhy::SetNumberOfReceiveAntennas),
       
   138                    MakeUintegerChecker<uint32_t> ())
       
   139     .AddAttribute ("ShortGuardEnabled", "Whether or not short guard interval is enabled.",
       
   140                    BooleanValue (false),
       
   141                    MakeBooleanAccessor (&YansWifiPhy::GetGuardInterval,
       
   142                                         &YansWifiPhy::SetGuardInterval),
       
   143                    MakeBooleanChecker ())
       
   144     .AddAttribute ("LdpcEnabled", "Whether or not LDPC is enabled.",
       
   145                    BooleanValue (false),
       
   146                    MakeBooleanAccessor (&YansWifiPhy::GetLdpc,
       
   147                                         &YansWifiPhy::SetLdpc),
       
   148                    MakeBooleanChecker ())
       
   149     .AddAttribute ("STBCEnabled", "Whether or not STBC is enabled.",
       
   150                    BooleanValue (false),
       
   151                    MakeBooleanAccessor (&YansWifiPhy::GetStbc,
       
   152                                         &YansWifiPhy::SetStbc),
       
   153                    MakeBooleanChecker ())
       
   154     .AddAttribute ("GreenfieldEnabled", "Whether or not STBC is enabled.",
       
   155                    BooleanValue (false),
       
   156                    MakeBooleanAccessor (&YansWifiPhy::GetGreenfield,
       
   157                                         &YansWifiPhy::SetGreenfield),
       
   158                    MakeBooleanChecker ())
       
   159     .AddAttribute ("ChannelBonding", "Whether 20MHz or 40MHz.",
       
   160                    BooleanValue (false),
       
   161                    MakeBooleanAccessor (&YansWifiPhy::GetChannelBonding,
       
   162                                         &YansWifiPhy::SetChannelBonding),
       
   163                    MakeBooleanChecker ())
       
   164 
   122 
   165 
   123   ;
   166   ;
   124   return tid;
   167   return tid;
   125 }
   168 }
   126 
   169 
   143 YansWifiPhy::DoDispose (void)
   186 YansWifiPhy::DoDispose (void)
   144 {
   187 {
   145   NS_LOG_FUNCTION (this);
   188   NS_LOG_FUNCTION (this);
   146   m_channel = 0;
   189   m_channel = 0;
   147   m_deviceRateSet.clear ();
   190   m_deviceRateSet.clear ();
       
   191   m_deviceMcsSet.clear();
   148   m_device = 0;
   192   m_device = 0;
   149   m_mobility = 0;
   193   m_mobility = 0;
   150   m_state = 0;
   194   m_state = 0;
   151 }
   195 }
   152 
   196 
   178       Configure80211p_CCH ();
   222       Configure80211p_CCH ();
   179       break;
   223       break;
   180     case WIFI_PHY_STANDARD_80211p_SCH:
   224     case WIFI_PHY_STANDARD_80211p_SCH:
   181       Configure80211p_SCH ();
   225       Configure80211p_SCH ();
   182       break;
   226       break;
       
   227     case WIFI_PHY_STANDARD_80211n_2_4GHZ:
       
   228       m_channelStartingFrequency=2407;
       
   229       Configure80211n ();
       
   230       break;
       
   231     case WIFI_PHY_STANDARD_80211n_5GHZ:
       
   232       m_channelStartingFrequency=5e3;
       
   233       Configure80211n ();
       
   234       break;
       
   235 
   183     default:
   236     default:
   184       NS_ASSERT (false);
   237       NS_ASSERT (false);
   185       break;
   238       break;
   186     }
   239     }
   187 }
   240 }
   395   m_state->SetReceiveErrorCallback (callback);
   448   m_state->SetReceiveErrorCallback (callback);
   396 }
   449 }
   397 void
   450 void
   398 YansWifiPhy::StartReceivePacket (Ptr<Packet> packet,
   451 YansWifiPhy::StartReceivePacket (Ptr<Packet> packet,
   399                                  double rxPowerDbm,
   452                                  double rxPowerDbm,
   400                                  WifiMode txMode,
   453                                  WifiTxVector txVector,
   401                                  enum WifiPreamble preamble)
   454                                  enum WifiPreamble preamble)
   402 {
   455 {
   403   NS_LOG_FUNCTION (this << packet << rxPowerDbm << txMode << preamble);
   456   NS_LOG_FUNCTION (this << packet << rxPowerDbm << txVector.GetMode()<< preamble);
   404   rxPowerDbm += m_rxGainDb;
   457   rxPowerDbm += m_rxGainDb;
   405   double rxPowerW = DbmToW (rxPowerDbm);
   458   double rxPowerW = DbmToW (rxPowerDbm);
   406   Time rxDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble);
   459   Time rxDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble);
       
   460 WifiMode txMode=txVector.GetMode();
   407   Time endRx = Simulator::Now () + rxDuration;
   461   Time endRx = Simulator::Now () + rxDuration;
   408 
   462 
   409   Ptr<InterferenceHelper::Event> event;
   463   Ptr<InterferenceHelper::Event> event;
   410   event = m_interference.Add (packet->GetSize (),
   464   event = m_interference.Add (packet->GetSize (),
   411                               txMode,
   465                               txMode,
   412                               preamble,
   466                               preamble,
   413                               rxDuration,
   467                               rxDuration,
   414                               rxPowerW);
   468                               rxPowerW,
       
   469 		          txVector);  // we need it to calculate duration of HT training symbols
   415 
   470 
   416   switch (m_state->GetState ())
   471   switch (m_state->GetState ())
   417     {
   472     {
   418     case YansWifiPhy::SWITCHING:
   473     case YansWifiPhy::SWITCHING:
   419       NS_LOG_DEBUG ("drop packet because of channel switching");
   474       NS_LOG_DEBUG ("drop packet because of channel switching");
   493       m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
   548       m_state->SwitchMaybeToCcaBusy (delayUntilCcaEnd);
   494     }
   549     }
   495 }
   550 }
   496 
   551 
   497 void
   552 void
   498 YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiMode txMode, WifiPreamble preamble, uint8_t txPower)
   553 YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiMode txMode, WifiPreamble preamble, WifiTxVector txVector)
   499 {
   554 {
   500   NS_LOG_FUNCTION (this << packet << txMode << preamble << (uint32_t)txPower);
   555   NS_LOG_FUNCTION (this << packet << txMode << preamble << (uint32_t)txVector.GetTxPowerLevel());
   501   /* Transmission can happen if:
   556   /* Transmission can happen if:
   502    *  - we are syncing on a packet. It is the responsability of the
   557    *  - we are syncing on a packet. It is the responsability of the
   503    *    MAC layer to avoid doing this but the PHY does nothing to
   558    *    MAC layer to avoid doing this but the PHY does nothing to
   504    *    prevent it.
   559    *    prevent it.
   505    *  - we are idle
   560    *  - we are idle
   506    */
   561    */
   507   NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
   562   NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
   508 
   563 
   509   Time txDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble);
   564   Time txDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble);
   510   if (m_state->IsStateRx ())
   565   if (m_state->IsStateRx ())
   511     {
   566     {
   512       m_endRxEvent.Cancel ();
   567       m_endRxEvent.Cancel ();
   513       m_interference.NotifyRxEnd ();
   568       m_interference.NotifyRxEnd ();
   514     }
   569     }
   515   NotifyTxBegin (packet);
   570   NotifyTxBegin (packet);
   516   uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;
   571   uint32_t dataRate500KbpsUnits = txVector.GetMode().GetDataRate () * txVector.GetNss() / 500000;
   517   bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
   572   bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
   518   NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble);
   573   NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, txVector.GetTxPowerLevel());
   519   m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower);
   574   m_state->SwitchToTx (txDuration, packet, txVector.GetMode(), preamble,  txVector.GetTxPowerLevel());
   520   m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble);
   575   m_channel->Send (this, packet, GetPowerDbm ( txVector.GetTxPowerLevel()) + m_txGainDb, txVector, preamble);
   521 }
   576 }
   522 
   577 
   523 uint32_t
   578 uint32_t
   524 YansWifiPhy::GetNModes (void) const
   579 YansWifiPhy::GetNModes (void) const
   525 {
   580 {
   780   NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate ()) <<
   835   NS_LOG_DEBUG ("mode=" << (event->GetPayloadMode ().GetDataRate ()) <<
   781                 ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
   836                 ", snr=" << snrPer.snr << ", per=" << snrPer.per << ", size=" << packet->GetSize ());
   782   if (m_random->GetValue () > snrPer.per)
   837   if (m_random->GetValue () > snrPer.per)
   783     {
   838     {
   784       NotifyRxEnd (packet);
   839       NotifyRxEnd (packet);
   785       uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000;
   840       uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () * event->GetTxVector().GetNss()/ 500000;
   786       bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
   841       bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
   787       double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
   842       double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
   788       double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
   843       double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
   789       NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
   844       NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
   790       m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
   845       m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
   802 {
   857 {
   803   NS_LOG_FUNCTION (this << stream);
   858   NS_LOG_FUNCTION (this << stream);
   804   m_random->SetStream (stream);
   859   m_random->SetStream (stream);
   805   return 1;
   860   return 1;
   806 }
   861 }
       
   862 
       
   863 void
       
   864 YansWifiPhy::SetFrequency (uint32_t freq)
       
   865 {
       
   866   m_channelStartingFrequency = freq;
       
   867 }
       
   868 
       
   869 void
       
   870 YansWifiPhy::SetNumberOfTransmitAntennas (uint32_t tx)
       
   871 {
       
   872   m_numberOfTransmitters = tx;
       
   873 }
       
   874 void
       
   875 YansWifiPhy::SetNumberOfReceiveAntennas (uint32_t rx)
       
   876 {
       
   877   m_numberOfReceivers = rx;
       
   878 }
       
   879 
       
   880 void
       
   881 YansWifiPhy::SetLdpc (bool Ldpc)
       
   882 {
       
   883   m_ldpc = Ldpc;
       
   884 }
       
   885 
       
   886 void
       
   887 YansWifiPhy::SetStbc (bool stbc)
       
   888 {
       
   889   m_stbc = stbc;
       
   890 }
       
   891 
       
   892 void
       
   893 YansWifiPhy::SetGreenfield (bool greenfield)
       
   894 {
       
   895   m_greenfield = greenfield;
       
   896 }
       
   897 bool
       
   898 YansWifiPhy::GetGuardInterval (void) const
       
   899 {
       
   900   return m_guardInterval;
       
   901 }
       
   902 void
       
   903 YansWifiPhy::SetGuardInterval (bool GuardInterval)
       
   904 {
       
   905   m_guardInterval = GuardInterval;
       
   906 }
       
   907 
       
   908 uint32_t
       
   909 YansWifiPhy::GetFrequency (void) const
       
   910 {
       
   911   return m_channelStartingFrequency;
       
   912 }
       
   913 
       
   914 uint32_t
       
   915 YansWifiPhy::GetNumberOfTransmitAntennas (void) const
       
   916 {
       
   917   return m_numberOfTransmitters;
       
   918 }
       
   919 uint32_t
       
   920 YansWifiPhy::GetNumberOfReceiveAntennas (void) const
       
   921 {
       
   922   return m_numberOfReceivers;
       
   923 }
       
   924 
       
   925 bool
       
   926 YansWifiPhy::GetLdpc (void) const
       
   927 {
       
   928   return m_ldpc;
       
   929 }
       
   930 bool
       
   931 YansWifiPhy::GetStbc (void) const
       
   932 {
       
   933   return m_stbc;
       
   934 }
       
   935 
       
   936 bool
       
   937 YansWifiPhy::GetGreenfield (void) const
       
   938 {
       
   939   return m_greenfield;
       
   940 }
       
   941 
       
   942 bool
       
   943 YansWifiPhy::GetChannelBonding(void) const
       
   944 {
       
   945   return m_channelBonding;
       
   946 }
       
   947 
       
   948 void
       
   949 YansWifiPhy::SetChannelBonding(bool channelbonding) 
       
   950 {
       
   951   m_channelBonding= channelbonding;
       
   952 }
       
   953 
       
   954 void
       
   955 YansWifiPhy::Configure80211n (void)
       
   956 {
       
   957   NS_LOG_FUNCTION (this);
       
   958   m_deviceRateSet.push_back (WifiPhy::GetDsssRate1Mbps ());
       
   959   m_deviceRateSet.push_back (WifiPhy::GetDsssRate2Mbps ());
       
   960   m_deviceRateSet.push_back (WifiPhy::GetDsssRate5_5Mbps ());
       
   961   m_deviceRateSet.push_back (WifiPhy::GetErpOfdmRate6Mbps ());
       
   962   m_deviceRateSet.push_back (WifiPhy::GetDsssRate11Mbps ());
       
   963   m_deviceRateSet.push_back (WifiPhy::GetErpOfdmRate12Mbps ());
       
   964   m_deviceRateSet.push_back (WifiPhy::GetErpOfdmRate24Mbps ());
       
   965   m_bssMembershipSelectorSet.push_back(HT_PHY);
       
   966   for (uint8_t i=0; i <8; i++)
       
   967     {
       
   968       m_deviceMcsSet.push_back(i);
       
   969     }
       
   970 
       
   971 }
       
   972 uint32_t
       
   973 YansWifiPhy::GetNBssMembershipSelectors (void) const
       
   974 {
       
   975   return  m_bssMembershipSelectorSet.size ();
       
   976 }
       
   977 uint32_t
       
   978 YansWifiPhy::GetBssMembershipSelector (uint32_t selector) const
       
   979 {
       
   980   return  m_bssMembershipSelectorSet[selector];
       
   981 }
       
   982 WifiModeList
       
   983 YansWifiPhy::GetMembershipSelectorModes(uint32_t selector)
       
   984 {
       
   985   uint32_t id=GetBssMembershipSelector(selector);
       
   986   WifiModeList supportedmodes;
       
   987   if (id == HT_PHY)
       
   988   {
       
   989     //mandatory MCS 0 to 7
       
   990      supportedmodes.push_back (WifiPhy::GetOfdmRate6_5MbpsBW20MHz ());
       
   991      supportedmodes.push_back (WifiPhy::GetOfdmRate13MbpsBW20MHz ());
       
   992      supportedmodes.push_back (WifiPhy::GetOfdmRate19_5MbpsBW20MHz ());
       
   993      supportedmodes.push_back (WifiPhy::GetOfdmRate26MbpsBW20MHz ());
       
   994      supportedmodes.push_back (WifiPhy::GetOfdmRate39MbpsBW20MHz ());
       
   995      supportedmodes.push_back (WifiPhy::GetOfdmRate52MbpsBW20MHz ());
       
   996      supportedmodes.push_back (WifiPhy::GetOfdmRate58_5MbpsBW20MHz ());
       
   997      supportedmodes.push_back (WifiPhy::GetOfdmRate65MbpsBW20MHz ());
       
   998   }
       
   999   return supportedmodes;
       
  1000 }
       
  1001 uint8_t
       
  1002 YansWifiPhy::GetNMcs (void) const
       
  1003 {
       
  1004   return  m_deviceMcsSet.size ();
       
  1005 }
       
  1006 uint8_t
       
  1007 YansWifiPhy::GetMcs (uint8_t mcs) const
       
  1008 {
       
  1009   return  m_deviceMcsSet[mcs];
       
  1010 }
       
  1011 uint32_t 
       
  1012 YansWifiPhy::WifiModeToMcs (WifiMode mode)
       
  1013 {
       
  1014     uint32_t mcs = 0;
       
  1015    if (mode.GetUniqueName() == "OfdmRate135MbpsBW40MHzShGi" || mode.GetUniqueName() == "OfdmRate65MbpsBW20MHzShGi" )
       
  1016      {
       
  1017              mcs=6;
       
  1018      }
       
  1019   else
       
  1020     {
       
  1021      switch (mode.GetDataRate())
       
  1022        {
       
  1023          case 6500000:
       
  1024          case 7200000:
       
  1025          case 13500000:
       
  1026          case 15000000:
       
  1027            mcs=0;
       
  1028            break;
       
  1029          case 13000000:
       
  1030          case 14400000:
       
  1031          case 27000000:
       
  1032          case 30000000:
       
  1033            mcs=1;
       
  1034            break;
       
  1035          case 19500000:
       
  1036          case 21700000:
       
  1037          case 40500000:
       
  1038          case 45000000:
       
  1039            mcs=2;
       
  1040            break;
       
  1041          case 26000000:
       
  1042          case 28900000:
       
  1043          case 54000000:
       
  1044          case 60000000:
       
  1045            mcs=3;
       
  1046            break;
       
  1047          case 39000000:
       
  1048          case 43300000:
       
  1049          case 81000000:
       
  1050          case 90000000:        
       
  1051            mcs=4;
       
  1052            break;
       
  1053          case 52000000:
       
  1054          case 57800000:
       
  1055          case 108000000:
       
  1056          case 120000000:
       
  1057            mcs=5;
       
  1058            break; 
       
  1059          case 58500000:
       
  1060          case 121500000:
       
  1061            mcs=6;
       
  1062            break;
       
  1063          case 65000000:
       
  1064          case 72200000:
       
  1065          case 135000000:
       
  1066          case 150000000:
       
  1067            mcs=7;
       
  1068            break;     
       
  1069        }
       
  1070     }
       
  1071   return mcs;
       
  1072 }
       
  1073 WifiMode
       
  1074 YansWifiPhy::McsToWifiMode (uint8_t mcs)
       
  1075 {
       
  1076    WifiMode mode;
       
  1077    switch (mcs)
       
  1078      { 
       
  1079        case 7:
       
  1080           if (!GetGuardInterval() && !GetChannelBonding())
       
  1081            {
       
  1082               mode =  WifiPhy::GetOfdmRate65MbpsBW20MHz ();
       
  1083             }
       
  1084          else if(GetGuardInterval() && !GetChannelBonding())
       
  1085             {
       
  1086               mode = WifiPhy::GetOfdmRate72_2MbpsBW20MHz ();
       
  1087             }
       
  1088           else if (!GetGuardInterval() && GetChannelBonding())
       
  1089             {
       
  1090               mode = WifiPhy::GetOfdmRate135MbpsBW40MHz ();
       
  1091             }
       
  1092           else
       
  1093             {
       
  1094               mode = WifiPhy::GetOfdmRate150MbpsBW40MHz ();
       
  1095             }
       
  1096           break;
       
  1097        case 6:
       
  1098           if (!GetGuardInterval() && !GetChannelBonding())
       
  1099            {
       
  1100               mode = WifiPhy::GetOfdmRate58_5MbpsBW20MHz ();
       
  1101  
       
  1102             }
       
  1103          else if(GetGuardInterval() && !GetChannelBonding())
       
  1104             {
       
  1105               mode =  WifiPhy::GetOfdmRate65MbpsBW20MHzShGi ();
       
  1106        
       
  1107             }
       
  1108           else if (!GetGuardInterval() && GetChannelBonding())
       
  1109             {
       
  1110               mode = WifiPhy::GetOfdmRate121_5MbpsBW40MHz ();
       
  1111      
       
  1112             }
       
  1113           else
       
  1114             {
       
  1115               mode= WifiPhy::GetOfdmRate135MbpsBW40MHzShGi ();
       
  1116           
       
  1117             }
       
  1118           break;
       
  1119        case 5:
       
  1120           if (!GetGuardInterval() && !GetChannelBonding())
       
  1121            {
       
  1122               mode = WifiPhy::GetOfdmRate52MbpsBW20MHz ();
       
  1123   
       
  1124             }
       
  1125          else if(GetGuardInterval() && !GetChannelBonding())
       
  1126             {
       
  1127               mode = WifiPhy::GetOfdmRate57_8MbpsBW20MHz ();
       
  1128             }
       
  1129           else if (!GetGuardInterval() && GetChannelBonding())
       
  1130             {
       
  1131               mode = WifiPhy::GetOfdmRate108MbpsBW40MHz ();
       
  1132      
       
  1133             }
       
  1134           else
       
  1135             {
       
  1136               mode = WifiPhy::GetOfdmRate120MbpsBW40MHz ();
       
  1137        
       
  1138             }
       
  1139           break;
       
  1140        case 4:
       
  1141           if (!GetGuardInterval() && !GetChannelBonding())
       
  1142            {
       
  1143               mode = WifiPhy::GetOfdmRate39MbpsBW20MHz ();
       
  1144             }
       
  1145          else if(GetGuardInterval() && !GetChannelBonding())
       
  1146             {
       
  1147               mode = WifiPhy::GetOfdmRate43_3MbpsBW20MHz ();
       
  1148             }
       
  1149           else if (!GetGuardInterval() && GetChannelBonding())
       
  1150             {
       
  1151               mode = WifiPhy::GetOfdmRate81MbpsBW40MHz ();
       
  1152   
       
  1153             }
       
  1154           else
       
  1155             {
       
  1156               mode = WifiPhy::GetOfdmRate90MbpsBW40MHz ();
       
  1157          
       
  1158             }
       
  1159           break;
       
  1160        case 3:
       
  1161           if (!GetGuardInterval() && !GetChannelBonding())
       
  1162            {
       
  1163               mode =  WifiPhy::GetOfdmRate26MbpsBW20MHz ();
       
  1164   
       
  1165             }
       
  1166          else if(GetGuardInterval() && !GetChannelBonding())
       
  1167             {
       
  1168               mode = WifiPhy::GetOfdmRate28_9MbpsBW20MHz ();
       
  1169       
       
  1170             }
       
  1171           else if (!GetGuardInterval() && GetChannelBonding())
       
  1172             {
       
  1173               mode = WifiPhy::GetOfdmRate54MbpsBW40MHz ();
       
  1174      
       
  1175             }
       
  1176           else
       
  1177             {
       
  1178               mode = WifiPhy::GetOfdmRate60MbpsBW40MHz ();
       
  1179             }
       
  1180           break;
       
  1181        case 2:
       
  1182           if (!GetGuardInterval() && !GetChannelBonding())
       
  1183            {
       
  1184               mode = WifiPhy::GetOfdmRate19_5MbpsBW20MHz ();
       
  1185  
       
  1186             }
       
  1187          else if(GetGuardInterval() && !GetChannelBonding())
       
  1188             {
       
  1189               mode = WifiPhy::GetOfdmRate21_7MbpsBW20MHz ();
       
  1190      
       
  1191             }
       
  1192           else if (!GetGuardInterval() && GetChannelBonding())
       
  1193             {
       
  1194               mode =  WifiPhy::GetOfdmRate40_5MbpsBW40MHz ();
       
  1195   
       
  1196             }
       
  1197           else
       
  1198             {
       
  1199               mode = WifiPhy::GetOfdmRate45MbpsBW40MHz ();
       
  1200            
       
  1201             }
       
  1202           break;
       
  1203        case 1:
       
  1204           if (!GetGuardInterval() && !GetChannelBonding())
       
  1205            {
       
  1206             mode = WifiPhy::GetOfdmRate13MbpsBW20MHz ();
       
  1207   
       
  1208             }
       
  1209          else if(GetGuardInterval() && !GetChannelBonding())
       
  1210             {
       
  1211               mode =  WifiPhy::GetOfdmRate14_4MbpsBW20MHz ();
       
  1212             }
       
  1213           else if (!GetGuardInterval() && GetChannelBonding())
       
  1214             {
       
  1215               mode = WifiPhy::GetOfdmRate27MbpsBW40MHz ();
       
  1216      
       
  1217             }
       
  1218           else
       
  1219             {
       
  1220               mode = WifiPhy::GetOfdmRate30MbpsBW40MHz ();
       
  1221             }
       
  1222           break;
       
  1223        case 0:
       
  1224        default:
       
  1225          if (!GetGuardInterval() && !GetChannelBonding())
       
  1226            {
       
  1227               mode = WifiPhy::GetOfdmRate6_5MbpsBW20MHz ();
       
  1228               
       
  1229             }
       
  1230          else if(GetGuardInterval() && !GetChannelBonding())
       
  1231             {
       
  1232               mode = WifiPhy::GetOfdmRate7_2MbpsBW20MHz ();
       
  1233             }
       
  1234           else if (!GetGuardInterval() && GetChannelBonding())
       
  1235             {
       
  1236               mode = WifiPhy::GetOfdmRate13_5MbpsBW40MHz ();
       
  1237  
       
  1238             }
       
  1239           else
       
  1240             {
       
  1241               mode = WifiPhy::GetOfdmRate15MbpsBW40MHz ();
       
  1242             }
       
  1243          break;
       
  1244         }
       
  1245  return mode;
       
  1246 }
   807 } // namespace ns3
  1247 } // namespace ns3