src/wifi/model/ap-wifi-mac.cc
changeset 10139 17a71cd49da3
parent 9705 43fa2408aa05
child 10206 ecd136bcb899
equal deleted inserted replaced
10138:2f8e35b43d11 10139:17a71cd49da3
   225   else
   225   else
   226     {
   226     {
   227       hdr.SetTypeData ();
   227       hdr.SetTypeData ();
   228     }
   228     }
   229 
   229 
       
   230   if (m_htSupported)
       
   231    hdr.SetNoOrder();
   230   hdr.SetAddr1 (to);
   232   hdr.SetAddr1 (to);
   231   hdr.SetAddr2 (GetAddress ());
   233   hdr.SetAddr2 (GetAddress ());
   232   hdr.SetAddr3 (from);
   234   hdr.SetAddr3 (from);
   233   hdr.SetDsFrom ();
   235   hdr.SetDsFrom ();
   234   hdr.SetDsNotTo ();
   236   hdr.SetDsNotTo ();
   274 
   276 
   275 SupportedRates
   277 SupportedRates
   276 ApWifiMac::GetSupportedRates (void) const
   278 ApWifiMac::GetSupportedRates (void) const
   277 {
   279 {
   278   NS_LOG_FUNCTION (this);
   280   NS_LOG_FUNCTION (this);
       
   281   SupportedRates rates;
       
   282   // If it is an HT-AP then add the BSSMembershipSelectorSet 
       
   283   // which only includes 127 for HT now. The standard says that the BSSMembershipSelectorSet
       
   284   // must have its MSB set to 1 (must be treated as a Basic Rate)
       
   285   // Also the standard mentioned that at leat 1 element should be included in the SupportedRates the rest can be in the ExtendedSupportedRates
       
   286   if (m_htSupported)
       
   287     {
       
   288       for (uint32_t i = 0; i < m_phy->GetNBssMembershipSelectors(); i++)
       
   289         {
       
   290           rates.SetBasicRate(m_phy->GetBssMembershipSelector(i));
       
   291         }
       
   292     }
   279   // send the set of supported rates and make sure that we indicate
   293   // send the set of supported rates and make sure that we indicate
   280   // the Basic Rate set in this set of supported rates.
   294   // the Basic Rate set in this set of supported rates.
   281   SupportedRates rates;
       
   282   for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
   295   for (uint32_t i = 0; i < m_phy->GetNModes (); i++)
   283     {
   296     {
   284       WifiMode mode = m_phy->GetMode (i);
   297       WifiMode mode = m_phy->GetMode (i);
   285       rates.AddSupportedRate (mode.GetDataRate ());
   298       rates.AddSupportedRate (mode.GetDataRate ());
   286     }
   299     }
   288   for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++)
   301   for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++)
   289     {
   302     {
   290       WifiMode mode = m_stationManager->GetBasicMode (j);
   303       WifiMode mode = m_stationManager->GetBasicMode (j);
   291       rates.SetBasicRate (mode.GetDataRate ());
   304       rates.SetBasicRate (mode.GetDataRate ());
   292     }
   305     }
       
   306   
   293   return rates;
   307   return rates;
   294 }
   308 }
   295 
   309 HtCapabilities
       
   310 ApWifiMac::GetHtCapabilities (void) const
       
   311 {
       
   312  HtCapabilities capabilities;
       
   313  capabilities.SetHtSupported(1);
       
   314  capabilities.SetLdpc (m_phy->GetLdpc());
       
   315  capabilities.SetShortGuardInterval20 (m_phy->GetGuardInterval());
       
   316  capabilities.SetGreenfield (m_phy->GetGreenfield());
       
   317  for (uint8_t i =0 ; i < m_phy->GetNMcs();i++)
       
   318   {
       
   319      capabilities.SetRxMcsBitmask(m_phy->GetMcs(i));
       
   320   }
       
   321  return capabilities;
       
   322 }
   296 void
   323 void
   297 ApWifiMac::SendProbeResp (Mac48Address to)
   324 ApWifiMac::SendProbeResp (Mac48Address to)
   298 {
   325 {
   299   NS_LOG_FUNCTION (this << to);
   326   NS_LOG_FUNCTION (this << to);
   300   WifiMacHeader hdr;
   327   WifiMacHeader hdr;
   307   Ptr<Packet> packet = Create<Packet> ();
   334   Ptr<Packet> packet = Create<Packet> ();
   308   MgtProbeResponseHeader probe;
   335   MgtProbeResponseHeader probe;
   309   probe.SetSsid (GetSsid ());
   336   probe.SetSsid (GetSsid ());
   310   probe.SetSupportedRates (GetSupportedRates ());
   337   probe.SetSupportedRates (GetSupportedRates ());
   311   probe.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
   338   probe.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
       
   339 if (m_htSupported)
       
   340     {
       
   341       probe.SetHtCapabilities (GetHtCapabilities());
       
   342       hdr.SetNoOrder();
       
   343     }
   312   packet->AddHeader (probe);
   344   packet->AddHeader (probe);
   313 
   345 
   314   // The standard is not clear on the correct queue for management
   346   // The standard is not clear on the correct queue for management
   315   // frames if we are a QoS AP. The approach taken here is to always
   347   // frames if we are a QoS AP. The approach taken here is to always
   316   // use the DCF for these regardless of whether we have a QoS
   348   // use the DCF for these regardless of whether we have a QoS
   340     {
   372     {
   341       code.SetFailure ();
   373       code.SetFailure ();
   342     }
   374     }
   343   assoc.SetSupportedRates (GetSupportedRates ());
   375   assoc.SetSupportedRates (GetSupportedRates ());
   344   assoc.SetStatusCode (code);
   376   assoc.SetStatusCode (code);
       
   377 
       
   378  if (m_htSupported)
       
   379     {
       
   380       assoc.SetHtCapabilities (GetHtCapabilities());
       
   381       hdr.SetNoOrder();
       
   382     }
   345   packet->AddHeader (assoc);
   383   packet->AddHeader (assoc);
   346 
   384 
   347   // The standard is not clear on the correct queue for management
   385   // The standard is not clear on the correct queue for management
   348   // frames if we are a QoS AP. The approach taken here is to always
   386   // frames if we are a QoS AP. The approach taken here is to always
   349   // use the DCF for these regardless of whether we have a QoS
   387   // use the DCF for these regardless of whether we have a QoS
   365   Ptr<Packet> packet = Create<Packet> ();
   403   Ptr<Packet> packet = Create<Packet> ();
   366   MgtBeaconHeader beacon;
   404   MgtBeaconHeader beacon;
   367   beacon.SetSsid (GetSsid ());
   405   beacon.SetSsid (GetSsid ());
   368   beacon.SetSupportedRates (GetSupportedRates ());
   406   beacon.SetSupportedRates (GetSupportedRates ());
   369   beacon.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
   407   beacon.SetBeaconIntervalUs (m_beaconInterval.GetMicroSeconds ());
   370 
   408   if (m_htSupported)
       
   409     {
       
   410       beacon.SetHtCapabilities (GetHtCapabilities());
       
   411       hdr.SetNoOrder();
       
   412     }
   371   packet->AddHeader (beacon);
   413   packet->AddHeader (beacon);
   372 
   414 
   373   // The beacon has it's own special queue, so we load it in there
   415   // The beacon has it's own special queue, so we load it in there
   374   m_beaconDca->Queue (packet, hdr);
   416   m_beaconDca->Queue (packet, hdr);
   375   m_beaconEvent = Simulator::Schedule (m_beaconInterval, &ApWifiMac::SendOneBeacon, this);
   417   m_beaconEvent = Simulator::Schedule (m_beaconInterval, &ApWifiMac::SendOneBeacon, this);
   504                     {
   546                     {
   505                       problem = true;
   547                       problem = true;
   506                       break;
   548                       break;
   507                     }
   549                     }
   508                 }
   550                 }
       
   551                if (m_htSupported)
       
   552                     {//check that the STA supports all MCSs in Basic MCS Set
       
   553                       HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
       
   554                       for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
       
   555                         {
       
   556                           uint8_t mcs = m_stationManager->GetBasicMcs (i);
       
   557                           if (!htcapabilities.IsSupportedMcs (mcs))
       
   558                             {
       
   559                               problem = true;
       
   560                               break;
       
   561                             }
       
   562                          }
       
   563                       
       
   564                      }
   509               if (problem)
   565               if (problem)
   510                 {
   566                 {
   511                   // one of the Basic Rate set mode is not
   567                   // one of the Basic Rate set mode is not
   512                   // supported by the station. So, we return an assoc
   568                   // supported by the station. So, we return an assoc
   513                   // response with an error status.
   569                   // response with an error status.
   523                       if (rates.IsSupportedRate (mode.GetDataRate ()))
   579                       if (rates.IsSupportedRate (mode.GetDataRate ()))
   524                         {
   580                         {
   525                           m_stationManager->AddSupportedMode (from, mode);
   581                           m_stationManager->AddSupportedMode (from, mode);
   526                         }
   582                         }
   527                     }
   583                     }
       
   584                    if (m_htSupported)
       
   585                     {
       
   586                       HtCapabilities htcapabilities = assocReq.GetHtCapabilities ();
       
   587                       m_stationManager->AddStationHtCapabilities (from,htcapabilities);
       
   588                       for (uint32_t j = 0; j < m_phy->GetNMcs (); j++)
       
   589                        {
       
   590                          uint8_t mcs = m_phy->GetMcs (j);
       
   591                          if (htcapabilities.IsSupportedMcs (mcs))
       
   592                            {
       
   593                              m_stationManager->AddSupportedMcs (from, mcs);
       
   594                            }
       
   595                         }
       
   596                      }
   528                   m_stationManager->RecordWaitAssocTxOk (from);
   597                   m_stationManager->RecordWaitAssocTxOk (from);
   529                   // send assoc response with success status.
   598                   // send assoc response with success status.
   530                   SendAssocResp (hdr->GetAddr2 (), true);
   599                   SendAssocResp (hdr->GetAddr2 (), true);
   531                 }
   600                 }
   532               return;
   601               return;