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

(-)a/src/wifi/model/ap-wifi-mac.cc (-25 / +85 lines)
 Lines 92-97   ApWifiMac::ApWifiMac () Link Here 
92
92
93
  //Let the lower layers know that we are acting as an AP.
93
  //Let the lower layers know that we are acting as an AP.
94
  SetTypeOfStation (AP);
94
  SetTypeOfStation (AP);
95
  m_nextAid = 1; //0 is excluded
95
}
96
}
96
97
97
ApWifiMac::~ApWifiMac ()
98
ApWifiMac::~ApWifiMac ()
 Lines 200-208   ApWifiMac::GetShortSlotTimeEnabled (void) const Link Here 
200
    }
201
    }
201
  if (m_erpSupported == true && GetShortSlotTimeSupported () == true)
202
  if (m_erpSupported == true && GetShortSlotTimeSupported () == true)
202
    {
203
    {
203
      for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
204
      for (std::map<Mac48Address, uint16_t>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
204
        {
205
        {
205
          if (m_stationManager->GetShortSlotTimeSupported (*i) == false)
206
          if (m_stationManager->GetShortSlotTimeSupported (i->first) == false)
206
            {
207
            {
207
              return false;
208
              return false;
208
            }
209
            }
 Lines 233-241   bool Link Here 
233
ApWifiMac::IsNonGfHtStasPresent (void) const
234
ApWifiMac::IsNonGfHtStasPresent (void) const
234
{
235
{
235
  bool isNonGfHtStasPresent = false;
236
  bool isNonGfHtStasPresent = false;
236
  for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
237
  for (std::map<Mac48Address, uint16_t>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
237
    {
238
    {
238
      if (m_stationManager->GetGreenfieldSupported (*i) == false)
239
      if (m_stationManager->GetGreenfieldSupported (i->first) == false)
239
        {
240
        {
240
          isNonGfHtStasPresent = true;
241
          isNonGfHtStasPresent = true;
241
          break;
242
          break;
 Lines 249-261   uint8_t Link Here 
249
ApWifiMac::GetVhtOperationalChannelWidth (void) const
250
ApWifiMac::GetVhtOperationalChannelWidth (void) const
250
{
251
{
251
  uint8_t channelWidth = m_phy->GetChannelWidth ();
252
  uint8_t channelWidth = m_phy->GetChannelWidth ();
252
  for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
253
  for (std::map<Mac48Address, uint16_t>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
253
    {
254
    {
254
      if (m_stationManager->GetVhtSupported (*i))
255
      if (m_stationManager->GetVhtSupported (i->first))
255
        {
256
        {
256
          if (m_stationManager->GetChannelWidthSupported (*i) < channelWidth)
257
          if (m_stationManager->GetChannelWidthSupported (i->first) < channelWidth)
257
            {
258
            {
258
              channelWidth = m_stationManager->GetChannelWidthSupported (*i);
259
              channelWidth = m_stationManager->GetChannelWidthSupported (i->first);
259
            }
260
            }
260
        }
261
        }
261
    }
262
    }
 Lines 555-566   ApWifiMac::GetHtOperation (void) const Link Here 
555
        }
556
        }
556
      uint8_t maxSpatialStream = m_phy->GetMaxSupportedTxSpatialStreams ();
557
      uint8_t maxSpatialStream = m_phy->GetMaxSupportedTxSpatialStreams ();
557
      uint8_t nMcs = m_phy->GetNMcs ();
558
      uint8_t nMcs = m_phy->GetNMcs ();
558
      for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
559
      for (std::map<Mac48Address, uint16_t>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
559
        {
560
        {
560
          if (m_stationManager->GetHtSupported (*i))
561
          if (m_stationManager->GetHtSupported (i->first))
561
            {
562
            {
562
              uint64_t maxSupportedRateByHtSta = 0; //in bit/s
563
              uint64_t maxSupportedRateByHtSta = 0; //in bit/s
563
              for (uint8_t j = 0; j < (std::min (nMcs, m_stationManager->GetNMcsSupported (*i))); j++)
564
              for (uint8_t j = 0; j < (std::min (nMcs, m_stationManager->GetNMcsSupported (i->first))); j++)
564
                {
565
                {
565
                  WifiMode mcs = m_phy->GetMcs (j);
566
                  WifiMode mcs = m_phy->GetMcs (j);
566
                  if (mcs.GetModulationClass () != WIFI_MOD_CLASS_HT)
567
                  if (mcs.GetModulationClass () != WIFI_MOD_CLASS_HT)
 Lines 569-575   ApWifiMac::GetHtOperation (void) const Link Here 
569
                    }
570
                    }
570
                  uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
571
                  uint8_t nss = (mcs.GetMcsValue () / 8) + 1;
571
                  NS_ASSERT (nss > 0 && nss < 5);
572
                  NS_ASSERT (nss > 0 && nss < 5);
572
                  uint64_t dataRate = mcs.GetDataRate (m_stationManager->GetChannelWidthSupported (*i), m_stationManager->GetShortGuardInterval (*i) ? 400 : 800, nss);
573
                  uint64_t dataRate = mcs.GetDataRate (m_stationManager->GetChannelWidthSupported (i->first), m_stationManager->GetShortGuardInterval (i->first) ? 400 : 800, nss);
573
                  if (dataRate > maxSupportedRateByHtSta)
574
                  if (dataRate > maxSupportedRateByHtSta)
574
                    {
575
                    {
575
                      maxSupportedRateByHtSta = dataRate;
576
                      maxSupportedRateByHtSta = dataRate;
 Lines 579-591   ApWifiMac::GetHtOperation (void) const Link Here 
579
                {
580
                {
580
                  maxSupportedRate = maxSupportedRateByHtSta;
581
                  maxSupportedRate = maxSupportedRateByHtSta;
581
                }
582
                }
582
              if (m_stationManager->GetNMcsSupported (*i) < nMcs)
583
              if (m_stationManager->GetNMcsSupported (i->first) < nMcs)
583
                {
584
                {
584
                  nMcs = m_stationManager->GetNMcsSupported (*i);
585
                  nMcs = m_stationManager->GetNMcsSupported (i->first);
585
                }
586
                }
586
              if (m_stationManager->GetNumberOfSupportedStreams (*i) < maxSpatialStream)
587
              if (m_stationManager->GetNumberOfSupportedStreams (i->first) < maxSpatialStream)
587
                {
588
                {
588
                  maxSpatialStream = m_stationManager->GetNumberOfSupportedStreams (*i);
589
                  maxSpatialStream = m_stationManager->GetNumberOfSupportedStreams (i->first);
589
                }
590
                }
590
            }
591
            }
591
        }
592
        }
 Lines 736-742   ApWifiMac::SendAssocResp (Mac48Address to, bool success) Link Here 
736
  if (success)
737
  if (success)
737
    {
738
    {
738
      code.SetSuccess ();
739
      code.SetSuccess ();
739
      m_staList.push_back (to);
740
      uint16_t aid = AllocateAid (to);
741
      assoc.SetAid (aid);
740
    }
742
    }
741
  else
743
  else
742
    {
744
    {
 Lines 1147-1160   ApWifiMac::Receive (Ptr<Packet> packet, const WifiMacHeader *hdr) Link Here 
1147
          else if (hdr->IsDisassociation ())
1149
          else if (hdr->IsDisassociation ())
1148
            {
1150
            {
1149
              m_stationManager->RecordDisassociated (from);
1151
              m_stationManager->RecordDisassociated (from);
1150
              for (std::list<Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
1152
              DeallocateAid (from);
1151
                {
1152
                  if ((*i) == from)
1153
                    {
1154
                      m_staList.erase (i);
1155
                      break;
1156
                    }
1157
                }
1158
              for (std::list<Mac48Address>::const_iterator j = m_nonErpStations.begin (); j != m_nonErpStations.end (); j++)
1153
              for (std::list<Mac48Address>::const_iterator j = m_nonErpStations.begin (); j != m_nonErpStations.end (); j++)
1159
                {
1154
                {
1160
                  if ((*j) == from)
1155
                  if ((*j) == from)
 Lines 1261-1264   ApWifiMac::GetRifsMode (void) const Link Here 
1261
  return rifsMode;
1256
  return rifsMode;
1262
}
1257
}
1263
1258
1259
uint16_t
1260
ApWifiMac::GetNextAid (void)
1261
{
1262
  NS_LOG_FUNCTION (this);
1263
  uint16_t retval = m_nextAid++;
1264
  NS_ASSERT (retval != 0 && retval <= 2007); // values given for non-DMG stations (802.11-2016 section 9.4.1.8.))
1265
  return retval;
1266
}
1267
1268
uint16_t
1269
ApWifiMac::GetAidByAddress (Mac48Address addr) const
1270
{
1271
  std::map<Mac48Address, uint16_t>::const_iterator i = m_staList.find (addr);
1272
  if (i != m_staList.end ())
1273
    {
1274
      return i->second;
1275
    }
1276
  return 0;
1277
}
1278
1279
Mac48Address
1280
ApWifiMac::GetAddressByAid (uint16_t aid) const
1281
{
1282
  for (std::map<Mac48Address, uint16_t>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
1283
    {
1284
      if (i->second == aid)
1285
        {
1286
          return i->first;
1287
        }
1288
    }
1289
  return Mac48Address::GetBroadcast ();
1290
}
1291
1292
bool
1293
ApWifiMac::IsAllocated (uint16_t aid) const
1294
{
1295
  for (std::map<Mac48Address, uint16_t>::const_iterator i = m_staList.begin (); i != m_staList.end (); i++)
1296
    {
1297
      if (i->second == aid)
1298
        {
1299
          return true;
1300
        }
1301
    }
1302
  return false;
1303
}
1304
1305
uint16_t
1306
ApWifiMac::AllocateAid (Mac48Address addr)
1307
{
1308
  NS_LOG_FUNCTION (this << addr);
1309
  uint16_t aid = GetNextAid ();
1310
  NS_ASSERT (!IsAllocated (aid));
1311
  m_staList[addr] = aid;
1312
  return aid;
1313
}
1314
1315
void
1316
ApWifiMac::DeallocateAid (Mac48Address addr)
1317
{
1318
  NS_LOG_FUNCTION (this << addr);
1319
  NS_ASSERT (m_staList.find (addr) != m_staList.end ());
1320
  m_staList.erase (addr);
1321
}
1322
1323
1264
} //namespace ns3
1324
} //namespace ns3
(-)a/src/wifi/model/ap-wifi-mac.h (-2 / +38 lines)
 Lines 139-145   public: Link Here 
139
   * \return the number of stream indices assigned by this model
139
   * \return the number of stream indices assigned by this model
140
   */
140
   */
141
  int64_t AssignStreams (int64_t stream);
141
  int64_t AssignStreams (int64_t stream);
142
142
  /**
143
   * Get the Association ID allocated to a given station.
144
   *
145
   * \param addr the MAC address of the station.
146
   * \return the AID the station.
147
   */
148
  uint16_t GetAidByAddress (Mac48Address addr) const;
149
  /**
150
   * Get the MAC address of a station knowing its Association ID.
151
   *
152
   * \param aid The AID of the station.
153
   * \return the MAC address of the station.
154
   */
155
  Mac48Address GetAddressByAid (uint16_t aid) const;
156
  /**
157
   * \return whether the specified AID is already allocated to a station.
158
   */
159
  bool IsAllocated (uint16_t aid) const;
143
160
144
private:
161
private:
145
  void Receive (Ptr<Packet> packet, const WifiMacHeader *hdr);
162
  void Receive (Ptr<Packet> packet, const WifiMacHeader *hdr);
 Lines 289-305   private: Link Here 
289
  void DoDispose (void);
306
  void DoDispose (void);
290
  void DoInitialize (void);
307
  void DoInitialize (void);
291
308
309
  /**
310
   * \return the next AID that will be allocated by the AP
311
   */
312
  uint16_t GetNextAid (void);
313
  /**
314
   * Allocate an AID to a station and store its MAC address along with this AID.
315
   *
316
   * \param addr the MAC address of the station
317
   * \return The allocated AID
318
   */
319
  uint16_t AllocateAid (Mac48Address addr);
320
  /**
321
   * Deallocate an AID for a station and remove it from the station list.
322
   *
323
   * \param addr the MAC address of the STA
324
   */
325
  void DeallocateAid (Mac48Address addr);
326
292
  Ptr<DcaTxop> m_beaconDca;                  //!< Dedicated DcaTxop for beacons
327
  Ptr<DcaTxop> m_beaconDca;                  //!< Dedicated DcaTxop for beacons
293
  Time m_beaconInterval;                     //!< Interval between beacons
328
  Time m_beaconInterval;                     //!< Interval between beacons
294
  bool m_enableBeaconGeneration;             //!< Flag whether beacons are being generated
329
  bool m_enableBeaconGeneration;             //!< Flag whether beacons are being generated
295
  EventId m_beaconEvent;                     //!< Event to generate one beacon
330
  EventId m_beaconEvent;                     //!< Event to generate one beacon
296
  Ptr<UniformRandomVariable> m_beaconJitter; //!< UniformRandomVariable used to randomize the time of the first beacon
331
  Ptr<UniformRandomVariable> m_beaconJitter; //!< UniformRandomVariable used to randomize the time of the first beacon
297
  bool m_enableBeaconJitter;                 //!< Flag whether the first beacon should be generated at random time
332
  bool m_enableBeaconJitter;                 //!< Flag whether the first beacon should be generated at random time
298
  std::list<Mac48Address> m_staList;         //!< List of all stations currently associated to the AP
333
  std::map<Mac48Address, uint16_t> m_staList;//!< Map of all stations currently associated to the AP with their association ID
299
  std::list<Mac48Address> m_nonErpStations;  //!< List of all non-ERP stations currently associated to the AP
334
  std::list<Mac48Address> m_nonErpStations;  //!< List of all non-ERP stations currently associated to the AP
300
  std::list<Mac48Address> m_nonHtStations;   //!< List of all non-HT stations currently associated to the AP
335
  std::list<Mac48Address> m_nonHtStations;   //!< List of all non-HT stations currently associated to the AP
301
  bool m_enableNonErpProtection;             //!< Flag whether protection mechanism is used or not when non-ERP STAs are present within the BSS
336
  bool m_enableNonErpProtection;             //!< Flag whether protection mechanism is used or not when non-ERP STAs are present within the BSS
302
  bool m_disableRifs;                        //!< Flag whether to force RIFS to be disabled within the BSS If non-HT STAs are detected
337
  bool m_disableRifs;                        //!< Flag whether to force RIFS to be disabled within the BSS If non-HT STAs are detected
338
  uint16_t m_nextAid;                        //!< Next Association ID to be allocated
303
};
339
};
304
340
305
} //namespace ns3
341
} //namespace ns3
(-)a/src/wifi/model/mgt-headers.cc (+13 lines)
 Lines 838-843   MgtAssocResponseHeader::GetEdcaParameterSet (void) const Link Here 
838
  return m_edcaParameterSet;
838
  return m_edcaParameterSet;
839
}
839
}
840
840
841
uint16_t
842
MgtAssocResponseHeader::GetAid (void) const
843
{
844
  return m_aid;
845
}
846
847
void
848
MgtAssocResponseHeader::SetAid (uint16_t aid)
849
{
850
  m_aid = aid;
851
}
852
841
TypeId
853
TypeId
842
MgtAssocResponseHeader::GetTypeId (void)
854
MgtAssocResponseHeader::GetTypeId (void)
843
{
855
{
 Lines 881-886   MgtAssocResponseHeader::Print (std::ostream &os) const Link Here 
881
{
893
{
882
  os << "status code=" << m_code << ", "
894
  os << "status code=" << m_code << ", "
883
     << "rates=" << m_rates << ", "
895
     << "rates=" << m_rates << ", "
896
     << "AID=" << m_aid << ", "
884
     << "ERP information=" << m_erpInformation << ", "
897
     << "ERP information=" << m_erpInformation << ", "
885
     << "HT Capabilities=" << m_htCapability << " , "
898
     << "HT Capabilities=" << m_htCapability << " , "
886
     << "HT Operation=" << m_htOperation << " , "
899
     << "HT Operation=" << m_htOperation << " , "
(-)a/src/wifi/model/mgt-headers.h (+12 lines)
 Lines 325-330   public: Link Here 
325
   * \param heoperation HE operation
325
   * \param heoperation HE operation
326
   */
326
   */
327
  void SetHeOperation (HeOperation heoperation);
327
  void SetHeOperation (HeOperation heoperation);
328
  /**
329
   * Return the association ID (AID) of the station.
330
   *
331
   * \return AID of the station
332
   */
333
  uint16_t GetAid (void) const;
334
  /**
335
   * Set the association ID (AID) of the station.
336
   *
337
   * \param aid AID of the station
338
   */
339
  void SetAid (uint16_t aid);
328
340
329
  /**
341
  /**
330
   * Register this type.
342
   * Register this type.

Return to bug 2848