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

(-)a/src/wifi/model/ap-wifi-mac.cc (-8 / +209 lines)
 Lines 719-729    Link Here 
719
}
719
}
720
720
721
void
721
void
722
ApWifiMac::SendAssocResp (Mac48Address to, bool success)
722
ApWifiMac::SendAssocResp (Mac48Address to, bool success, bool isReassoc)
723
{
723
{
724
  NS_LOG_FUNCTION (this << to << success);
724
  NS_LOG_FUNCTION (this << to << success);
725
  WifiMacHeader hdr;
725
  WifiMacHeader hdr;
726
  hdr.SetType (WIFI_MAC_MGT_ASSOCIATION_RESPONSE);
726
  hdr.SetType (isReassoc ? WIFI_MAC_MGT_REASSOCIATION_RESPONSE : WIFI_MAC_MGT_ASSOCIATION_RESPONSE);
727
  hdr.SetAddr1 (to);
727
  hdr.SetAddr1 (to);
728
  hdr.SetAddr2 (GetAddress ());
728
  hdr.SetAddr2 (GetAddress ());
729
  hdr.SetAddr3 (GetAddress ());
729
  hdr.SetAddr3 (GetAddress ());
 Lines 736-743    Link Here 
736
  if (success)
736
  if (success)
737
    {
737
    {
738
      code.SetSuccess ();
738
      code.SetSuccess ();
739
      uint16_t aid = GetNextAssociationId ();
739
      uint16_t aid;
740
      m_staList.insert (std::make_pair (aid, to));
740
      bool found = false;
741
      if (isReassoc)
742
        {
743
          for (std::map<uint16_t, Mac48Address>::const_iterator i = m_staList.begin (); i != m_staList.end (); ++i)
744
            {
745
              if (i->second == to)
746
                {
747
                      aid = i->first;
748
                      found = true;
749
                      break;
750
                }
751
            }
752
        }
753
      if (!found)
754
        {
755
          aid = GetNextAssociationId ();
756
          m_staList.insert (std::make_pair (aid, to));
757
        }
741
      assoc.SetAssociationId (aid);
758
      assoc.SetAssociationId (aid);
742
    }
759
    }
743
  else
760
  else
 Lines 858-864    Link Here 
858
  NS_LOG_FUNCTION (this);
875
  NS_LOG_FUNCTION (this);
859
  RegularWifiMac::TxOk (hdr);
876
  RegularWifiMac::TxOk (hdr);
860
877
861
  if (hdr.IsAssocResp ()
878
  if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
862
      && m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ()))
879
      && m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ()))
863
    {
880
    {
864
      NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
881
      NS_LOG_DEBUG ("associated with sta=" << hdr.GetAddr1 ());
 Lines 872-878    Link Here 
872
  NS_LOG_FUNCTION (this);
889
  NS_LOG_FUNCTION (this);
873
  RegularWifiMac::TxFailed (hdr);
890
  RegularWifiMac::TxFailed (hdr);
874
891
875
  if (hdr.IsAssocResp ()
892
  if ((hdr.IsAssocResp () || hdr.IsReassocResp ())
876
      && m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ()))
893
      && m_stationManager->IsWaitAssocTxOk (hdr.GetAddr1 ()))
877
    {
894
    {
878
      NS_LOG_DEBUG ("assoc failed with sta=" << hdr.GetAddr1 ());
895
      NS_LOG_DEBUG ("assoc failed with sta=" << hdr.GetAddr1 ());
 Lines 1077-1083    Link Here 
1077
                  //One of the Basic Rate set mode is not
1094
                  //One of the Basic Rate set mode is not
1078
                  //supported by the station. So, we return an assoc
1095
                  //supported by the station. So, we return an assoc
1079
                  //response with an error status.
1096
                  //response with an error status.
1080
                  SendAssocResp (hdr->GetAddr2 (), false);
1097
                  SendAssocResp (hdr->GetAddr2 (), false, false);
1081
                }
1098
                }
1082
              else
1099
              else
1083
                {
1100
                {
 Lines 1136-1148    Link Here 
1136
                  if (!isHtStation)
1153
                  if (!isHtStation)
1137
                    {
1154
                    {
1138
                      m_nonHtStations.push_back (hdr->GetAddr2 ());
1155
                      m_nonHtStations.push_back (hdr->GetAddr2 ());
1156
                      m_nonHtStations.unique ();
1139
                    }
1157
                    }
1140
                  if (!isErpStation && isDsssStation)
1158
                  if (!isErpStation && isDsssStation)
1141
                    {
1159
                    {
1142
                      m_nonErpStations.push_back (hdr->GetAddr2 ());
1160
                      m_nonErpStations.push_back (hdr->GetAddr2 ());
1161
                      m_nonErpStations.unique ();
1143
                    }
1162
                    }
1144
                  // send assoc response with success status.
1163
                  // send assoc response with success status.
1145
                  SendAssocResp (hdr->GetAddr2 (), true);
1164
                  SendAssocResp (hdr->GetAddr2 (), true, false);
1165
                }
1166
              return;
1167
            }
1168
          else if (hdr->IsReassocReq ())
1169
            {
1170
              //first, verify that the the station's supported
1171
              //rate set is compatible with our Basic Rate set
1172
              MgtReassocRequestHeader reassocReq;
1173
              packet->RemoveHeader (reassocReq);
1174
              CapabilityInformation capabilities = reassocReq.GetCapabilities ();
1175
              m_stationManager->AddSupportedPlcpPreamble (from, capabilities.IsShortPreamble ());
1176
              SupportedRates rates = reassocReq.GetSupportedRates ();
1177
              bool problem = false;
1178
              bool isHtStation = false;
1179
              bool isOfdmStation = false;
1180
              bool isErpStation = false;
1181
              bool isDsssStation = false;
1182
              for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
1183
                {
1184
                  WifiMode mode = m_stationManager->GetBasicMode (i);
1185
                  if (!rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1186
                    {
1187
                      if ((mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS) || (mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS))
1188
                        {
1189
                          isDsssStation = false;
1190
                        }
1191
                      else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1192
                        {
1193
                          isErpStation = false;
1194
                        }
1195
                      else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1196
                        {
1197
                          isOfdmStation = false;
1198
                        }
1199
                      if (isDsssStation == false && isErpStation == false && isOfdmStation == false)
1200
                        {
1201
                          problem = true;
1202
                          break;
1203
                        }
1204
                    }
1205
                  else
1206
                    {
1207
                      if ((mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS) || (mode.GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS))
1208
                        {
1209
                          isDsssStation = true;
1210
                        }
1211
                      else if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM)
1212
                        {
1213
                          isErpStation = true;
1214
                        }
1215
                      else if (mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
1216
                        {
1217
                          isOfdmStation = true;
1218
                        }
1219
                    }
1220
                }
1221
              m_stationManager->AddSupportedErpSlotTime (from, capabilities.IsShortSlotTime () && isErpStation);
1222
              if (m_htSupported)
1223
                {
1224
                  //check whether the HT STA supports all MCSs in Basic MCS Set
1225
                  HtCapabilities htcapabilities = reassocReq.GetHtCapabilities ();
1226
                  if (htcapabilities.IsSupportedMcs (0))
1227
                    {
1228
                      isHtStation = true;
1229
                      for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1230
                        {
1231
                          WifiMode mcs = m_stationManager->GetBasicMcs (i);
1232
                          if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ()))
1233
                            {
1234
                              problem = true;
1235
                              break;
1236
                            }
1237
                        }
1238
                    }
1239
                }
1240
              if (m_vhtSupported)
1241
                {
1242
                  //check whether the VHT STA supports all MCSs in Basic MCS Set
1243
                  VhtCapabilities vhtcapabilities = reassocReq.GetVhtCapabilities ();
1244
                  if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0)
1245
                    {
1246
                      for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1247
                        {
1248
                          WifiMode mcs = m_stationManager->GetBasicMcs (i);
1249
                          if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1250
                            {
1251
                              problem = true;
1252
                              break;
1253
                            }
1254
                        }
1255
                    }
1256
                }
1257
              if (m_heSupported)
1258
                {
1259
                  //check whether the HE STA supports all MCSs in Basic MCS Set
1260
                  HeCapabilities hecapabilities = reassocReq.GetHeCapabilities ();
1261
                  if (hecapabilities.GetSupportedMcsAndNss () != 0)
1262
                    {
1263
                      for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++)
1264
                        {
1265
                          WifiMode mcs = m_stationManager->GetBasicMcs (i);
1266
                          if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1267
                            {
1268
                              problem = true;
1269
                              break;
1270
                            }
1271
                        }
1272
                    }
1273
                }
1274
              if (problem)
1275
                {
1276
                  //One of the Basic Rate set mode is not
1277
                  //supported by the station. So, we return an reassoc
1278
                  //response with an error status.
1279
                  SendAssocResp (hdr->GetAddr2 (), false, true);
1280
                }
1281
              else
1282
                {
1283
                  //station supports all rates in Basic Rate Set.
1284
                  //record all its supported modes in its associated WifiRemoteStation
1285
                  for (uint8_t j = 0; j < m_phy->GetNModes (); j++)
1286
                    {
1287
                      WifiMode mode = m_phy->GetMode (j);
1288
                      if (rates.IsSupportedRate (mode.GetDataRate (m_phy->GetChannelWidth ())))
1289
                        {
1290
                          m_stationManager->AddSupportedMode (from, mode);
1291
                        }
1292
                    }
1293
                  if (m_htSupported)
1294
                    {
1295
                      HtCapabilities htCapabilities = reassocReq.GetHtCapabilities ();
1296
                      if (htCapabilities.IsSupportedMcs (0))
1297
                        {
1298
                          m_stationManager->AddStationHtCapabilities (from, htCapabilities);
1299
                        }
1300
                    }
1301
                  if (m_vhtSupported)
1302
                    {
1303
                      VhtCapabilities vhtCapabilities = reassocReq.GetVhtCapabilities ();
1304
                      //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT
1305
                      if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0)
1306
                        {
1307
                          m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities);
1308
                          for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1309
                            {
1310
                              WifiMode mcs = m_phy->GetMcs (i);
1311
                              if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1312
                                {
1313
                                  m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1314
                                  //here should add a control to add basic MCS when it is implemented
1315
                                }
1316
                            }
1317
                        }
1318
                    }
1319
                  if (m_heSupported)
1320
                    {
1321
                      HeCapabilities heCapabilities = reassocReq.GetHeCapabilities ();
1322
                      //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer
1323
                      m_stationManager->AddStationHeCapabilities (from, heCapabilities);
1324
                      for (uint8_t i = 0; i < m_phy->GetNMcs (); i++)
1325
                        {
1326
                          WifiMode mcs = m_phy->GetMcs (i);
1327
                          if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ()))
1328
                            {
1329
                              m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs);
1330
                              //here should add a control to add basic MCS when it is implemented
1331
                            }
1332
                        }
1333
                    }
1334
                  m_stationManager->RecordWaitAssocTxOk (from);
1335
                  if (!isHtStation)
1336
                    {
1337
                      m_nonHtStations.push_back (hdr->GetAddr2 ());
1338
                      m_nonHtStations.unique ();
1339
                    }
1340
                  if (!isErpStation && isDsssStation)
1341
                    {
1342
                      m_nonErpStations.push_back (hdr->GetAddr2 ());
1343
                      m_nonErpStations.unique ();
1344
                    }
1345
                  // send reassoc response with success status.
1346
                  SendAssocResp (hdr->GetAddr2 (), true, true);
1146
                }
1347
                }
1147
              return;
1348
              return;
1148
            }
1349
            }
(-)a/src/wifi/model/ap-wifi-mac.h (-3 / +5 lines)
 Lines 199-211    Link Here 
199
   */
199
   */
200
  void SendProbeResp (Mac48Address to);
200
  void SendProbeResp (Mac48Address to);
201
  /**
201
  /**
202
   * Forward an association response packet to the DCF. The standard is not clear on the correct
202
   * Forward an association or a reassociation response packet to the DCF.
203
   * queue for management frames if QoS is supported. We always use the DCF.
203
   * The standard is not clear on the correct queue for management frames if QoS is supported.
204
   * We always use the DCF.
204
   *
205
   *
205
   * \param to the address of the STA we are sending an association response to
206
   * \param to the address of the STA we are sending an association response to
206
   * \param success indicates whether the association was successful or not
207
   * \param success indicates whether the association was successful or not
208
   * \param isReassoc indicates whether it is a reassociation response
207
   */
209
   */
208
  void SendAssocResp (Mac48Address to, bool success);
210
  void SendAssocResp (Mac48Address to, bool success, bool isReassoc);
209
  /**
211
  /**
210
   * Forward a beacon packet to the beacon special DCF.
212
   * Forward a beacon packet to the beacon special DCF.
211
   */
213
   */
(-)a/src/wifi/model/mgt-headers.cc (-1 / +197 lines)
 Lines 686-692    Link Here 
686
686
687
687
688
/***********************************************************
688
/***********************************************************
689
 *          Assoc Response
689
 *          Ressoc Request
690
 ***********************************************************/
691
692
NS_OBJECT_ENSURE_REGISTERED (MgtReassocRequestHeader);
693
694
MgtReassocRequestHeader::MgtReassocRequestHeader ()
695
  : m_currentApAddr (Mac48Address ())
696
{
697
}
698
699
MgtReassocRequestHeader::~MgtReassocRequestHeader ()
700
{
701
}
702
703
void
704
MgtReassocRequestHeader::SetSsid (Ssid ssid)
705
{
706
  m_ssid = ssid;
707
}
708
709
void
710
MgtReassocRequestHeader::SetSupportedRates (SupportedRates rates)
711
{
712
  m_rates = rates;
713
}
714
715
void
716
MgtReassocRequestHeader::SetListenInterval (uint16_t interval)
717
{
718
  m_listenInterval = interval;
719
}
720
721
void
722
MgtReassocRequestHeader::SetCapabilities (CapabilityInformation capabilities)
723
{
724
  m_capability = capabilities;
725
}
726
727
CapabilityInformation
728
MgtReassocRequestHeader::GetCapabilities (void) const
729
{
730
  return m_capability;
731
}
732
733
void
734
MgtReassocRequestHeader::SetExtendedCapabilities (ExtendedCapabilities extendedcapabilities)
735
{
736
  m_extendedCapability = extendedcapabilities;
737
}
738
739
ExtendedCapabilities
740
MgtReassocRequestHeader::GetExtendedCapabilities (void) const
741
{
742
  return m_extendedCapability;
743
}
744
745
void
746
MgtReassocRequestHeader::SetHtCapabilities (HtCapabilities htcapabilities)
747
{
748
  m_htCapability = htcapabilities;
749
}
750
751
HtCapabilities
752
MgtReassocRequestHeader::GetHtCapabilities (void) const
753
{
754
  return m_htCapability;
755
}
756
757
void
758
MgtReassocRequestHeader::SetVhtCapabilities (VhtCapabilities vhtcapabilities)
759
{
760
  m_vhtCapability = vhtcapabilities;
761
}
762
763
VhtCapabilities
764
MgtReassocRequestHeader::GetVhtCapabilities (void) const
765
{
766
  return m_vhtCapability;
767
}
768
769
void
770
MgtReassocRequestHeader::SetHeCapabilities (HeCapabilities hecapabilities)
771
{
772
  m_heCapability = hecapabilities;
773
}
774
775
HeCapabilities
776
MgtReassocRequestHeader::GetHeCapabilities (void) const
777
{
778
  return m_heCapability;
779
}
780
781
Ssid
782
MgtReassocRequestHeader::GetSsid (void) const
783
{
784
  return m_ssid;
785
}
786
787
SupportedRates
788
MgtReassocRequestHeader::GetSupportedRates (void) const
789
{
790
  return m_rates;
791
}
792
793
uint16_t
794
MgtReassocRequestHeader::GetListenInterval (void) const
795
{
796
  return m_listenInterval;
797
}
798
799
void
800
MgtReassocRequestHeader::SetCurrentApAddress (Mac48Address currentApAddr)
801
{
802
  m_currentApAddr = currentApAddr;
803
}
804
805
TypeId
806
MgtReassocRequestHeader::GetTypeId (void)
807
{
808
  static TypeId tid = TypeId ("ns3::MgtReassocRequestHeader")
809
    .SetParent<Header> ()
810
    .SetGroupName ("Wifi")
811
    .AddConstructor<MgtReassocRequestHeader> ()
812
  ;
813
  return tid;
814
}
815
816
TypeId
817
MgtReassocRequestHeader::GetInstanceTypeId (void) const
818
{
819
  return GetTypeId ();
820
}
821
822
uint32_t
823
MgtReassocRequestHeader::GetSerializedSize (void) const
824
{
825
  uint32_t size = 0;
826
  size += m_capability.GetSerializedSize ();
827
  size += 2; //listen interval
828
  size += 6; //current AP address
829
  size += m_ssid.GetSerializedSize ();
830
  size += m_rates.GetSerializedSize ();
831
  size += m_rates.extended.GetSerializedSize ();
832
  size += m_extendedCapability.GetSerializedSize ();
833
  size += m_htCapability.GetSerializedSize ();
834
  size += m_vhtCapability.GetSerializedSize ();
835
  size += m_heCapability.GetSerializedSize ();
836
  return size;
837
}
838
839
void
840
MgtReassocRequestHeader::Print (std::ostream &os) const
841
{
842
  os << "current AP address=" << m_currentApAddr << ", "
843
     << "ssid=" << m_ssid << ", "
844
     << "rates=" << m_rates << ", "
845
     << "HT Capabilities=" << m_htCapability << " , "
846
     << "VHT Capabilities=" << m_vhtCapability << " , "
847
     << "HE Capabilities=" << m_heCapability;
848
}
849
850
void
851
MgtReassocRequestHeader::Serialize (Buffer::Iterator start) const
852
{
853
  Buffer::Iterator i = start;
854
  i = m_capability.Serialize (i);
855
  i.WriteHtolsbU16 (m_listenInterval);
856
  WriteTo (i, m_currentApAddr);
857
  i = m_ssid.Serialize (i);
858
  i = m_rates.Serialize (i);
859
  i = m_rates.extended.Serialize (i);
860
  i = m_extendedCapability.Serialize (i);
861
  i = m_htCapability.Serialize (i);
862
  i = m_vhtCapability.Serialize (i);
863
  i = m_heCapability.Serialize (i);
864
}
865
866
uint32_t
867
MgtReassocRequestHeader::Deserialize (Buffer::Iterator start)
868
{
869
  Buffer::Iterator i = start;
870
  i = m_capability.Deserialize (i);
871
  m_listenInterval = i.ReadLsbtohU16 ();
872
  ReadFrom (i, m_currentApAddr);
873
  i = m_ssid.Deserialize (i);
874
  i = m_rates.Deserialize (i);
875
  i = m_rates.extended.DeserializeIfPresent (i);
876
  i = m_extendedCapability.DeserializeIfPresent (i);
877
  i = m_htCapability.DeserializeIfPresent (i);
878
  i = m_vhtCapability.DeserializeIfPresent (i);
879
  i = m_heCapability.DeserializeIfPresent (i);
880
  return i.GetDistanceFrom (start);
881
}
882
883
884
/***********************************************************
885
 *          Assoc/Reassoc Response
690
 ***********************************************************/
886
 ***********************************************************/
691
887
692
NS_OBJECT_ENSURE_REGISTERED (MgtAssocResponseHeader);
888
NS_OBJECT_ENSURE_REGISTERED (MgtAssocResponseHeader);
(-)a/src/wifi/model/mgt-headers.h (-1 / +140 lines)
 Lines 37-42    Link Here 
37
#include "edca-parameter-set.h"
37
#include "edca-parameter-set.h"
38
#include "he-capabilities.h"
38
#include "he-capabilities.h"
39
#include "he-operation.h"
39
#include "he-operation.h"
40
#include "ns3/address-utils.h"
40
41
41
namespace ns3 {
42
namespace ns3 {
42
43
 Lines 173-179    Link Here 
173
174
174
/**
175
/**
175
 * \ingroup wifi
176
 * \ingroup wifi
176
 * Implement the header for management frames of type association response.
177
 * Implement the header for management frames of type reassociation request.
178
 */
179
class MgtReassocRequestHeader : public Header
180
{
181
public:
182
  MgtReassocRequestHeader ();
183
  ~MgtReassocRequestHeader ();
184
185
  /**
186
   * Set the Service Set Identifier (SSID).
187
   *
188
   * \param ssid SSID
189
   */
190
  void SetSsid (Ssid ssid);
191
  /**
192
   * Set the supported rates.
193
   *
194
   * \param rates the supported rates
195
   */
196
  void SetSupportedRates (SupportedRates rates);
197
  /**
198
   * Set the listen interval.
199
   *
200
   * \param interval the listen interval
201
   */
202
  void SetListenInterval (uint16_t interval);
203
  /**
204
   * Set the Capability information.
205
   *
206
   * \param capabilities Capability information
207
   */
208
  void SetCapabilities (CapabilityInformation capabilities);
209
  /**
210
   * Set the Extended Capabilities.
211
   *
212
   * \param extendedcapabilities the Extended Capabilities
213
   */
214
  void SetExtendedCapabilities (ExtendedCapabilities extendedcapabilities);
215
  /**
216
   * Set the HT capabilities.
217
   *
218
   * \param htcapabilities HT capabilities
219
   */
220
  void SetHtCapabilities (HtCapabilities htcapabilities);
221
  /**
222
   * Set the VHT capabilities.
223
   *
224
   * \param vhtcapabilities VHT capabilities
225
   */
226
  void SetVhtCapabilities (VhtCapabilities vhtcapabilities);
227
  /**
228
   * Set the HE capabilities.
229
   *
230
   * \param hecapabilities HE capabilities
231
   */
232
  void SetHeCapabilities (HeCapabilities hecapabilities);
233
  /**
234
   * Return the Capability information.
235
   *
236
   * \return Capability information
237
   */
238
  CapabilityInformation GetCapabilities (void) const;
239
  /**
240
   * Return the extended capabilities.
241
   *
242
   * \return the extended capabilities
243
   */
244
  ExtendedCapabilities GetExtendedCapabilities (void) const;
245
  /**
246
   * Return the HT capabilities.
247
   *
248
   * \return HT capabilities
249
   */
250
  HtCapabilities GetHtCapabilities (void) const;
251
  /**
252
   * Return the VHT capabilities.
253
   *
254
   * \return VHT capabilities
255
   */
256
  VhtCapabilities GetVhtCapabilities (void) const;
257
  /**
258
   * Return the HE capabilities.
259
   *
260
   * \return HE capabilities
261
   */
262
  HeCapabilities GetHeCapabilities (void) const;
263
  /**
264
   * Return the Service Set Identifier (SSID).
265
   *
266
   * \return SSID
267
   */
268
  Ssid GetSsid (void) const;
269
  /**
270
   * Return the supported rates.
271
   *
272
   * \return the supported rates
273
   */
274
  SupportedRates GetSupportedRates (void) const;
275
  /**
276
   * Return the listen interval.
277
   *
278
   * \return the listen interval
279
   */
280
  uint16_t GetListenInterval (void) const;
281
  /**
282
   * Set the address of the current access point.
283
   *
284
   * \param currentApAddr address of the current access point
285
   */
286
  void SetCurrentApAddress (Mac48Address currentApAddr);
287
288
  /**
289
   * Register this type.
290
   * \return The TypeId.
291
   */
292
  static TypeId GetTypeId (void);
293
  TypeId GetInstanceTypeId (void) const;
294
  void Print (std::ostream &os) const;
295
  uint32_t GetSerializedSize (void) const;
296
  void Serialize (Buffer::Iterator start) const;
297
  uint32_t Deserialize (Buffer::Iterator start);
298
299
300
private:
301
  Mac48Address m_currentApAddr;       //!< Address of the current access point
302
  Ssid m_ssid;                        //!< Service Set ID (SSID)
303
  SupportedRates m_rates;             //!< List of supported rates
304
  CapabilityInformation m_capability; //!< Capability information
305
  ExtendedCapabilities m_extendedCapability; //!< Extended capabilities
306
  HtCapabilities m_htCapability;      //!< HT capabilities
307
  VhtCapabilities m_vhtCapability;    //!< VHT capabilities
308
  HeCapabilities m_heCapability;      //!< HE capabilities
309
  uint16_t m_listenInterval;          //!< listen interval
310
};
311
312
313
/**
314
 * \ingroup wifi
315
 * Implement the header for management frames of type association and reassociation response.
177
 */
316
 */
178
class MgtAssocResponseHeader : public Header
317
class MgtAssocResponseHeader : public Header
179
{
318
{
(-)a/src/wifi/model/regular-wifi-mac.h (-1 / +1 lines)
 Lines 216-222    Link Here 
216
  /**
216
  /**
217
   * \param phy the physical layer attached to this MAC.
217
   * \param phy the physical layer attached to this MAC.
218
   */
218
   */
219
  void SetWifiPhy (const Ptr<WifiPhy> phy);
219
  virtual void SetWifiPhy (const Ptr<WifiPhy> phy);
220
  /**
220
  /**
221
   * \return the physical layer attached to this MAC.
221
   * \return the physical layer attached to this MAC.
222
   */
222
   */
(-)a/src/wifi/model/sta-wifi-mac.cc (-23 / +68 lines)
 Lines 120-131    Link Here 
120
  m_activeProbing = enable;
120
  m_activeProbing = enable;
121
}
121
}
122
122
123
bool StaWifiMac::GetActiveProbing (void) const
123
bool
124
StaWifiMac::GetActiveProbing (void) const
124
{
125
{
125
  return m_activeProbing;
126
  return m_activeProbing;
126
}
127
}
127
128
128
void
129
void
130
StaWifiMac::SetWifiPhy (const Ptr<WifiPhy> phy)
131
{
132
  RegularWifiMac::SetWifiPhy (phy);
133
  m_phy->SetCapabilitiesChangedCallback (MakeCallback (&StaWifiMac::PhyCapabilitiesChanged, this));
134
}
135
136
void
129
StaWifiMac::SendProbeRequest (void)
137
StaWifiMac::SendProbeRequest (void)
130
{
138
{
131
  NS_LOG_FUNCTION (this);
139
  NS_LOG_FUNCTION (this);
 Lines 171-181    Link Here 
171
}
179
}
172
180
173
void
181
void
174
StaWifiMac::SendAssociationRequest (void)
182
StaWifiMac::SendAssociationRequest (bool isReassoc)
175
{
183
{
176
  NS_LOG_FUNCTION (this << GetBssid ());
184
  NS_LOG_FUNCTION (this << GetBssid () << isReassoc);
177
  WifiMacHeader hdr;
185
  WifiMacHeader hdr;
178
  hdr.SetType (WIFI_MAC_MGT_ASSOCIATION_REQUEST);
186
  hdr.SetType (isReassoc ? WIFI_MAC_MGT_REASSOCIATION_REQUEST : WIFI_MAC_MGT_ASSOCIATION_REQUEST);
179
  hdr.SetAddr1 (GetBssid ());
187
  hdr.SetAddr1 (GetBssid ());
180
  hdr.SetAddr2 (GetAddress ());
188
  hdr.SetAddr2 (GetAddress ());
181
  hdr.SetAddr3 (GetBssid ());
189
  hdr.SetAddr3 (GetBssid ());
 Lines 183-206    Link Here 
183
  hdr.SetDsNotTo ();
191
  hdr.SetDsNotTo ();
184
  hdr.SetNoOrder ();
192
  hdr.SetNoOrder ();
185
  Ptr<Packet> packet = Create<Packet> ();
193
  Ptr<Packet> packet = Create<Packet> ();
186
  MgtAssocRequestHeader assoc;
194
  if (!isReassoc)
187
  assoc.SetSsid (GetSsid ());
188
  assoc.SetSupportedRates (GetSupportedRates ());
189
  assoc.SetCapabilities (GetCapabilities ());
190
  if (m_htSupported || m_vhtSupported || m_heSupported)
191
    {
195
    {
192
      assoc.SetExtendedCapabilities (GetExtendedCapabilities ());
196
      MgtAssocRequestHeader assoc;
193
      assoc.SetHtCapabilities (GetHtCapabilities ());
197
      assoc.SetSsid (GetSsid ());
198
      assoc.SetSupportedRates (GetSupportedRates ());
199
      assoc.SetCapabilities (GetCapabilities ());
200
      if (m_htSupported || m_vhtSupported || m_heSupported)
201
        {
202
          assoc.SetExtendedCapabilities (GetExtendedCapabilities ());
203
          assoc.SetHtCapabilities (GetHtCapabilities ());
204
        }
205
      if (m_vhtSupported || m_heSupported)
206
        {
207
          assoc.SetVhtCapabilities (GetVhtCapabilities ());
208
        }
209
      if (m_heSupported)
210
        {
211
          assoc.SetHeCapabilities (GetHeCapabilities ());
212
        }
213
      packet->AddHeader (assoc);
194
    }
214
    }
195
  if (m_vhtSupported || m_heSupported)
215
  else
196
    {
216
    {
197
      assoc.SetVhtCapabilities (GetVhtCapabilities ());
217
      MgtReassocRequestHeader reassoc;
218
      reassoc.SetCurrentApAddress (GetBssid ());
219
      reassoc.SetSsid (GetSsid ());
220
      reassoc.SetSupportedRates (GetSupportedRates ());
221
      reassoc.SetCapabilities (GetCapabilities ());
222
      if (m_htSupported || m_vhtSupported || m_heSupported)
223
        {
224
          reassoc.SetExtendedCapabilities (GetExtendedCapabilities ());
225
          reassoc.SetHtCapabilities (GetHtCapabilities ());
226
        }
227
      if (m_vhtSupported || m_heSupported)
228
        {
229
          reassoc.SetVhtCapabilities (GetVhtCapabilities ());
230
        }
231
      if (m_heSupported)
232
        {
233
          reassoc.SetHeCapabilities (GetHeCapabilities ());
234
        }
235
      packet->AddHeader (reassoc);
198
    }
236
    }
199
  if (m_heSupported)
200
    {
201
      assoc.SetHeCapabilities (GetHeCapabilities ());
202
    }
203
  packet->AddHeader (assoc);
204
237
205
  //The standard is not clear on the correct queue for management
238
  //The standard is not clear on the correct queue for management
206
  //frames if we are a QoS AP. The approach taken here is to always
239
  //frames if we are a QoS AP. The approach taken here is to always
 Lines 265-271    Link Here 
265
{
298
{
266
  NS_LOG_FUNCTION (this);
299
  NS_LOG_FUNCTION (this);
267
  SetState (WAIT_ASSOC_RESP);
300
  SetState (WAIT_ASSOC_RESP);
268
  SendAssociationRequest ();
301
  SendAssociationRequest (false);
269
}
302
}
270
303
271
void
304
void
 Lines 447-453    Link Here 
447
      return;
480
      return;
448
    }
481
    }
449
  else if (hdr->IsProbeReq ()
482
  else if (hdr->IsProbeReq ()
450
           || hdr->IsAssocReq ())
483
           || hdr->IsAssocReq ()
484
           || hdr->IsReassocReq ())
451
    {
485
    {
452
      //This is a frame aimed at an AP, so we can safely ignore it.
486
      //This is a frame aimed at an AP, so we can safely ignore it.
453
      NotifyRxDrop (packet);
487
      NotifyRxDrop (packet);
 Lines 608-614    Link Here 
608
      if (goodBeacon && m_state == BEACON_MISSED)
642
      if (goodBeacon && m_state == BEACON_MISSED)
609
        {
643
        {
610
          SetState (WAIT_ASSOC_RESP);
644
          SetState (WAIT_ASSOC_RESP);
611
          SendAssociationRequest ();
645
          SendAssociationRequest (false);
612
        }
646
        }
613
      return;
647
      return;
614
    }
648
    }
 Lines 692-702    Link Here 
692
              m_probeRequestEvent.Cancel ();
726
              m_probeRequestEvent.Cancel ();
693
            }
727
            }
694
          SetState (WAIT_ASSOC_RESP);
728
          SetState (WAIT_ASSOC_RESP);
695
          SendAssociationRequest ();
729
          SendAssociationRequest (false);
696
        }
730
        }
697
      return;
731
      return;
698
    }
732
    }
699
  else if (hdr->IsAssocResp ())
733
  else if (hdr->IsAssocResp () || hdr->IsReassocResp ())
700
    {
734
    {
701
      if (m_state == WAIT_ASSOC_RESP)
735
      if (m_state == WAIT_ASSOC_RESP)
702
        {
736
        {
 Lines 938-941    Link Here 
938
  edca->SetTxopLimit (txopLimit);
972
  edca->SetTxopLimit (txopLimit);
939
}
973
}
940
974
975
void
976
StaWifiMac::PhyCapabilitiesChanged (void)
977
{
978
  NS_LOG_FUNCTION (this);
979
  if (IsAssociated ())
980
    {
981
      SetState (WAIT_ASSOC_RESP);
982
      SendAssociationRequest (true);
983
    }
984
}
985
941
} //namespace ns3
986
} //namespace ns3
(-)a/src/wifi/model/sta-wifi-mac.h (-3 / +17 lines)
 Lines 58-63    Link Here 
58
   */
58
   */
59
  void Enqueue (Ptr<const Packet> packet, Mac48Address to);
59
  void Enqueue (Ptr<const Packet> packet, Mac48Address to);
60
60
61
  /**
62
   * \param phy the physical layer attached to this MAC.
63
   */
64
  void SetWifiPhy (const Ptr<WifiPhy> phy);
65
61
66
62
private:
67
private:
63
  /**
68
  /**
 Lines 93-102    Link Here 
93
   */
98
   */
94
  void SendProbeRequest (void);
99
  void SendProbeRequest (void);
95
  /**
100
  /**
96
   * Forward an association request packet to the DCF. The standard is not clear on the correct
101
   * Forward an association or reassociation request packet to the DCF.
97
   * queue for management frames if QoS is supported. We always use the DCF.
102
   * The standard is not clear on the correct queue for management frames if QoS is supported.
103
   * We always use the DCF.
104
   *
105
   * \param isReassoc flag whether it is a reassociation request
106
   *
98
   */
107
   */
99
  void SendAssociationRequest (void);
108
  void SendAssociationRequest (bool isReassoc);
100
  /**
109
  /**
101
   * Try to ensure that we are associated with an AP by taking an appropriate action
110
   * Try to ensure that we are associated with an AP by taking an appropriate action
102
   * depending on the current association status.
111
   * depending on the current association status.
 Lines 164-169    Link Here 
164
   */
173
   */
165
  CapabilityInformation GetCapabilities (void) const;
174
  CapabilityInformation GetCapabilities (void) const;
166
175
176
  /**
177
   * Indicate that PHY capabilities have changed.
178
   */
179
  void PhyCapabilitiesChanged (void);
180
167
  MacState m_state;            ///< MAC state
181
  MacState m_state;            ///< MAC state
168
  Time m_probeRequestTimeout;  ///< probe request timeout
182
  Time m_probeRequestTimeout;  ///< probe request timeout
169
  Time m_assocRequestTimeout;  ///< assoc request timeout
183
  Time m_assocRequestTimeout;  ///< assoc request timeout
(-)a/src/wifi/model/wifi-phy.cc (+22 lines)
 Lines 435-440    Link Here 
435
}
435
}
436
436
437
void
437
void
438
WifiPhy::SetCapabilitiesChangedCallback (Callback<void> callback)
439
{
440
  m_capabilitiesChangedCallback = callback;
441
}
442
443
void
438
WifiPhy::InitializeFrequencyChannelNumber (void)
444
WifiPhy::InitializeFrequencyChannelNumber (void)
439
{
445
{
440
  NS_LOG_FUNCTION (this);
446
  NS_LOG_FUNCTION (this);
 Lines 1267-1275    Link Here 
1267
void
1273
void
1268
WifiPhy::SetChannelWidth (uint8_t channelwidth)
1274
WifiPhy::SetChannelWidth (uint8_t channelwidth)
1269
{
1275
{
1276
  NS_LOG_FUNCTION (this << static_cast<uint16_t>(channelwidth));
1270
  NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 || channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth == 160, "wrong channel width value");
1277
  NS_ASSERT_MSG (channelwidth == 5 || channelwidth == 10 || channelwidth == 20 || channelwidth == 22 || channelwidth == 40 || channelwidth == 80 || channelwidth == 160, "wrong channel width value");
1278
  bool changed = (m_channelWidth == channelwidth);
1271
  m_channelWidth = channelwidth;
1279
  m_channelWidth = channelwidth;
1272
  AddSupportedChannelWidth (channelwidth);
1280
  AddSupportedChannelWidth (channelwidth);
1281
  if (changed && !m_capabilitiesChangedCallback.IsNull ())
1282
    {
1283
      m_capabilitiesChangedCallback ();
1284
    }
1273
}
1285
}
1274
1286
1275
uint8_t
1287
uint8_t
 Lines 1296-1303    Link Here 
1296
WifiPhy::SetMaxSupportedTxSpatialStreams (uint8_t streams)
1308
WifiPhy::SetMaxSupportedTxSpatialStreams (uint8_t streams)
1297
{
1309
{
1298
  NS_ASSERT (streams <= GetNumberOfAntennas ());
1310
  NS_ASSERT (streams <= GetNumberOfAntennas ());
1311
  bool changed = (m_txSpatialStreams == streams);
1299
  m_txSpatialStreams = streams;
1312
  m_txSpatialStreams = streams;
1300
  ConfigureHtDeviceMcsSet ();
1313
  ConfigureHtDeviceMcsSet ();
1314
  if (changed && !m_capabilitiesChangedCallback.IsNull ())
1315
    {
1316
      m_capabilitiesChangedCallback ();
1317
    }
1301
}
1318
}
1302
1319
1303
uint8_t
1320
uint8_t
 Lines 1310-1316    Link Here 
1310
WifiPhy::SetMaxSupportedRxSpatialStreams (uint8_t streams)
1327
WifiPhy::SetMaxSupportedRxSpatialStreams (uint8_t streams)
1311
{
1328
{
1312
  NS_ASSERT (streams <= GetNumberOfAntennas ());
1329
  NS_ASSERT (streams <= GetNumberOfAntennas ());
1330
  bool changed = (m_rxSpatialStreams == streams);
1313
  m_rxSpatialStreams = streams;
1331
  m_rxSpatialStreams = streams;
1332
  if (changed && !m_capabilitiesChangedCallback.IsNull ())
1333
    {
1334
      m_capabilitiesChangedCallback ();
1335
    }
1314
}
1336
}
1315
1337
1316
uint8_t
1338
uint8_t
(-)a/src/wifi/model/wifi-phy.h (+7 lines)
 Lines 258-263    Link Here 
258
  void UnregisterListener (WifiPhyListener *listener);
258
  void UnregisterListener (WifiPhyListener *listener);
259
259
260
  /**
260
  /**
261
   * \param callback the callback to invoke when PHY capabilities have changed.
262
   */
263
  void SetCapabilitiesChangedCallback (Callback<void> callback);
264
265
  /**
261
   * Starting receiving the plcp of a packet (i.e. the first bit of the preamble has arrived).
266
   * Starting receiving the plcp of a packet (i.e. the first bit of the preamble has arrived).
262
   *
267
   *
263
   * \param packet the arriving packet
268
   * \param packet the arriving packet
 Lines 1987-1992    Link Here 
1987
  Ptr<InterferenceHelper::Event> m_currentEvent; //!< Hold the current event
1992
  Ptr<InterferenceHelper::Event> m_currentEvent; //!< Hold the current event
1988
  Ptr<FrameCaptureModel> m_frameCaptureModel; //!< Frame capture model
1993
  Ptr<FrameCaptureModel> m_frameCaptureModel; //!< Frame capture model
1989
  Ptr<WifiRadioEnergyModel> m_wifiRadioEnergyModel; //!< Wifi radio energy model
1994
  Ptr<WifiRadioEnergyModel> m_wifiRadioEnergyModel; //!< Wifi radio energy model
1995
  
1996
  Callback<void> m_capabilitiesChangedCallback; //!< Callback when PHY capabilities changed
1990
};
1997
};
1991
1998
1992
/**
1999
/**

Return to bug 2831