# HG changeset patch # Parent c648032c80795f11176ef1f70ed83ba447f4570a diff -r c648032c8079 src/wifi/model/ap-wifi-mac.cc --- a/src/wifi/model/ap-wifi-mac.cc Fri Jul 06 11:14:13 2018 +0300 +++ b/src/wifi/model/ap-wifi-mac.cc Sun Jul 08 21:56:33 2018 +0200 @@ -444,15 +444,15 @@ return rates; } -DsssParameterSet +Ptr ApWifiMac::GetDsssParameterSet (void) const { NS_LOG_FUNCTION (this); - DsssParameterSet dsssParameters; + Ptr dsssParameters = Create (); if (GetDsssSupported ()) { - dsssParameters.SetDsssSupported (1); - dsssParameters.SetCurrentChannel (m_phy->GetChannelNumber ()); + dsssParameters->SetDsssSupported (1); + dsssParameters->SetCurrentChannel (m_phy->GetChannelNumber ()); } return dsssParameters; } @@ -472,113 +472,116 @@ return capabilities; } -ErpInformation +Ptr ApWifiMac::GetErpInformation (void) const { NS_LOG_FUNCTION (this); - ErpInformation information; - information.SetErpSupported (1); + Ptr information = Create (); + information->SetErpSupported (1); if (GetErpSupported ()) { - information.SetNonErpPresent (!m_nonErpStations.empty ()); - information.SetUseProtection (GetUseNonErpProtection ()); + information->SetNonErpPresent (!m_nonErpStations.empty ()); + information->SetUseProtection (GetUseNonErpProtection ()); if (GetShortPreambleEnabled ()) { - information.SetBarkerPreambleMode (0); + information->SetBarkerPreambleMode (0); } else { - information.SetBarkerPreambleMode (1); + information->SetBarkerPreambleMode (1); } } return information; } -EdcaParameterSet +Ptr ApWifiMac::GetEdcaParameterSet (void) const { NS_LOG_FUNCTION (this); - EdcaParameterSet edcaParameters; + Ptr edcaParameters = Create (); if (GetQosSupported ()) { - edcaParameters.SetQosSupported (1); + edcaParameters->SetQosSupported (1); Ptr edca; Time txopLimit; edca = m_edca.find (AC_BE)->second; txopLimit = edca->GetTxopLimit (); - edcaParameters.SetBeAci (0); - edcaParameters.SetBeCWmin (edca->GetMinCw ()); - edcaParameters.SetBeCWmax (edca->GetMaxCw ()); - edcaParameters.SetBeAifsn (edca->GetAifsn ()); - edcaParameters.SetBeTXOPLimit (static_cast (txopLimit.GetMicroSeconds () / 32)); + edcaParameters->SetBeAci (0); + edcaParameters->SetBeCWmin (edca->GetMinCw ()); + edcaParameters->SetBeCWmax (edca->GetMaxCw ()); + edcaParameters->SetBeAifsn (edca->GetAifsn ()); + edcaParameters->SetBeTXOPLimit (static_cast (txopLimit.GetMicroSeconds () / 32)); edca = m_edca.find (AC_BK)->second; txopLimit = edca->GetTxopLimit (); - edcaParameters.SetBkAci (1); - edcaParameters.SetBkCWmin (edca->GetMinCw ()); - edcaParameters.SetBkCWmax (edca->GetMaxCw ()); - edcaParameters.SetBkAifsn (edca->GetAifsn ()); - edcaParameters.SetBkTXOPLimit (static_cast (txopLimit.GetMicroSeconds () / 32)); + edcaParameters->SetBkAci (1); + edcaParameters->SetBkCWmin (edca->GetMinCw ()); + edcaParameters->SetBkCWmax (edca->GetMaxCw ()); + edcaParameters->SetBkAifsn (edca->GetAifsn ()); + edcaParameters->SetBkTXOPLimit (static_cast (txopLimit.GetMicroSeconds () / 32)); edca = m_edca.find (AC_VI)->second; txopLimit = edca->GetTxopLimit (); - edcaParameters.SetViAci (2); - edcaParameters.SetViCWmin (edca->GetMinCw ()); - edcaParameters.SetViCWmax (edca->GetMaxCw ()); - edcaParameters.SetViAifsn (edca->GetAifsn ()); - edcaParameters.SetViTXOPLimit (static_cast (txopLimit.GetMicroSeconds () / 32)); + edcaParameters->SetViAci (2); + edcaParameters->SetViCWmin (edca->GetMinCw ()); + edcaParameters->SetViCWmax (edca->GetMaxCw ()); + edcaParameters->SetViAifsn (edca->GetAifsn ()); + edcaParameters->SetViTXOPLimit (static_cast (txopLimit.GetMicroSeconds () / 32)); edca = m_edca.find (AC_VO)->second; txopLimit = edca->GetTxopLimit (); - edcaParameters.SetVoAci (3); - edcaParameters.SetVoCWmin (edca->GetMinCw ()); - edcaParameters.SetVoCWmax (edca->GetMaxCw ()); - edcaParameters.SetVoAifsn (edca->GetAifsn ()); - edcaParameters.SetVoTXOPLimit (static_cast (txopLimit.GetMicroSeconds () / 32)); + edcaParameters->SetVoAci (3); + edcaParameters->SetVoCWmin (edca->GetMinCw ()); + edcaParameters->SetVoCWmax (edca->GetMaxCw ()); + edcaParameters->SetVoAifsn (edca->GetAifsn ()); + edcaParameters->SetVoTXOPLimit (static_cast (txopLimit.GetMicroSeconds () / 32)); - edcaParameters.SetQosInfo (0); + edcaParameters->SetQosInfo (0); } return edcaParameters; } -CfParameterSet +Ptr ApWifiMac::GetCfParameterSet (void) const { - CfParameterSet cfParameterSet; - if (GetPcfSupported () && !m_cfPollingList.empty ()) + Ptr cfParameterSet = Create (); + if (GetPcfSupported ()) { - cfParameterSet.SetPcfSupported (1); - cfParameterSet.SetCFPCount (0); - cfParameterSet.SetCFPPeriod (1); - cfParameterSet.SetCFPMaxDurationUs (GetCfpMaxDuration ().GetMicroSeconds ()); - cfParameterSet.SetCFPDurRemainingUs (GetCfpMaxDuration ().GetMicroSeconds ()); + cfParameterSet->SetPcfSupported (1); + if (!m_cfPollingList.empty ()) + { + cfParameterSet->SetCFPCount (0); + cfParameterSet->SetCFPPeriod (1); + cfParameterSet->SetCFPMaxDurationUs (GetCfpMaxDuration ().GetMicroSeconds ()); + cfParameterSet->SetCFPDurRemainingUs (GetCfpMaxDuration ().GetMicroSeconds ()); + } } return cfParameterSet; } -HtOperation +Ptr ApWifiMac::GetHtOperation (void) const { NS_LOG_FUNCTION (this); - HtOperation operation; - if (GetHtSupported ()) + Ptr operation = Create (); + if (GetHtSupported () || GetVhtSupported () || GetHeSupported ()) { - operation.SetHtSupported (1); - operation.SetRifsMode (GetRifsMode ()); - operation.SetNonGfHtStasPresent (IsNonGfHtStasPresent ()); + operation->SetHtSupported (1); + operation->SetRifsMode (GetRifsMode ()); + operation->SetNonGfHtStasPresent (IsNonGfHtStasPresent ()); if (m_phy->GetChannelWidth () > 20) { - operation.SetSecondaryChannelOffset (1); - operation.SetStaChannelWidth (1); + operation->SetSecondaryChannelOffset (1); + operation->SetStaChannelWidth (1); } if (m_nonHtStations.empty ()) { - operation.SetHtProtection (NO_PROTECTION); + operation->SetHtProtection (NO_PROTECTION); } else { - operation.SetHtProtection (MIXED_MODE_PROTECTION); + operation->SetHtProtection (MIXED_MODE_PROTECTION); } uint64_t maxSupportedRate = 0; //in bit/s for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) @@ -633,44 +636,44 @@ } } } - operation.SetRxHighestSupportedDataRate (static_cast (maxSupportedRate / 1e6)); //in Mbit/s - operation.SetTxMcsSetDefined (nMcs > 0); - operation.SetTxMaxNSpatialStreams (maxSpatialStream); + operation->SetRxHighestSupportedDataRate (static_cast (maxSupportedRate / 1e6)); //in Mbit/s + operation->SetTxMcsSetDefined (nMcs > 0); + operation->SetTxMaxNSpatialStreams (maxSpatialStream); //To be filled in once supported - operation.SetObssNonHtStasPresent (0); - operation.SetDualBeacon (0); - operation.SetDualCtsProtection (0); - operation.SetStbcBeacon (0); - operation.SetLSigTxopProtectionFullSupport (0); - operation.SetPcoActive (0); - operation.SetPhase (0); - operation.SetRxMcsBitmask (0); - operation.SetTxRxMcsSetUnequal (0); - operation.SetTxUnequalModulation (0); + operation->SetObssNonHtStasPresent (0); + operation->SetDualBeacon (0); + operation->SetDualCtsProtection (0); + operation->SetStbcBeacon (0); + operation->SetLSigTxopProtectionFullSupport (0); + operation->SetPcoActive (0); + operation->SetPhase (0); + operation->SetRxMcsBitmask (0); + operation->SetTxRxMcsSetUnequal (0); + operation->SetTxUnequalModulation (0); } return operation; } -VhtOperation +Ptr ApWifiMac::GetVhtOperation (void) const { NS_LOG_FUNCTION (this); - VhtOperation operation; - if (GetVhtSupported ()) + Ptr operation = Create (); + if (GetVhtSupported () || GetHeSupported ()) { - operation.SetVhtSupported (1); + operation->SetVhtSupported (1); uint16_t channelWidth = GetVhtOperationalChannelWidth (); if (channelWidth == 160) { - operation.SetChannelWidth (2); + operation->SetChannelWidth (2); } else if (channelWidth == 80) { - operation.SetChannelWidth (1); + operation->SetChannelWidth (1); } else { - operation.SetChannelWidth (0); + operation->SetChannelWidth (0); } for (uint8_t nss = 1; nss <= 8; nss++) { @@ -683,23 +686,23 @@ { maxMcs = 0; } - operation.SetMaxVhtMcsPerNss (nss, maxMcs); + operation->SetMaxVhtMcsPerNss (nss, maxMcs); } } return operation; } -HeOperation +Ptr ApWifiMac::GetHeOperation (void) const { NS_LOG_FUNCTION (this); - HeOperation operation; + Ptr operation = Create (); if (GetHeSupported ()) { - operation.SetHeSupported (1); + operation->SetHeSupported (1); for (uint8_t nss = 1; nss <= m_phy->GetMaxSupportedRxSpatialStreams (); nss++) { - operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported + operation->SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported } } return operation; @@ -727,31 +730,31 @@ m_stationManager->SetShortSlotTimeEnabled (GetShortSlotTimeEnabled ()); if (GetDsssSupported ()) { - probe.SetDsssParameterSet (GetDsssParameterSet ()); + probe.AddWifiInformationElement (GetDsssParameterSet ()); } if (GetErpSupported ()) { - probe.SetErpInformation (GetErpInformation ()); + probe.AddWifiInformationElement (GetErpInformation ()); } if (GetQosSupported ()) { - probe.SetEdcaParameterSet (GetEdcaParameterSet ()); + probe.AddWifiInformationElement (GetEdcaParameterSet ()); } if (GetHtSupported () || GetVhtSupported () || GetHeSupported ()) { - probe.SetExtendedCapabilities (GetExtendedCapabilities ()); - probe.SetHtCapabilities (GetHtCapabilities ()); - probe.SetHtOperation (GetHtOperation ()); + probe.AddWifiInformationElement (GetExtendedCapabilities ()); + probe.AddWifiInformationElement (GetHtCapabilities ()); + probe.AddWifiInformationElement (GetHtOperation ()); } if (GetVhtSupported () || GetHeSupported ()) { - probe.SetVhtCapabilities (GetVhtCapabilities ()); - probe.SetVhtOperation (GetVhtOperation ()); + probe.AddWifiInformationElement (GetVhtCapabilities ()); + probe.AddWifiInformationElement (GetVhtOperation ()); } if (GetHeSupported ()) { - probe.SetHeCapabilities (GetHeCapabilities ()); - probe.SetHeOperation (GetHeOperation ()); + probe.AddWifiInformationElement (GetHeCapabilities ()); + probe.AddWifiInformationElement (GetHeOperation ()); } packet->AddHeader (probe); @@ -810,27 +813,27 @@ assoc.SetCapabilities (GetCapabilities ()); if (GetErpSupported ()) { - assoc.SetErpInformation (GetErpInformation ()); + assoc.AddWifiInformationElement (GetErpInformation ()); } if (GetQosSupported ()) { - assoc.SetEdcaParameterSet (GetEdcaParameterSet ()); + assoc.AddWifiInformationElement (GetEdcaParameterSet ()); } if (GetHtSupported () || GetVhtSupported () || GetHeSupported ()) { - assoc.SetExtendedCapabilities (GetExtendedCapabilities ()); - assoc.SetHtCapabilities (GetHtCapabilities ()); - assoc.SetHtOperation (GetHtOperation ()); + assoc.AddWifiInformationElement (GetExtendedCapabilities ()); + assoc.AddWifiInformationElement (GetHtCapabilities ()); + assoc.AddWifiInformationElement (GetHtOperation ()); } if (GetVhtSupported () || GetHeSupported ()) { - assoc.SetVhtCapabilities (GetVhtCapabilities ()); - assoc.SetVhtOperation (GetVhtOperation ()); + assoc.AddWifiInformationElement (GetVhtCapabilities ()); + assoc.AddWifiInformationElement (GetVhtOperation ()); } if (GetHeSupported ()) { - assoc.SetHeCapabilities (GetHeCapabilities ()); - assoc.SetHeOperation (GetHeOperation ()); + assoc.AddWifiInformationElement (GetHeCapabilities ()); + assoc.AddWifiInformationElement (GetHeOperation ()); } packet->AddHeader (assoc); @@ -863,35 +866,35 @@ m_stationManager->SetShortSlotTimeEnabled (GetShortSlotTimeEnabled ()); if (GetPcfSupported ()) { - beacon.SetCfParameterSet (GetCfParameterSet ()); + beacon.AddWifiInformationElement (GetCfParameterSet ()); } if (GetDsssSupported ()) { - beacon.SetDsssParameterSet (GetDsssParameterSet ()); + beacon.AddWifiInformationElement (GetDsssParameterSet ()); } if (GetErpSupported ()) { - beacon.SetErpInformation (GetErpInformation ()); + beacon.AddWifiInformationElement (GetErpInformation ()); } if (GetQosSupported ()) { - beacon.SetEdcaParameterSet (GetEdcaParameterSet ()); + beacon.AddWifiInformationElement (GetEdcaParameterSet ()); } if (GetHtSupported () || GetVhtSupported ()) { - beacon.SetExtendedCapabilities (GetExtendedCapabilities ()); - beacon.SetHtCapabilities (GetHtCapabilities ()); - beacon.SetHtOperation (GetHtOperation ()); + beacon.AddWifiInformationElement (GetExtendedCapabilities ()); + beacon.AddWifiInformationElement (GetHtCapabilities ()); + beacon.AddWifiInformationElement (GetHtOperation ()); } if (GetVhtSupported () || GetHeSupported ()) { - beacon.SetVhtCapabilities (GetVhtCapabilities ()); - beacon.SetVhtOperation (GetVhtOperation ()); + beacon.AddWifiInformationElement (GetVhtCapabilities ()); + beacon.AddWifiInformationElement (GetVhtOperation ()); } if (GetHeSupported ()) { - beacon.SetHeCapabilities (GetHeCapabilities ()); - beacon.SetHeOperation (GetHeOperation ()); + beacon.AddWifiInformationElement (GetHeCapabilities ()); + beacon.AddWifiInformationElement (GetHeOperation ()); } packet->AddHeader (beacon); @@ -1140,14 +1143,15 @@ if (GetHtSupported ()) { //check whether the HT STA supports all MCSs in Basic MCS Set - HtCapabilities htcapabilities = assocReq.GetHtCapabilities (); - if (htcapabilities.IsSupportedMcs (0)) + Ptr htcapabilities = + StaticCast (assocReq.GetInformationElement (IE_HT_CAPABILITIES)); + if (htcapabilities != 0) { isHtStation = true; for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) { WifiMode mcs = m_stationManager->GetBasicMcs (i); - if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ())) + if (!htcapabilities->IsSupportedMcs (mcs.GetMcsValue ())) { problem = true; break; @@ -1158,13 +1162,14 @@ if (GetVhtSupported ()) { //check whether the VHT STA supports all MCSs in Basic MCS Set - VhtCapabilities vhtcapabilities = assocReq.GetVhtCapabilities (); - if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0) + Ptr vhtcapabilities = + StaticCast (assocReq.GetInformationElement (IE_VHT_CAPABILITIES)); + if (vhtcapabilities != 0) { for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) { WifiMode mcs = m_stationManager->GetBasicMcs (i); - if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) + if (!vhtcapabilities->IsSupportedTxMcs (mcs.GetMcsValue ())) { problem = true; break; @@ -1175,13 +1180,14 @@ if (GetHeSupported ()) { //check whether the HE STA supports all MCSs in Basic MCS Set - HeCapabilities hecapabilities = assocReq.GetHeCapabilities (); - if (hecapabilities.GetSupportedMcsAndNss () != 0) + Ptr hecapabilities = + StaticCast (assocReq.GetInformationElement (IE_HE_CAPABILITIES)); + if (hecapabilities != 0) { for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) { WifiMode mcs = m_stationManager->GetBasicMcs (i); - if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) + if (!hecapabilities->IsSupportedTxMcs (mcs.GetMcsValue ())) { problem = true; break; @@ -1216,23 +1222,24 @@ } if (GetHtSupported ()) { - HtCapabilities htCapabilities = assocReq.GetHtCapabilities (); - if (htCapabilities.IsSupportedMcs (0)) + Ptr htCapabilities = + StaticCast (assocReq.GetInformationElement (IE_HT_CAPABILITIES)); + if (htCapabilities != 0) { m_stationManager->AddStationHtCapabilities (from, htCapabilities); } } if (GetVhtSupported ()) { - VhtCapabilities vhtCapabilities = assocReq.GetVhtCapabilities (); - //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT - if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0) + Ptr vhtCapabilities = + StaticCast (assocReq.GetInformationElement (IE_VHT_CAPABILITIES)); + if (vhtCapabilities != 0) { m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities); for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) { WifiMode mcs = m_phy->GetMcs (i); - if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) + if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities->IsSupportedTxMcs (mcs.GetMcsValue ())) { m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs); //here should add a control to add basic MCS when it is implemented @@ -1242,21 +1249,25 @@ } if (GetHtSupported () || GetVhtSupported ()) { - ExtendedCapabilities extendedCapabilities = assocReq.GetExtendedCapabilities (); + Ptr extendedCapabilities = + StaticCast (assocReq.GetInformationElement (IE_EXTENDED_CAPABILITIES)); //TODO: to be completed } if (GetHeSupported ()) { - HeCapabilities heCapabilities = assocReq.GetHeCapabilities (); - //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer - m_stationManager->AddStationHeCapabilities (from, heCapabilities); - for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) + Ptr heCapabilities = + StaticCast (assocReq.GetInformationElement (IE_HE_CAPABILITIES)); + if (heCapabilities != 0) { - WifiMode mcs = m_phy->GetMcs (i); - if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) + m_stationManager->AddStationHeCapabilities (from, heCapabilities); + for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) { - m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs); - //here should add a control to add basic MCS when it is implemented + WifiMode mcs = m_phy->GetMcs (i); + if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities->IsSupportedTxMcs (mcs.GetMcsValue ())) + { + m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs); + //here should add a control to add basic MCS when it is implemented + } } } } @@ -1334,14 +1345,15 @@ if (GetHtSupported ()) { //check whether the HT STA supports all MCSs in Basic MCS Set - HtCapabilities htcapabilities = reassocReq.GetHtCapabilities (); - if (htcapabilities.IsSupportedMcs (0)) + Ptr htcapabilities = + StaticCast (reassocReq.GetInformationElement (IE_HT_CAPABILITIES)); + if (htcapabilities != 0) { isHtStation = true; for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) { WifiMode mcs = m_stationManager->GetBasicMcs (i); - if (!htcapabilities.IsSupportedMcs (mcs.GetMcsValue ())) + if (!htcapabilities->IsSupportedMcs (mcs.GetMcsValue ())) { problem = true; break; @@ -1352,13 +1364,14 @@ if (GetVhtSupported ()) { //check whether the VHT STA supports all MCSs in Basic MCS Set - VhtCapabilities vhtcapabilities = reassocReq.GetVhtCapabilities (); - if (vhtcapabilities.GetVhtCapabilitiesInfo () != 0) + Ptr vhtcapabilities = + StaticCast (reassocReq.GetInformationElement (IE_VHT_CAPABILITIES)); + if (vhtcapabilities != 0) { for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) { WifiMode mcs = m_stationManager->GetBasicMcs (i); - if (!vhtcapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) + if (!vhtcapabilities->IsSupportedTxMcs (mcs.GetMcsValue ())) { problem = true; break; @@ -1369,13 +1382,14 @@ if (GetHeSupported ()) { //check whether the HE STA supports all MCSs in Basic MCS Set - HeCapabilities hecapabilities = reassocReq.GetHeCapabilities (); - if (hecapabilities.GetSupportedMcsAndNss () != 0) + Ptr hecapabilities = + StaticCast (reassocReq.GetInformationElement (IE_HE_CAPABILITIES)); + if (hecapabilities != 0) { for (uint8_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) { WifiMode mcs = m_stationManager->GetBasicMcs (i); - if (!hecapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) + if (!hecapabilities->IsSupportedTxMcs (mcs.GetMcsValue ())) { problem = true; break; @@ -1402,23 +1416,25 @@ } if (GetHtSupported ()) { - HtCapabilities htCapabilities = reassocReq.GetHtCapabilities (); - if (htCapabilities.IsSupportedMcs (0)) + Ptr htCapabilities = + StaticCast (reassocReq.GetInformationElement (IE_HT_CAPABILITIES)); + if (htCapabilities != 0) { m_stationManager->AddStationHtCapabilities (from, htCapabilities); } } if (GetVhtSupported ()) { - VhtCapabilities vhtCapabilities = reassocReq.GetVhtCapabilities (); + Ptr vhtCapabilities = + StaticCast (reassocReq.GetInformationElement (IE_VHT_CAPABILITIES)); //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT - if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0) + if (vhtCapabilities != 0) { m_stationManager->AddStationVhtCapabilities (from, vhtCapabilities); for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) { WifiMode mcs = m_phy->GetMcs (i); - if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) + if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities->IsSupportedTxMcs (mcs.GetMcsValue ())) { m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs); //here should add a control to add basic MCS when it is implemented @@ -1428,21 +1444,25 @@ } if (GetHtSupported () || GetVhtSupported ()) { - ExtendedCapabilities extendedCapabilities = reassocReq.GetExtendedCapabilities (); + Ptr extendedCapabilities = + StaticCast (reassocReq.GetInformationElement (IE_EXTENDED_CAPABILITIES)); //TODO: to be completed } if (GetHeSupported ()) { - HeCapabilities heCapabilities = reassocReq.GetHeCapabilities (); - //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer - m_stationManager->AddStationHeCapabilities (from, heCapabilities); - for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) + Ptr heCapabilities = + StaticCast (reassocReq.GetInformationElement (IE_HE_CAPABILITIES)); + if (heCapabilities != 0) { - WifiMode mcs = m_phy->GetMcs (i); - if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedTxMcs (mcs.GetMcsValue ())) + m_stationManager->AddStationHeCapabilities (from, heCapabilities); + for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) { - m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs); - //here should add a control to add basic MCS when it is implemented + WifiMode mcs = m_phy->GetMcs (i); + if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities->IsSupportedTxMcs (mcs.GetMcsValue ())) + { + m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs); + //here should add a control to add basic MCS when it is implemented + } } } } diff -r c648032c8079 src/wifi/model/ap-wifi-mac.h --- a/src/wifi/model/ap-wifi-mac.h Fri Jul 06 11:14:13 2018 +0300 +++ b/src/wifi/model/ap-wifi-mac.h Sun Jul 08 21:56:33 2018 +0200 @@ -248,37 +248,37 @@ * * \return the ERP information that we support */ - ErpInformation GetErpInformation (void) const; + Ptr GetErpInformation (void) const; /** * Return the EDCA Parameter Set of the current AP. * * \return the EDCA Parameter Set that we support */ - EdcaParameterSet GetEdcaParameterSet (void) const; + Ptr GetEdcaParameterSet (void) const; /** * Return the CF parameter set of the current AP. * * \return the CF parameter set that we support */ - CfParameterSet GetCfParameterSet (void) const; + Ptr GetCfParameterSet (void) const; /** * Return the HT operation of the current AP. * * \return the HT operation that we support */ - HtOperation GetHtOperation (void) const; + Ptr GetHtOperation (void) const; /** * Return the VHT operation of the current AP. * * \return the VHT operation that we support */ - VhtOperation GetVhtOperation (void) const; + Ptr GetVhtOperation (void) const; /** * Return the HE operation of the current AP. * * \return the HE operation that we support */ - HeOperation GetHeOperation (void) const; + Ptr GetHeOperation (void) const; /** * Return an instance of SupportedRates that contains all rates that we support * including HT rates. @@ -291,7 +291,7 @@ * * \return the DSSS Parameter Set that we support */ - DsssParameterSet GetDsssParameterSet (void) const; + Ptr GetDsssParameterSet (void) const; /** * Enable or disable beacon generation of the AP. * diff -r c648032c8079 src/wifi/model/mgt-headers.cc --- a/src/wifi/model/mgt-headers.cc Fri Jul 06 11:14:13 2018 +0300 +++ b/src/wifi/model/mgt-headers.cc Sun Jul 08 21:56:33 2018 +0200 @@ -26,8 +26,128 @@ namespace ns3 { +void +MgtCommonHeader::AddWifiInformationElement (Ptr element) +{ + m_map[element->ElementId ()] = element; +} + +Ptr +MgtCommonHeader::GetInformationElement (WifiInformationElementId id) +{ + WifiInformationElementMap::const_iterator it = m_map.find (id); + if (it != m_map.end()) + { + return it->second; + } + else + { + return 0; + } +} + +uint32_t +MgtCommonHeader::GetInformationElementsSerializedSize (void) const +{ + Ptr element; + uint32_t size = 0; + for (WifiInformationElementMap::const_iterator elem = m_map.begin (); elem != m_map.end (); elem++) + { + element = elem->second; + size += element->GetSerializedSize (); + } + return size; +} + +WifiInformationElementMap +MgtCommonHeader::GetListOfInformationElement (void) const +{ + return m_map; +} + +void +MgtCommonHeader::PrintInformationElements (std::ostream &os) const +{ +} + +Buffer::Iterator +MgtCommonHeader::SerializeInformationElements (Buffer::Iterator start) const +{ + Buffer::Iterator i = start; + Ptr element; + for (WifiInformationElementMap::const_iterator elem = m_map.begin (); elem != m_map.end (); elem++) + { + element = elem->second; + i = element->Serialize (i); + } + return i; +} + +Buffer::Iterator +MgtCommonHeader::DeserializeInformationElements (Buffer::Iterator start) +{ + Buffer::Iterator i = start; + Ptr element; + uint8_t id, length; + while ((!i.IsEnd ()) && (i.GetRemainingSize() > 2)) + { + id = i.ReadU8 (); + length = i.ReadU8 (); + switch (id) + { + /*case IE_SUPPORTED_RATES: + element = Create (); + break; + case IE_EXTENDED_SUPPORTED_RATES: + element = Create (); + break;*/ + case IE_HT_CAPABILITIES: + element = Create (); + break; + case IE_VHT_CAPABILITIES: + element = Create (); + break; + case IE_HE_CAPABILITIES: + element = Create (); + break; + case IE_EXTENDED_CAPABILITIES: + element = Create (); + break; + case IE_HT_OPERATION: + element = Create (); + break; + case IE_VHT_OPERATION: + element = Create (); + break; + case IE_HE_OPERATION: + element = Create (); + break; + case IE_ERP_INFORMATION: + element = Create (); + break; + case IE_EDCA_PARAMETER_SET: + element = Create (); + break; + case IE_DSSS_PARAMETER_SET: + element = Create (); + break; + case IE_CF_PARAMETER_SET: + element = Create (); + break; + default: + // We peeked at the ID and length, so we need to back up the + // pointer before deferring to our parent. + i.Prev (2); + return i; + } + i = element->DeserializeElementBody (i, length); + m_map[id] = element; + } + return i; +} + /*********************************************************** - * Probe Request + * Probe Request ***********************************************************/ NS_OBJECT_ENSURE_REGISTERED (MgtProbeRequestHeader); @@ -60,54 +180,6 @@ m_rates = rates; } -void -MgtProbeRequestHeader::SetExtendedCapabilities (ExtendedCapabilities extendedcapabilities) -{ - m_extendedCapability = extendedcapabilities; -} - -ExtendedCapabilities -MgtProbeRequestHeader::GetExtendedCapabilities (void) const -{ - return m_extendedCapability; -} - -void -MgtProbeRequestHeader::SetHtCapabilities (HtCapabilities htcapabilities) -{ - m_htCapability = htcapabilities; -} - -HtCapabilities -MgtProbeRequestHeader::GetHtCapabilities (void) const -{ - return m_htCapability; -} - -void -MgtProbeRequestHeader::SetVhtCapabilities (VhtCapabilities vhtcapabilities) -{ - m_vhtCapability = vhtcapabilities; -} - -VhtCapabilities -MgtProbeRequestHeader::GetVhtCapabilities (void) const -{ - return m_vhtCapability; -} - -void -MgtProbeRequestHeader::SetHeCapabilities (HeCapabilities hecapabilities) -{ - m_heCapability = hecapabilities; -} - -HeCapabilities -MgtProbeRequestHeader::GetHeCapabilities (void) const -{ - return m_heCapability; -} - SupportedRates MgtProbeRequestHeader::GetSupportedRates (void) const { @@ -121,10 +193,7 @@ size += m_ssid.GetSerializedSize (); size += m_rates.GetSerializedSize (); size += m_rates.extended.GetSerializedSize (); - size += m_extendedCapability.GetSerializedSize (); - size += m_htCapability.GetSerializedSize (); - size += m_vhtCapability.GetSerializedSize (); - size += m_heCapability.GetSerializedSize (); + size += GetInformationElementsSerializedSize (); return size; } @@ -148,12 +217,9 @@ void MgtProbeRequestHeader::Print (std::ostream &os) const { - os << "ssid=" << m_ssid << ", " - << "rates=" << m_rates << ", " - << "Extended Capabilities=" << m_extendedCapability << " , " - << "HT Capabilities=" << m_htCapability << " , " - << "VHT Capabilities=" << m_vhtCapability << " , " - << "HE Capabilities=" << m_heCapability; + os << "ssid=" << m_ssid + << "rates=" << m_rates; + PrintInformationElements (os); } void @@ -163,10 +229,7 @@ i = m_ssid.Serialize (i); i = m_rates.Serialize (i); i = m_rates.extended.Serialize (i); - i = m_extendedCapability.Serialize (i); - i = m_htCapability.Serialize (i); - i = m_vhtCapability.Serialize (i); - i = m_heCapability.Serialize (i); + i = SerializeInformationElements (i); } uint32_t @@ -176,16 +239,13 @@ i = m_ssid.Deserialize (i); i = m_rates.Deserialize (i); i = m_rates.extended.DeserializeIfPresent (i); - i = m_extendedCapability.DeserializeIfPresent (i); - i = m_htCapability.DeserializeIfPresent (i); - i = m_vhtCapability.DeserializeIfPresent (i); - i = m_heCapability.DeserializeIfPresent (i); + i = DeserializeInformationElements (i); return i.GetDistanceFrom (start); } /*********************************************************** - * Probe Response + * Probe Response ***********************************************************/ NS_OBJECT_ENSURE_REGISTERED (MgtProbeResponseHeader); @@ -235,102 +295,6 @@ } void -MgtProbeResponseHeader::SetExtendedCapabilities (ExtendedCapabilities extendedcapabilities) -{ - m_extendedCapability = extendedcapabilities; -} - -ExtendedCapabilities -MgtProbeResponseHeader::GetExtendedCapabilities (void) const -{ - return m_extendedCapability; -} - -void -MgtProbeResponseHeader::SetHtCapabilities (HtCapabilities htcapabilities) -{ - m_htCapability = htcapabilities; -} - -HtCapabilities -MgtProbeResponseHeader::GetHtCapabilities (void) const -{ - return m_htCapability; -} - -void -MgtProbeResponseHeader::SetHtOperation (HtOperation htoperation) -{ - m_htOperation = htoperation; -} - -HtOperation -MgtProbeResponseHeader::GetHtOperation (void) const -{ - return m_htOperation; -} - -void -MgtProbeResponseHeader::SetVhtCapabilities (VhtCapabilities vhtcapabilities) -{ - m_vhtCapability = vhtcapabilities; -} - -VhtCapabilities -MgtProbeResponseHeader::GetVhtCapabilities (void) const -{ - return m_vhtCapability; -} - -void -MgtProbeResponseHeader::SetVhtOperation (VhtOperation vhtoperation) -{ - m_vhtOperation = vhtoperation; -} - -VhtOperation -MgtProbeResponseHeader::GetVhtOperation (void) const -{ - return m_vhtOperation; -} - -void -MgtProbeResponseHeader::SetHeCapabilities (HeCapabilities hecapabilities) -{ - m_heCapability = hecapabilities; -} - -HeCapabilities -MgtProbeResponseHeader::GetHeCapabilities (void) const -{ - return m_heCapability; -} - -void -MgtProbeResponseHeader::SetHeOperation (HeOperation heoperation) -{ - m_heOperation = heoperation; -} - -HeOperation -MgtProbeResponseHeader::GetHeOperation (void) const -{ - return m_heOperation; -} - -void -MgtProbeResponseHeader::SetCfParameterSet (CfParameterSet cfparameterset) -{ - m_cfParameterSet = cfparameterset; -} - -CfParameterSet -MgtProbeResponseHeader::GetCfParameterSet (void) const -{ - return m_cfParameterSet; -} - -void MgtProbeResponseHeader::SetSsid (Ssid ssid) { m_ssid = ssid; @@ -348,42 +312,6 @@ m_rates = rates; } -void -MgtProbeResponseHeader::SetDsssParameterSet (DsssParameterSet dsssParameterSet) -{ - m_dsssParameterSet = dsssParameterSet; -} - -DsssParameterSet -MgtProbeResponseHeader::GetDsssParameterSet (void) const -{ - return m_dsssParameterSet; -} - -void -MgtProbeResponseHeader::SetErpInformation (ErpInformation erpInformation) -{ - m_erpInformation = erpInformation; -} - -ErpInformation -MgtProbeResponseHeader::GetErpInformation (void) const -{ - return m_erpInformation; -} - -void -MgtProbeResponseHeader::SetEdcaParameterSet (EdcaParameterSet edcaparameters) -{ - m_edcaParameterSet = edcaparameters; -} - -EdcaParameterSet -MgtProbeResponseHeader::GetEdcaParameterSet (void) const -{ - return m_edcaParameterSet; -} - TypeId MgtProbeResponseHeader::GetTypeId (void) { @@ -410,34 +338,19 @@ size += m_capability.GetSerializedSize (); size += m_ssid.GetSerializedSize (); size += m_rates.GetSerializedSize (); - size += m_cfParameterSet.GetSerializedSize (); - size += m_dsssParameterSet.GetSerializedSize (); - size += m_erpInformation.GetSerializedSize (); size += m_rates.extended.GetSerializedSize (); - size += m_edcaParameterSet.GetSerializedSize (); - size += m_extendedCapability.GetSerializedSize (); - size += m_htCapability.GetSerializedSize (); - size += m_htOperation.GetSerializedSize (); - size += m_vhtCapability.GetSerializedSize (); - size += m_vhtOperation.GetSerializedSize (); - size += m_heCapability.GetSerializedSize (); - size += m_heOperation.GetSerializedSize (); + size += GetInformationElementsSerializedSize (); return size; } void MgtProbeResponseHeader::Print (std::ostream &os) const { - os << "ssid=" << m_ssid << ", " - << "rates=" << m_rates << ", " - << "ERP information=" << m_erpInformation << ", " - << "Extended Capabilities=" << m_extendedCapability << " , " - << "HT Capabilities=" << m_htCapability << " , " - << "HT Operation=" << m_htOperation << " , " - << "VHT Capabilities=" << m_vhtCapability << " , " - << "VHT Operation=" << m_vhtOperation << " , " - << "HE Capabilities=" << m_heCapability << " , " - << "HE Operation=" << m_heOperation; + os << "Timestamp=" << m_timestamp << "," << + "BeaconInterval=" << m_beaconInterval << "," << + "rates=" << m_rates << ", " + "ssid=" << m_ssid; + PrintInformationElements (os); } void @@ -448,28 +361,14 @@ //capability information //ssid //supported rates - //fh parameter set - //ds parameter set - //cf parameter set - //ibss parameter set Buffer::Iterator i = start; i.WriteHtolsbU64 (Simulator::Now ().GetMicroSeconds ()); i.WriteHtolsbU16 (static_cast (m_beaconInterval / 1024)); i = m_capability.Serialize (i); i = m_ssid.Serialize (i); i = m_rates.Serialize (i); - i = m_cfParameterSet.Serialize (i); - i = m_dsssParameterSet.Serialize (i); - i = m_erpInformation.Serialize (i); i = m_rates.extended.Serialize (i); - i = m_edcaParameterSet.Serialize (i); - i = m_extendedCapability.Serialize (i); - i = m_htCapability.Serialize (i); - i = m_htOperation.Serialize (i); - i = m_vhtCapability.Serialize (i); - i = m_vhtOperation.Serialize (i); - i = m_heCapability.Serialize (i); - i = m_heOperation.Serialize (i); + i = SerializeInformationElements (i); } uint32_t @@ -482,18 +381,8 @@ i = m_capability.Deserialize (i); i = m_ssid.Deserialize (i); i = m_rates.Deserialize (i); - i = m_cfParameterSet.DeserializeIfPresent (i); - i = m_dsssParameterSet.DeserializeIfPresent (i); - i = m_erpInformation.DeserializeIfPresent (i); i = m_rates.extended.DeserializeIfPresent (i); - i = m_edcaParameterSet.DeserializeIfPresent (i); - i = m_extendedCapability.DeserializeIfPresent (i); - i = m_htCapability.DeserializeIfPresent (i); - i = m_htOperation.DeserializeIfPresent (i); - i = m_vhtCapability.DeserializeIfPresent (i); - i = m_vhtOperation.DeserializeIfPresent (i); - i = m_heCapability.DeserializeIfPresent (i); - i = m_heOperation.DeserializeIfPresent (i); + i = DeserializeInformationElements (i); return i.GetDistanceFrom (start); } @@ -518,7 +407,7 @@ /*********************************************************** - * Assoc Request + * Assoc Request ***********************************************************/ NS_OBJECT_ENSURE_REGISTERED (MgtAssocRequestHeader); @@ -562,54 +451,6 @@ return m_capability; } -void -MgtAssocRequestHeader::SetExtendedCapabilities (ExtendedCapabilities extendedcapabilities) -{ - m_extendedCapability = extendedcapabilities; -} - -ExtendedCapabilities -MgtAssocRequestHeader::GetExtendedCapabilities (void) const -{ - return m_extendedCapability; -} - -void -MgtAssocRequestHeader::SetHtCapabilities (HtCapabilities htcapabilities) -{ - m_htCapability = htcapabilities; -} - -HtCapabilities -MgtAssocRequestHeader::GetHtCapabilities (void) const -{ - return m_htCapability; -} - -void -MgtAssocRequestHeader::SetVhtCapabilities (VhtCapabilities vhtcapabilities) -{ - m_vhtCapability = vhtcapabilities; -} - -VhtCapabilities -MgtAssocRequestHeader::GetVhtCapabilities (void) const -{ - return m_vhtCapability; -} - -void -MgtAssocRequestHeader::SetHeCapabilities (HeCapabilities hecapabilities) -{ - m_heCapability = hecapabilities; -} - -HeCapabilities -MgtAssocRequestHeader::GetHeCapabilities (void) const -{ - return m_heCapability; -} - Ssid MgtAssocRequestHeader::GetSsid (void) const { @@ -654,22 +495,16 @@ size += m_ssid.GetSerializedSize (); size += m_rates.GetSerializedSize (); size += m_rates.extended.GetSerializedSize (); - size += m_extendedCapability.GetSerializedSize (); - size += m_htCapability.GetSerializedSize (); - size += m_vhtCapability.GetSerializedSize (); - size += m_heCapability.GetSerializedSize (); + size += GetInformationElementsSerializedSize (); return size; } void MgtAssocRequestHeader::Print (std::ostream &os) const { - os << "ssid=" << m_ssid << ", " - << "rates=" << m_rates << ", " - << "Extended Capabilities=" << m_extendedCapability << " , " - << "HT Capabilities=" << m_htCapability << " , " - << "VHT Capabilities=" << m_vhtCapability << " , " - << "HE Capabilities=" << m_heCapability; + os << "ssid=" << m_ssid << ", " + << "rates=" << m_rates; + PrintInformationElements (os); } void @@ -681,10 +516,7 @@ i = m_ssid.Serialize (i); i = m_rates.Serialize (i); i = m_rates.extended.Serialize (i); - i = m_extendedCapability.Serialize (i); - i = m_htCapability.Serialize (i); - i = m_vhtCapability.Serialize (i); - i = m_heCapability.Serialize (i); + i = SerializeInformationElements (i); } uint32_t @@ -696,16 +528,13 @@ i = m_ssid.Deserialize (i); i = m_rates.Deserialize (i); i = m_rates.extended.DeserializeIfPresent (i); - i = m_extendedCapability.DeserializeIfPresent (i); - i = m_htCapability.DeserializeIfPresent (i); - i = m_vhtCapability.DeserializeIfPresent (i); - i = m_heCapability.DeserializeIfPresent (i); + i = DeserializeInformationElements (i); return i.GetDistanceFrom (start); } /*********************************************************** - * Ressoc Request + * Ressoc Request ***********************************************************/ NS_OBJECT_ENSURE_REGISTERED (MgtReassocRequestHeader); @@ -749,54 +578,6 @@ return m_capability; } -void -MgtReassocRequestHeader::SetExtendedCapabilities (ExtendedCapabilities extendedcapabilities) -{ - m_extendedCapability = extendedcapabilities; -} - -ExtendedCapabilities -MgtReassocRequestHeader::GetExtendedCapabilities (void) const -{ - return m_extendedCapability; -} - -void -MgtReassocRequestHeader::SetHtCapabilities (HtCapabilities htcapabilities) -{ - m_htCapability = htcapabilities; -} - -HtCapabilities -MgtReassocRequestHeader::GetHtCapabilities (void) const -{ - return m_htCapability; -} - -void -MgtReassocRequestHeader::SetVhtCapabilities (VhtCapabilities vhtcapabilities) -{ - m_vhtCapability = vhtcapabilities; -} - -VhtCapabilities -MgtReassocRequestHeader::GetVhtCapabilities (void) const -{ - return m_vhtCapability; -} - -void -MgtReassocRequestHeader::SetHeCapabilities (HeCapabilities hecapabilities) -{ - m_heCapability = hecapabilities; -} - -HeCapabilities -MgtReassocRequestHeader::GetHeCapabilities (void) const -{ - return m_heCapability; -} - Ssid MgtReassocRequestHeader::GetSsid (void) const { @@ -848,10 +629,7 @@ size += m_ssid.GetSerializedSize (); size += m_rates.GetSerializedSize (); size += m_rates.extended.GetSerializedSize (); - size += m_extendedCapability.GetSerializedSize (); - size += m_htCapability.GetSerializedSize (); - size += m_vhtCapability.GetSerializedSize (); - size += m_heCapability.GetSerializedSize (); + size += GetInformationElementsSerializedSize (); return size; } @@ -860,11 +638,8 @@ { os << "current AP address=" << m_currentApAddr << ", " << "ssid=" << m_ssid << ", " - << "rates=" << m_rates << ", " - << "Extended Capabilities=" << m_extendedCapability << " , " - << "HT Capabilities=" << m_htCapability << " , " - << "VHT Capabilities=" << m_vhtCapability << " , " - << "HE Capabilities=" << m_heCapability; + << "rates=" << m_rates; + PrintInformationElements (os); } void @@ -877,10 +652,7 @@ i = m_ssid.Serialize (i); i = m_rates.Serialize (i); i = m_rates.extended.Serialize (i); - i = m_extendedCapability.Serialize (i); - i = m_htCapability.Serialize (i); - i = m_vhtCapability.Serialize (i); - i = m_heCapability.Serialize (i); + i = SerializeInformationElements (i); } uint32_t @@ -893,16 +665,13 @@ i = m_ssid.Deserialize (i); i = m_rates.Deserialize (i); i = m_rates.extended.DeserializeIfPresent (i); - i = m_extendedCapability.DeserializeIfPresent (i); - i = m_htCapability.DeserializeIfPresent (i); - i = m_vhtCapability.DeserializeIfPresent (i); - i = m_heCapability.DeserializeIfPresent (i); + i = DeserializeInformationElements (i); return i.GetDistanceFrom (start); } /*********************************************************** - * Assoc/Reassoc Response + * Assoc/Reassoc Response ***********************************************************/ NS_OBJECT_ENSURE_REGISTERED (MgtAssocResponseHeader); @@ -952,114 +721,6 @@ return m_capability; } -void -MgtAssocResponseHeader::SetExtendedCapabilities (ExtendedCapabilities extendedcapabilities) -{ - m_extendedCapability = extendedcapabilities; -} - -ExtendedCapabilities -MgtAssocResponseHeader::GetExtendedCapabilities (void) const -{ - return m_extendedCapability; -} - -void -MgtAssocResponseHeader::SetHtCapabilities (HtCapabilities htcapabilities) -{ - m_htCapability = htcapabilities; -} - -HtCapabilities -MgtAssocResponseHeader::GetHtCapabilities (void) const -{ - return m_htCapability; -} - -void -MgtAssocResponseHeader::SetHtOperation (HtOperation htoperation) -{ - m_htOperation = htoperation; -} - -HtOperation -MgtAssocResponseHeader::GetHtOperation (void) const -{ - return m_htOperation; -} - -void -MgtAssocResponseHeader::SetVhtCapabilities (VhtCapabilities vhtcapabilities) -{ - m_vhtCapability = vhtcapabilities; -} - -VhtCapabilities -MgtAssocResponseHeader::GetVhtCapabilities (void) const -{ - return m_vhtCapability; -} - -void -MgtAssocResponseHeader::SetVhtOperation (VhtOperation vhtoperation) -{ - m_vhtOperation = vhtoperation; -} - -VhtOperation -MgtAssocResponseHeader::GetVhtOperation (void) const -{ - return m_vhtOperation; -} - -void -MgtAssocResponseHeader::SetHeCapabilities (HeCapabilities hecapabilities) -{ - m_heCapability = hecapabilities; -} - -HeCapabilities -MgtAssocResponseHeader::GetHeCapabilities (void) const -{ - return m_heCapability; -} - -void -MgtAssocResponseHeader::SetHeOperation (HeOperation heoperation) -{ - m_heOperation = heoperation; -} - -HeOperation -MgtAssocResponseHeader::GetHeOperation (void) const -{ - return m_heOperation; -} - -void -MgtAssocResponseHeader::SetErpInformation (ErpInformation erpInformation) -{ - m_erpInformation = erpInformation; -} - -ErpInformation -MgtAssocResponseHeader::GetErpInformation (void) const -{ - return m_erpInformation; -} - -void -MgtAssocResponseHeader::SetEdcaParameterSet (EdcaParameterSet edcaparameters) -{ - m_edcaParameterSet = edcaparameters; -} - -EdcaParameterSet -MgtAssocResponseHeader::GetEdcaParameterSet (void) const -{ - return m_edcaParameterSet; -} - TypeId MgtAssocResponseHeader::GetTypeId (void) { @@ -1085,16 +746,8 @@ size += m_code.GetSerializedSize (); size += 2; //aid size += m_rates.GetSerializedSize (); - size += m_erpInformation.GetSerializedSize (); size += m_rates.extended.GetSerializedSize (); - size += m_edcaParameterSet.GetSerializedSize (); - size += m_extendedCapability.GetSerializedSize (); - size += m_htCapability.GetSerializedSize (); - size += m_htOperation.GetSerializedSize (); - size += m_vhtCapability.GetSerializedSize (); - size += m_vhtOperation.GetSerializedSize (); - size += m_heCapability.GetSerializedSize (); - size += m_heOperation.GetSerializedSize (); + size += GetInformationElementsSerializedSize (); return size; } @@ -1103,15 +756,8 @@ { os << "status code=" << m_code << ", " << "aid=" << m_aid << ", " - << "rates=" << m_rates << ", " - << "ERP information=" << m_erpInformation << ", " - << "Extended Capabilities=" << m_extendedCapability << " , " - << "HT Capabilities=" << m_htCapability << " , " - << "HT Operation=" << m_htOperation << " , " - << "VHT Capabilities=" << m_vhtCapability << " , " - << "VHT Operation=" << m_vhtOperation << " , " - << "HE Capabilities=" << m_heCapability << " , " - << "HE Operation=" << m_heOperation; + << "rates=" << m_rates; + PrintInformationElements (os); } void @@ -1122,16 +768,8 @@ i = m_code.Serialize (i); i.WriteHtolsbU16 (m_aid); i = m_rates.Serialize (i); - i = m_erpInformation.Serialize (i); i = m_rates.extended.Serialize (i); - i = m_edcaParameterSet.Serialize (i); - i = m_extendedCapability.Serialize (i); - i = m_htCapability.Serialize (i); - i = m_htOperation.Serialize (i); - i = m_vhtCapability.Serialize (i); - i = m_vhtOperation.Serialize (i); - i = m_heCapability.Serialize (i); - i = m_heOperation.Serialize (i); + i = SerializeInformationElements (i); } uint32_t @@ -1142,22 +780,14 @@ i = m_code.Deserialize (i); m_aid = i.ReadLsbtohU16 (); i = m_rates.Deserialize (i); - i = m_erpInformation.DeserializeIfPresent (i); i = m_rates.extended.DeserializeIfPresent (i); - i = m_edcaParameterSet.DeserializeIfPresent (i); - i = m_extendedCapability.DeserializeIfPresent (i); - i = m_htCapability.DeserializeIfPresent (i); - i = m_htOperation.DeserializeIfPresent (i); - i = m_vhtCapability.DeserializeIfPresent (i); - i = m_vhtOperation.DeserializeIfPresent (i); - i = m_heCapability.DeserializeIfPresent (i); - i = m_heOperation.DeserializeIfPresent (i); + i = DeserializeInformationElements (i); return i.GetDistanceFrom (start); } /********************************************************** - * ActionFrame + * ActionFrame **********************************************************/ WifiActionHeader::WifiActionHeader () { diff -r c648032c8079 src/wifi/model/mgt-headers.h --- a/src/wifi/model/mgt-headers.h Fri Jul 06 11:14:13 2018 +0300 +++ b/src/wifi/model/mgt-headers.h Sun Jul 08 21:56:33 2018 +0200 @@ -23,6 +23,7 @@ #ifndef MGT_HEADERS_H #define MGT_HEADERS_H +#include #include "ns3/mac48-address.h" #include "status-code.h" #include "capability-information.h" @@ -42,11 +43,50 @@ namespace ns3 { +typedef std::vector > WifiInfoElementList; +typedef std::vector WifiInformationElementIdList; +typedef std::map > WifiInformationElementMap; + +/** + * \ingroup wifi + * Implement the common header for management frames. + */ +class MgtCommonHeader : public Header { +public: + /** + * Add new Wifi Information Element that is not vendor specific. + * \param element the Wifi Information Element to be added to the management frame header. + */ + void AddWifiInformationElement (Ptr element); + /** + * Get a specific Wifi information element by ID. + * \param id The ID of the Wifi Information Element. + * \return + */ + Ptr GetInformationElement (WifiInformationElementId id); + /** + * Get List of Information Element associated with this frame. + * \return + */ + WifiInformationElementMap GetListOfInformationElement (void) const; + + +protected: + void PrintInformationElements (std::ostream &os) const; + uint32_t GetInformationElementsSerializedSize (void) const; + Buffer::Iterator SerializeInformationElements (Buffer::Iterator start) const; + Buffer::Iterator DeserializeInformationElements (Buffer::Iterator start); + + +private: + WifiInformationElementMap m_map; //!< Map of Wifi Information Element. +}; + /** * \ingroup wifi * Implement the header for management frames of type association request. */ -class MgtAssocRequestHeader : public Header +class MgtAssocRequestHeader : public MgtCommonHeader { public: MgtAssocRequestHeader (); @@ -77,60 +117,12 @@ */ void SetCapabilities (CapabilityInformation capabilities); /** - * Set the Extended Capabilities. - * - * \param extendedcapabilities the Extended Capabilities - */ - void SetExtendedCapabilities (ExtendedCapabilities extendedcapabilities); - /** - * Set the HT capabilities. - * - * \param htcapabilities HT capabilities - */ - void SetHtCapabilities (HtCapabilities htcapabilities); - /** - * Set the VHT capabilities. - * - * \param vhtcapabilities VHT capabilities - */ - void SetVhtCapabilities (VhtCapabilities vhtcapabilities); - /** - * Set the HE capabilities. - * - * \param hecapabilities HE capabilities - */ - void SetHeCapabilities (HeCapabilities hecapabilities); - /** * Return the Capability information. * * \return Capability information */ CapabilityInformation GetCapabilities (void) const; /** - * Return the extended capabilities. - * - * \return the extended capabilities - */ - ExtendedCapabilities GetExtendedCapabilities (void) const; - /** - * Return the HT capabilities. - * - * \return HT capabilities - */ - HtCapabilities GetHtCapabilities (void) const; - /** - * Return the VHT capabilities. - * - * \return VHT capabilities - */ - VhtCapabilities GetVhtCapabilities (void) const; - /** - * Return the HE capabilities. - * - * \return HE capabilities - */ - HeCapabilities GetHeCapabilities (void) const; - /** * Return the Service Set Identifier (SSID). * * \return SSID @@ -165,10 +157,6 @@ Ssid m_ssid; //!< Service Set ID (SSID) SupportedRates m_rates; //!< List of supported rates CapabilityInformation m_capability; //!< Capability information - ExtendedCapabilities m_extendedCapability; //!< Extended capabilities - HtCapabilities m_htCapability; //!< HT capabilities - VhtCapabilities m_vhtCapability; //!< VHT capabilities - HeCapabilities m_heCapability; //!< HE capabilities uint16_t m_listenInterval; //!< listen interval }; @@ -177,7 +165,7 @@ * \ingroup wifi * Implement the header for management frames of type reassociation request. */ -class MgtReassocRequestHeader : public Header +class MgtReassocRequestHeader : public MgtCommonHeader { public: MgtReassocRequestHeader (); @@ -208,60 +196,12 @@ */ void SetCapabilities (CapabilityInformation capabilities); /** - * Set the Extended Capabilities. - * - * \param extendedcapabilities the Extended Capabilities - */ - void SetExtendedCapabilities (ExtendedCapabilities extendedcapabilities); - /** - * Set the HT capabilities. - * - * \param htcapabilities HT capabilities - */ - void SetHtCapabilities (HtCapabilities htcapabilities); - /** - * Set the VHT capabilities. - * - * \param vhtcapabilities VHT capabilities - */ - void SetVhtCapabilities (VhtCapabilities vhtcapabilities); - /** - * Set the HE capabilities. - * - * \param hecapabilities HE capabilities - */ - void SetHeCapabilities (HeCapabilities hecapabilities); - /** * Return the Capability information. * * \return Capability information */ CapabilityInformation GetCapabilities (void) const; /** - * Return the extended capabilities. - * - * \return the extended capabilities - */ - ExtendedCapabilities GetExtendedCapabilities (void) const; - /** - * Return the HT capabilities. - * - * \return HT capabilities - */ - HtCapabilities GetHtCapabilities (void) const; - /** - * Return the VHT capabilities. - * - * \return VHT capabilities - */ - VhtCapabilities GetVhtCapabilities (void) const; - /** - * Return the HE capabilities. - * - * \return HE capabilities - */ - HeCapabilities GetHeCapabilities (void) const; - /** * Return the Service Set Identifier (SSID). * * \return SSID @@ -303,10 +243,6 @@ Ssid m_ssid; //!< Service Set ID (SSID) SupportedRates m_rates; //!< List of supported rates CapabilityInformation m_capability; //!< Capability information - ExtendedCapabilities m_extendedCapability; //!< Extended capabilities - HtCapabilities m_htCapability; //!< HT capabilities - VhtCapabilities m_vhtCapability; //!< VHT capabilities - HeCapabilities m_heCapability; //!< HE capabilities uint16_t m_listenInterval; //!< listen interval }; @@ -315,7 +251,7 @@ * \ingroup wifi * Implement the header for management frames of type association and reassociation response. */ -class MgtAssocResponseHeader : public Header +class MgtAssocResponseHeader : public MgtCommonHeader { public: MgtAssocResponseHeader (); @@ -340,96 +276,12 @@ */ CapabilityInformation GetCapabilities (void) const; /** - * Return the extended capabilities. - * - * \return the extended capabilities - */ - ExtendedCapabilities GetExtendedCapabilities (void) const; - /** - * Return the HT capabilities. - * - * \return HT capabilities - */ - HtCapabilities GetHtCapabilities (void) const; - /** - * Return the HT operation. - * - * \return HT operation - */ - HtOperation GetHtOperation (void) const; - /** - * Return the VHT capabilities. - * - * \return VHT capabilities - */ - VhtCapabilities GetVhtCapabilities (void) const; - /** - * Return the VHT operation. - * - * \return VHT operation - */ - VhtOperation GetVhtOperation (void) const; - /** - * Return the HE capabilities. - * - * \return HE capabilities - */ - HeCapabilities GetHeCapabilities (void) const; - /** - * Return the HE operation. - * - * \return HE operation - */ - HeOperation GetHeOperation (void) const; - /** - * Return the ERP information. - * - * \return the ERP information - */ - ErpInformation GetErpInformation (void) const; - /** - * Return the EDCA Parameter Set. - * - * \return the EDCA Parameter Set - */ - EdcaParameterSet GetEdcaParameterSet (void) const; - /** * Set the Capability information. * * \param capabilities Capability information */ void SetCapabilities (CapabilityInformation capabilities); /** - * Set the extended capabilities. - * - * \param extendedcapabilities the extended capabilities - */ - void SetExtendedCapabilities (ExtendedCapabilities extendedcapabilities); - /** - * Set the VHT operation. - * - * \param vhtoperation VHT operation - */ - void SetVhtOperation (VhtOperation vhtoperation); - /** - * Set the VHT capabilities. - * - * \param vhtcapabilities VHT capabilities - */ - void SetVhtCapabilities (VhtCapabilities vhtcapabilities); - /** - * Set the HT capabilities. - * - * \param htcapabilities HT capabilities - */ - void SetHtCapabilities (HtCapabilities htcapabilities); - /** - * Set the HT operation. - * - * \param htoperation HT operation - */ - void SetHtOperation (HtOperation htoperation); - /** * Set the supported rates. * * \param rates the supported rates @@ -447,30 +299,6 @@ * \param aid the association ID */ void SetAssociationId (uint16_t aid); - /** - * Set the ERP information. - * - * \param erpInformation the ERP information - */ - void SetErpInformation (ErpInformation erpInformation); - /** - * Set the EDCA Parameter Set. - * - * \param edcaParameterSet the EDCA Parameter Set - */ - void SetEdcaParameterSet (EdcaParameterSet edcaParameterSet); - /** - * Set the HE capabilities. - * - * \param hecapabilities HE capabilities - */ - void SetHeCapabilities (HeCapabilities hecapabilities); - /** - * Set the HE operation. - * - * \param heoperation HE operation - */ - void SetHeOperation (HeOperation heoperation); /** * Register this type. @@ -489,15 +317,6 @@ CapabilityInformation m_capability; //!< Capability information StatusCode m_code; //!< Status code uint16_t m_aid; //!< aid - ExtendedCapabilities m_extendedCapability; //!< extended capabilities - HtCapabilities m_htCapability; //!< HT capabilities - HtOperation m_htOperation; //!< HT operation - VhtCapabilities m_vhtCapability; //!< VHT capabilities - VhtOperation m_vhtOperation; //!< VHT operation - ErpInformation m_erpInformation; //!< ERP information - EdcaParameterSet m_edcaParameterSet; //!< EDCA Parameter Set - HeCapabilities m_heCapability; //!< HE capabilities - HeOperation m_heOperation; //!< HE operation }; @@ -505,7 +324,7 @@ * \ingroup wifi * Implement the header for management frames of type probe request. */ -class MgtProbeRequestHeader : public Header +class MgtProbeRequestHeader : public MgtCommonHeader { public: ~MgtProbeRequestHeader (); @@ -523,30 +342,6 @@ */ void SetSupportedRates (SupportedRates rates); /** - * Set the extended capabilities. - * - * \param extendedcapabilities the extended capabilities - */ - void SetExtendedCapabilities (ExtendedCapabilities extendedcapabilities); - /** - * Set the HT capabilities. - * - * \param htcapabilities HT capabilities - */ - void SetHtCapabilities (HtCapabilities htcapabilities); - /** - * Set the VHT capabilities. - * - * \param vhtcapabilities VHT capabilities - */ - void SetVhtCapabilities (VhtCapabilities vhtcapabilities); - /** - * Set the HE capabilities. - * - * \param hecapabilities HE capabilities - */ - void SetHeCapabilities (HeCapabilities hecapabilities); - /** * Return the Service Set Identifier (SSID). * * \return SSID @@ -558,30 +353,6 @@ * \return the supported rates */ SupportedRates GetSupportedRates (void) const; - /** - * Return the extended capabilities. - * - * \return the extended capabilities - */ - ExtendedCapabilities GetExtendedCapabilities (void) const; - /** - * Return the HT capabilities. - * - * \return HT capabilities - */ - HtCapabilities GetHtCapabilities (void) const; - /** - * Return the VHT capabilities. - * - * \return VHT capabilities - */ - VhtCapabilities GetVhtCapabilities (void) const; - /** - * Return the HE capabilities. - * - * \return HE capabilities - */ - HeCapabilities GetHeCapabilities (void) const; /** * Register this type. @@ -598,10 +369,6 @@ private: Ssid m_ssid; //!< Service Set ID (SSID) SupportedRates m_rates; //!< List of supported rates - ExtendedCapabilities m_extendedCapability; //!< extended capabilities - HtCapabilities m_htCapability; //!< HT capabilities - VhtCapabilities m_vhtCapability; //!< VHT capabilities - HeCapabilities m_heCapability; //!< HE capabilities }; @@ -609,7 +376,7 @@ * \ingroup wifi * Implement the header for management frames of type probe response. */ -class MgtProbeResponseHeader : public Header +class MgtProbeResponseHeader : public MgtCommonHeader { public: MgtProbeResponseHeader (); @@ -640,120 +407,12 @@ */ CapabilityInformation GetCapabilities (void) const; /** - * Return the DSSS Parameter Set. - * - * \return the DSSS Parameter Set - */ - DsssParameterSet GetDsssParameterSet (void) const; - /** - * Return the extended capabilities. - * - * \return the extended capabilities - */ - ExtendedCapabilities GetExtendedCapabilities (void) const; - /** - * Return the HT capabilities. - * - * \return HT capabilities - */ - HtCapabilities GetHtCapabilities (void) const; - /** - * Return the HT operation. - * - * \return HT operation - */ - HtOperation GetHtOperation (void) const; - /** - * Return the VHT capabilities. - * - * \return VHT capabilities - */ - VhtCapabilities GetVhtCapabilities (void) const; - /** - * Return the VHT operation. - * - * \return VHT operation - */ - VhtOperation GetVhtOperation (void) const; - /** - * Return the HE capabilities. - * - * \return HE capabilities - */ - HeCapabilities GetHeCapabilities (void) const; - /** - * Return the HE operation. - * - * \return HE operation - */ - HeOperation GetHeOperation (void) const; - /** - * Return the ERP information. - * - * \return the ERP information - */ - ErpInformation GetErpInformation (void) const; - /** - * Return the EDCA Parameter Set. - * - * \return the EDCA Parameter Set - */ - EdcaParameterSet GetEdcaParameterSet (void) const; - /** - * Return the CF parameter set. - * - * \return CF parameter set - */ - CfParameterSet GetCfParameterSet (void) const; - /** * Set the Capability information. * * \param capabilities Capability information */ void SetCapabilities (CapabilityInformation capabilities); /** - * Set the extended capabilities. - * - * \param extendedcapabilities the extended capabilities - */ - void SetExtendedCapabilities (ExtendedCapabilities extendedcapabilities); - /** - * Set the HT capabilities. - * - * \param htcapabilities HT capabilities - */ - void SetHtCapabilities (HtCapabilities htcapabilities); - /** - * Set the HT operation. - * - * \param htoperation HT operation - */ - void SetHtOperation (HtOperation htoperation); - /** - * Set the VHT capabilities. - * - * \param vhtcapabilities VHT capabilities - */ - void SetVhtCapabilities (VhtCapabilities vhtcapabilities); - /** - * Set the VHT operation. - * - * \param vhtoperation VHT operation - */ - void SetVhtOperation (VhtOperation vhtoperation); - /** - * Set the HE capabilities. - * - * \param hecapabilities HE capabilities - */ - void SetHeCapabilities (HeCapabilities hecapabilities); - /** - * Set the HE operation. - * - * \param heoperation HE operation - */ - void SetHeOperation (HeOperation heoperation); - /** * Set the Service Set Identifier (SSID). * * \param ssid SSID @@ -772,30 +431,6 @@ */ void SetSupportedRates (SupportedRates rates); /** - * Set the DSSS Parameter Set. - * - * \param dsssParameterSet the DSSS Parameter Set - */ - void SetDsssParameterSet (DsssParameterSet dsssParameterSet); - /** - * Set the ERP information. - * - * \param erpInformation the ERP information - */ - void SetErpInformation (ErpInformation erpInformation); - /** - * Set the EDCA Parameter Set. - * - * \param edcaParameterSet the EDCA Parameter Set - */ - void SetEdcaParameterSet (EdcaParameterSet edcaParameterSet); - /** - * Set the CF parameter set. - * - * \param cfparameterset CF parameter set - */ - void SetCfParameterSet (CfParameterSet cfparameterset); - /** * Return the time stamp. * * \return time stamp @@ -820,17 +455,6 @@ uint64_t m_beaconInterval; //!< Beacon interval SupportedRates m_rates; //!< List of supported rates CapabilityInformation m_capability; //!< Capability information - DsssParameterSet m_dsssParameterSet; //!< DSSS Parameter Set - ExtendedCapabilities m_extendedCapability; //!< extended capabilities - HtCapabilities m_htCapability; //!< HT capabilities - HtOperation m_htOperation; //!< HT operation - VhtCapabilities m_vhtCapability; //!< VHT capabilities - VhtOperation m_vhtOperation; //!< VHT operation - HeCapabilities m_heCapability; //!< HE capabilities - HeOperation m_heOperation; //!< HE operation - ErpInformation m_erpInformation; //!< ERP information - EdcaParameterSet m_edcaParameterSet; //!< EDCA Parameter Set - CfParameterSet m_cfParameterSet; //!< CF parameter set }; diff -r c648032c8079 src/wifi/model/regular-wifi-mac.cc --- a/src/wifi/model/regular-wifi-mac.cc Fri Jul 06 11:14:13 2018 +0300 +++ b/src/wifi/model/regular-wifi-mac.cc Sun Jul 08 21:56:33 2018 +0200 @@ -143,49 +143,49 @@ return m_stationManager; } -ExtendedCapabilities +Ptr RegularWifiMac::GetExtendedCapabilities (void) const { NS_LOG_FUNCTION (this); - ExtendedCapabilities capabilities; + Ptr capabilities = Create (); if (m_htSupported || m_vhtSupported) { if (m_htSupported) { - capabilities.SetHtSupported (1); + capabilities->SetHtSupported (1); } if (m_vhtSupported) { - capabilities.SetVhtSupported (1); + capabilities->SetVhtSupported (1); } } //TODO: to be completed return capabilities; } -HtCapabilities +Ptr RegularWifiMac::GetHtCapabilities (void) const { NS_LOG_FUNCTION (this); - HtCapabilities capabilities; - if (m_htSupported) + Ptr capabilities = Create (); + if (m_htSupported || m_vhtSupported || m_heSupported) { - capabilities.SetHtSupported (1); - capabilities.SetLdpc (m_phy->GetLdpc ()); - capabilities.SetSupportedChannelWidth (m_phy->GetChannelWidth () >= 40); - capabilities.SetShortGuardInterval20 (m_phy->GetShortGuardInterval ()); - capabilities.SetShortGuardInterval40 (m_phy->GetChannelWidth () >= 40 && m_phy->GetShortGuardInterval ()); - capabilities.SetGreenfield (m_phy->GetGreenfield ()); + capabilities->SetHtSupported (1); + capabilities->SetLdpc (m_phy->GetLdpc ()); + capabilities->SetSupportedChannelWidth (m_phy->GetChannelWidth () >= 40); + capabilities->SetShortGuardInterval20 (m_phy->GetShortGuardInterval ()); + capabilities->SetShortGuardInterval40 (m_phy->GetChannelWidth () >= 40 && m_phy->GetShortGuardInterval ()); + capabilities->SetGreenfield (m_phy->GetGreenfield ()); uint32_t maxAmsduLength = std::max (std::max (m_beMaxAmsduSize, m_bkMaxAmsduSize), std::max (m_voMaxAmsduSize, m_viMaxAmsduSize)); - capabilities.SetMaxAmsduLength (maxAmsduLength > 3839); //0 if 3839 and 1 if 7935 - capabilities.SetLSigProtectionSupport (!m_phy->GetGreenfield ()); + capabilities->SetMaxAmsduLength (maxAmsduLength > 3839); //0 if 3839 and 1 if 7935 + capabilities->SetLSigProtectionSupport (!m_phy->GetGreenfield ()); double maxAmpduLengthExponent = std::max (std::ceil ((std::log (std::max (std::max (m_beMaxAmpduSize, m_bkMaxAmpduSize), std::max (m_voMaxAmpduSize, m_viMaxAmpduSize)) + 1.0) / std::log (2.0)) - 13.0), 0.0); NS_ASSERT (maxAmpduLengthExponent >= 0 && maxAmpduLengthExponent <= 255); - capabilities.SetMaxAmpduLength (std::max (3, static_cast (maxAmpduLengthExponent))); //0 to 3 for HT + capabilities->SetMaxAmpduLength (std::max (3, static_cast (maxAmpduLengthExponent))); //0 to 3 for HT uint64_t maxSupportedRate = 0; //in bit/s for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) { @@ -194,7 +194,7 @@ { continue; } - capabilities.SetRxMcsBitmask (mcs.GetMcsValue ()); + capabilities->SetRxMcsBitmask (mcs.GetMcsValue ()); uint8_t nss = (mcs.GetMcsValue () / 8) + 1; NS_ASSERT (nss > 0 && nss < 5); uint64_t dataRate = mcs.GetDataRate (m_phy->GetChannelWidth (), m_phy->GetShortGuardInterval () ? 400 : 800, nss); @@ -204,40 +204,40 @@ NS_LOG_DEBUG ("Updating maxSupportedRate to " << maxSupportedRate); } } - capabilities.SetRxHighestSupportedDataRate (static_cast (maxSupportedRate / 1e6)); //in Mbit/s - capabilities.SetTxMcsSetDefined (m_phy->GetNMcs () > 0); - capabilities.SetTxMaxNSpatialStreams (m_phy->GetMaxSupportedTxSpatialStreams ()); + capabilities->SetRxHighestSupportedDataRate (static_cast (maxSupportedRate / 1e6)); //in Mbit/s + capabilities->SetTxMcsSetDefined (m_phy->GetNMcs () > 0); + capabilities->SetTxMaxNSpatialStreams (m_phy->GetMaxSupportedTxSpatialStreams ()); //we do not support unequal modulations - capabilities.SetTxRxMcsSetUnequal (0); - capabilities.SetTxUnequalModulation (0); + capabilities->SetTxRxMcsSetUnequal (0); + capabilities->SetTxUnequalModulation (0); } return capabilities; } -VhtCapabilities +Ptr RegularWifiMac::GetVhtCapabilities (void) const { NS_LOG_FUNCTION (this); - VhtCapabilities capabilities; - if (m_vhtSupported) + Ptr capabilities = Create (); + if (m_vhtSupported || m_heSupported) { - capabilities.SetVhtSupported (1); + capabilities->SetVhtSupported (1); if (m_phy->GetChannelWidth () == 160) { - capabilities.SetSupportedChannelWidthSet (1); + capabilities->SetSupportedChannelWidthSet (1); } else { - capabilities.SetSupportedChannelWidthSet (0); + capabilities->SetSupportedChannelWidthSet (0); } uint32_t maxMpduLength = std::max (std::max (m_beMaxAmsduSize, m_bkMaxAmsduSize), std::max (m_voMaxAmsduSize, m_viMaxAmsduSize)) + 56; //see section 9.11 of 11ac standard - capabilities.SetMaxMpduLength (uint8_t (maxMpduLength > 3895) + uint8_t (maxMpduLength > 7991)); //0 if 3895, 1 if 7991, 2 for 11454 - capabilities.SetRxLdpc (m_phy->GetLdpc ()); - capabilities.SetShortGuardIntervalFor80Mhz ((m_phy->GetChannelWidth () == 80) && m_phy->GetShortGuardInterval ()); - capabilities.SetShortGuardIntervalFor160Mhz ((m_phy->GetChannelWidth () == 160) && m_phy->GetShortGuardInterval ()); + capabilities->SetMaxMpduLength (uint8_t (maxMpduLength > 3895) + uint8_t (maxMpduLength > 7991)); //0 if 3895, 1 if 7991, 2 for 11454 + capabilities->SetRxLdpc (m_phy->GetLdpc ()); + capabilities->SetShortGuardIntervalFor80Mhz ((m_phy->GetChannelWidth () == 80) && m_phy->GetShortGuardInterval ()); + capabilities->SetShortGuardIntervalFor160Mhz ((m_phy->GetChannelWidth () == 160) && m_phy->GetShortGuardInterval ()); double maxAmpduLengthExponent = std::max (std::ceil ((std::log (std::max (std::max (m_beMaxAmpduSize, m_bkMaxAmpduSize), std::max (m_voMaxAmpduSize, m_viMaxAmpduSize)) + 1.0) / std::log (2.0)) - 13.0), 0.0); NS_ASSERT (maxAmpduLengthExponent >= 0 && maxAmpduLengthExponent <= 255); - capabilities.SetMaxAmpduLengthExponent (std::max (7, static_cast (maxAmpduLengthExponent))); //0 to 7 for VHT + capabilities->SetMaxAmpduLengthExponent (std::max (7, static_cast (maxAmpduLengthExponent))); //0 to 7 for VHT uint8_t maxMcs = 0; for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) { @@ -248,14 +248,20 @@ maxMcs = mcs.GetMcsValue (); } } + //This is a workaround, a bug should be opened for this! + //TODO: HE shall support VHT and HT rates! + if (m_heSupported) + { + maxMcs = 9; + } // Support same MaxMCS for each spatial stream for (uint8_t nss = 1; nss <= m_phy->GetMaxSupportedRxSpatialStreams (); nss++) { - capabilities.SetRxMcsMap (maxMcs, nss); + capabilities->SetRxMcsMap (maxMcs, nss); } for (uint8_t nss = 1; nss <= m_phy->GetMaxSupportedTxSpatialStreams (); nss++) { - capabilities.SetTxMcsMap (maxMcs, nss); + capabilities->SetTxMcsMap (maxMcs, nss); } uint64_t maxSupportedRateLGI = 0; //in bit/s for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) @@ -271,23 +277,23 @@ NS_LOG_DEBUG ("Updating maxSupportedRateLGI to " << maxSupportedRateLGI); } } - capabilities.SetRxHighestSupportedLgiDataRate (static_cast (maxSupportedRateLGI / 1e6)); //in Mbit/s - capabilities.SetTxHighestSupportedLgiDataRate (static_cast (maxSupportedRateLGI / 1e6)); //in Mbit/s + capabilities->SetRxHighestSupportedLgiDataRate (static_cast (maxSupportedRateLGI / 1e6)); //in Mbit/s + capabilities->SetTxHighestSupportedLgiDataRate (static_cast (maxSupportedRateLGI / 1e6)); //in Mbit/s //To be filled in once supported - capabilities.SetRxStbc (0); - capabilities.SetTxStbc (0); + capabilities->SetRxStbc (0); + capabilities->SetTxStbc (0); } return capabilities; } -HeCapabilities +Ptr RegularWifiMac::GetHeCapabilities (void) const { NS_LOG_FUNCTION (this); - HeCapabilities capabilities; + Ptr capabilities = Create (); if (m_heSupported) { - capabilities.SetHeSupported (1); + capabilities->SetHeSupported (1); uint8_t channelWidthSet = 0; if (m_phy->GetChannelWidth () >= 40 && Is2_4Ghz (m_phy->GetFrequency ())) { @@ -301,7 +307,7 @@ { channelWidthSet |= 0x04; } - capabilities.SetChannelWidthSet (channelWidthSet); + capabilities->SetChannelWidthSet (channelWidthSet); uint8_t gi = 0; if (m_phy->GetGuardInterval () <= NanoSeconds (1600)) { @@ -312,14 +318,14 @@ { gi |= 0x02; } - capabilities.SetHeLtfAndGiForHePpdus (gi); + capabilities->SetHeLtfAndGiForHePpdus (gi); double maxAmpduLengthExponent = std::max (std::ceil ((std::log (std::max (std::max (m_beMaxAmpduSize, m_bkMaxAmpduSize), std::max (m_voMaxAmpduSize, m_viMaxAmpduSize)) + 1.0) / std::log (2.0)) - 13.0), 0.0); NS_ASSERT (maxAmpduLengthExponent >= 0 && maxAmpduLengthExponent <= 255); - capabilities.SetMaxAmpduLengthExponent (std::max (7, static_cast (maxAmpduLengthExponent))); //assume 0 to 7 for HE + capabilities->SetMaxAmpduLengthExponent (std::max (7, static_cast (maxAmpduLengthExponent))); //assume 0 to 7 for HE uint8_t maxMcs = 0; for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) { @@ -330,8 +336,8 @@ maxMcs = mcs.GetMcsValue (); } } - capabilities.SetHighestMcsSupported (maxMcs); - capabilities.SetHighestNssSupported (m_phy->GetMaxSupportedTxSpatialStreams ()); + capabilities->SetHighestMcsSupported (maxMcs); + capabilities->SetHighestNssSupported (m_phy->GetMaxSupportedTxSpatialStreams ()); } return capabilities; } diff -r c648032c8079 src/wifi/model/regular-wifi-mac.h --- a/src/wifi/model/regular-wifi-mac.h Fri Jul 06 11:14:13 2018 +0300 +++ b/src/wifi/model/regular-wifi-mac.h Sun Jul 08 21:56:33 2018 +0200 @@ -230,25 +230,25 @@ * * \return the extended capabilities that we support */ - ExtendedCapabilities GetExtendedCapabilities (void) const; + Ptr GetExtendedCapabilities (void) const; /** * Return the HT capabilities of the device. * * \return the HT capabilities that we support */ - HtCapabilities GetHtCapabilities (void) const; + Ptr GetHtCapabilities (void) const; /** * Return the VHT capabilities of the device. * * \return the VHT capabilities that we support */ - VhtCapabilities GetVhtCapabilities (void) const; + Ptr GetVhtCapabilities (void) const; /** * Return the HE capabilities of the device. * * \return the HE capabilities that we support */ - HeCapabilities GetHeCapabilities (void) const; + Ptr GetHeCapabilities (void) const; /** * This type defines the callback of a higher layer that a diff -r c648032c8079 src/wifi/model/sta-wifi-mac.cc --- a/src/wifi/model/sta-wifi-mac.cc Fri Jul 06 11:14:13 2018 +0300 +++ b/src/wifi/model/sta-wifi-mac.cc Sun Jul 08 21:56:33 2018 +0200 @@ -157,16 +157,16 @@ probe.SetSupportedRates (GetSupportedRates ()); if (GetHtSupported () || GetVhtSupported () || GetHeSupported ()) { - probe.SetExtendedCapabilities (GetExtendedCapabilities ()); - probe.SetHtCapabilities (GetHtCapabilities ()); + probe.AddWifiInformationElement (GetExtendedCapabilities ()); + probe.AddWifiInformationElement (GetHtCapabilities ()); } if (GetVhtSupported () || GetHeSupported ()) { - probe.SetVhtCapabilities (GetVhtCapabilities ()); + probe.AddWifiInformationElement (GetVhtCapabilities ()); } if (GetHeSupported ()) { - probe.SetHeCapabilities (GetHeCapabilities ()); + probe.AddWifiInformationElement (GetHeCapabilities ()); } packet->AddHeader (probe); @@ -199,16 +199,16 @@ assoc.SetListenInterval (0); if (GetHtSupported () || GetVhtSupported () || GetHeSupported ()) { - assoc.SetExtendedCapabilities (GetExtendedCapabilities ()); - assoc.SetHtCapabilities (GetHtCapabilities ()); + assoc.AddWifiInformationElement (GetExtendedCapabilities ()); + assoc.AddWifiInformationElement (GetHtCapabilities ()); } if (GetVhtSupported () || GetHeSupported ()) { - assoc.SetVhtCapabilities (GetVhtCapabilities ()); + assoc.AddWifiInformationElement (GetVhtCapabilities ()); } if (GetHeSupported ()) { - assoc.SetHeCapabilities (GetHeCapabilities ()); + assoc.AddWifiInformationElement (GetHeCapabilities ()); } packet->AddHeader (assoc); } @@ -222,16 +222,16 @@ reassoc.SetListenInterval (0); if (GetHtSupported () || GetVhtSupported () || GetHeSupported ()) { - reassoc.SetExtendedCapabilities (GetExtendedCapabilities ()); - reassoc.SetHtCapabilities (GetHtCapabilities ()); + reassoc.AddWifiInformationElement (GetExtendedCapabilities ()); + reassoc.AddWifiInformationElement (GetHtCapabilities ()); } if (GetVhtSupported () || GetHeSupported ()) { - reassoc.SetVhtCapabilities (GetVhtCapabilities ()); + reassoc.AddWifiInformationElement (GetVhtCapabilities ()); } if (GetHeSupported ()) { - reassoc.SetHeCapabilities (GetHeCapabilities ()); + reassoc.AddWifiInformationElement (GetHeCapabilities ()); } packet->AddHeader (reassoc); } @@ -570,17 +570,17 @@ NS_LOG_LOGIC ("Beacon is for our SSID"); goodBeacon = true; } - CfParameterSet cfParameterSet = beacon.GetCfParameterSet (); - if (cfParameterSet.GetCFPCount () == 0) + Ptr cfParameterSet = StaticCast (beacon.GetInformationElement (IE_CF_PARAMETER_SET)); + if (cfParameterSet != 0 && cfParameterSet->GetCFPCount () == 0) { //see section 9.3.2.2 802.11-1999 if (GetPcfSupported ()) { - m_low->DoNavStartNow (MicroSeconds (cfParameterSet.GetCFPMaxDurationUs ())); + m_low->DoNavStartNow (MicroSeconds (cfParameterSet->GetCFPMaxDurationUs ())); } else { - m_low->DoNavStartNow (MicroSeconds (cfParameterSet.GetCFPDurRemainingUs ())); + m_low->DoNavStartNow (MicroSeconds (cfParameterSet->GetCFPDurRemainingUs ())); } } SupportedRates rates = beacon.GetSupportedRates (); @@ -744,15 +744,18 @@ bool isShortPreambleEnabled = capabilities.IsShortPreamble (); if (GetErpSupported ()) { - ErpInformation erpInformation = beacon.GetErpInformation (); - isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode (); - if (erpInformation.GetUseProtection () != 0) + Ptr erpInformation = StaticCast (beacon.GetInformationElement (IE_ERP_INFORMATION)); + if (erpInformation != 0) { - m_stationManager->SetUseNonErpProtection (true); - } - else - { - m_stationManager->SetUseNonErpProtection (false); + isShortPreambleEnabled &= !erpInformation->GetBarkerPreambleMode (); + if (erpInformation->GetUseProtection () != 0) + { + m_stationManager->SetUseNonErpProtection (true); + } + else + { + m_stationManager->SetUseNonErpProtection (false); + } } if (capabilities.IsShortSlotTime () == true) { @@ -768,30 +771,31 @@ if (GetQosSupported ()) { bool qosSupported = false; - EdcaParameterSet edcaParameters = beacon.GetEdcaParameterSet (); - if (edcaParameters.IsQosSupported ()) + Ptr edcaParameters = StaticCast (beacon.GetInformationElement (IE_EDCA_PARAMETER_SET)); + if (edcaParameters != 0 && edcaParameters->IsQosSupported ()) { qosSupported = true; //The value of the TXOP Limit field is specified as an unsigned integer, with the least significant octet transmitted first, in units of 32 μs. - SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTXOPLimit ())); - SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTXOPLimit ())); - SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTXOPLimit ())); - SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTXOPLimit ())); + SetEdcaParameters (AC_BE, edcaParameters->GetBeCWmin (), edcaParameters->GetBeCWmax (), edcaParameters->GetBeAifsn (), 32 * MicroSeconds (edcaParameters->GetBeTXOPLimit ())); + SetEdcaParameters (AC_BK, edcaParameters->GetBkCWmin (), edcaParameters->GetBkCWmax (), edcaParameters->GetBkAifsn (), 32 * MicroSeconds (edcaParameters->GetBkTXOPLimit ())); + SetEdcaParameters (AC_VI, edcaParameters->GetViCWmin (), edcaParameters->GetViCWmax (), edcaParameters->GetViAifsn (), 32 * MicroSeconds (edcaParameters->GetViTXOPLimit ())); + SetEdcaParameters (AC_VO, edcaParameters->GetVoCWmin (), edcaParameters->GetVoCWmax (), edcaParameters->GetVoAifsn (), 32 * MicroSeconds (edcaParameters->GetVoTXOPLimit ())); } m_stationManager->SetQosSupport (apAddr, qosSupported); } if (GetHtSupported ()) { - HtCapabilities htCapabilities = beacon.GetHtCapabilities (); - if (!htCapabilities.IsSupportedMcs (0)) + Ptr htCapabilities = StaticCast (beacon.GetInformationElement (IE_HT_CAPABILITIES)); + if (htCapabilities == 0) { m_stationManager->RemoveAllSupportedMcs (apAddr); } else { m_stationManager->AddStationHtCapabilities (apAddr, htCapabilities); - HtOperation htOperation = beacon.GetHtOperation (); - if (htOperation.GetNonGfHtStasPresent ()) + Ptr htOperation = StaticCast (beacon.GetInformationElement (IE_HT_OPERATION)); + NS_ASSERT (htOperation != 0); + if (htOperation->GetNonGfHtStasPresent ()) { m_stationManager->SetUseGreenfieldProtection (true); } @@ -799,7 +803,7 @@ { m_stationManager->SetUseGreenfieldProtection (false); } - if (!GetVhtSupported () && GetRifsSupported () && htOperation.GetRifsMode ()) + if (!GetVhtSupported () && GetRifsSupported () && htOperation->GetRifsMode ()) { m_stationManager->SetRifsPermitted (true); } @@ -811,16 +815,17 @@ } if (GetVhtSupported ()) { - VhtCapabilities vhtCapabilities = beacon.GetVhtCapabilities (); + Ptr vhtCapabilities = StaticCast (beacon.GetInformationElement (IE_VHT_CAPABILITIES)); //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT - if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0) + if (vhtCapabilities != 0) { m_stationManager->AddStationVhtCapabilities (apAddr, vhtCapabilities); - VhtOperation vhtOperation = beacon.GetVhtOperation (); + Ptr vhtOperation = StaticCast (beacon.GetInformationElement (IE_VHT_OPERATION)); + NS_ASSERT (vhtOperation != 0); for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) { WifiMode mcs = m_phy->GetMcs (i); - if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ())) + if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities->IsSupportedRxMcs (mcs.GetMcsValue ())) { m_stationManager->AddSupportedMcs (apAddr, mcs); } @@ -829,21 +834,24 @@ } if (GetHtSupported () || GetVhtSupported ()) { - ExtendedCapabilities extendedCapabilities = beacon.GetExtendedCapabilities (); + Ptr extendedCapabilities = StaticCast (beacon.GetInformationElement (IE_EXTENDED_CAPABILITIES)); //TODO: to be completed } if (GetHeSupported ()) { - HeCapabilities heCapabilities = beacon.GetHeCapabilities (); - //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer - m_stationManager->AddStationHeCapabilities (apAddr, heCapabilities); - HeOperation heOperation = beacon.GetHeOperation (); - for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) + Ptr heCapabilities = StaticCast (beacon.GetInformationElement (IE_HE_CAPABILITIES)); + if (heCapabilities != 0) { - WifiMode mcs = m_phy->GetMcs (i); - if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ())) + m_stationManager->AddStationHeCapabilities (apAddr, heCapabilities); + Ptr heOperation = StaticCast (beacon.GetInformationElement (IE_HE_OPERATION)); + NS_ASSERT (heOperation != 0); + for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) { - m_stationManager->AddSupportedMcs (apAddr, mcs); + WifiMode mcs = m_phy->GetMcs (i); + if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities->IsSupportedRxMcs (mcs.GetMcsValue ())) + { + m_stationManager->AddSupportedMcs (apAddr, mcs); + } } } } @@ -900,8 +908,11 @@ } else { - ErpInformation erpInformation = probeResp.GetErpInformation (); - isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode (); + Ptr erpInformation = StaticCast (probeResp.GetInformationElement (IE_ERP_INFORMATION)); + if (erpInformation != 0) + { + isShortPreambleEnabled &= !erpInformation->GetBarkerPreambleMode (); + } if (m_stationManager->GetShortSlotTimeEnabled ()) { //enable short slot time @@ -947,8 +958,11 @@ } else { - ErpInformation erpInformation = assocResp.GetErpInformation (); - isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode (); + Ptr erpInformation = StaticCast (assocResp.GetInformationElement (IE_ERP_INFORMATION)); + if (erpInformation != 0) + { + isShortPreambleEnabled &= !erpInformation->GetBarkerPreambleMode (); + } if (m_stationManager->GetShortSlotTimeEnabled ()) { //enable short slot time @@ -967,30 +981,31 @@ if (GetQosSupported ()) { bool qosSupported = false; - EdcaParameterSet edcaParameters = assocResp.GetEdcaParameterSet (); - if (edcaParameters.IsQosSupported ()) + Ptr edcaParameters = StaticCast (assocResp.GetInformationElement (IE_EDCA_PARAMETER_SET)); + if (edcaParameters != 0 && edcaParameters->IsQosSupported ()) { qosSupported = true; //The value of the TXOP Limit field is specified as an unsigned integer, with the least significant octet transmitted first, in units of 32 μs. - SetEdcaParameters (AC_BE, edcaParameters.GetBeCWmin (), edcaParameters.GetBeCWmax (), edcaParameters.GetBeAifsn (), 32 * MicroSeconds (edcaParameters.GetBeTXOPLimit ())); - SetEdcaParameters (AC_BK, edcaParameters.GetBkCWmin (), edcaParameters.GetBkCWmax (), edcaParameters.GetBkAifsn (), 32 * MicroSeconds (edcaParameters.GetBkTXOPLimit ())); - SetEdcaParameters (AC_VI, edcaParameters.GetViCWmin (), edcaParameters.GetViCWmax (), edcaParameters.GetViAifsn (), 32 * MicroSeconds (edcaParameters.GetViTXOPLimit ())); - SetEdcaParameters (AC_VO, edcaParameters.GetVoCWmin (), edcaParameters.GetVoCWmax (), edcaParameters.GetVoAifsn (), 32 * MicroSeconds (edcaParameters.GetVoTXOPLimit ())); + SetEdcaParameters (AC_BE, edcaParameters->GetBeCWmin (), edcaParameters->GetBeCWmax (), edcaParameters->GetBeAifsn (), 32 * MicroSeconds (edcaParameters->GetBeTXOPLimit ())); + SetEdcaParameters (AC_BK, edcaParameters->GetBkCWmin (), edcaParameters->GetBkCWmax (), edcaParameters->GetBkAifsn (), 32 * MicroSeconds (edcaParameters->GetBkTXOPLimit ())); + SetEdcaParameters (AC_VI, edcaParameters->GetViCWmin (), edcaParameters->GetViCWmax (), edcaParameters->GetViAifsn (), 32 * MicroSeconds (edcaParameters->GetViTXOPLimit ())); + SetEdcaParameters (AC_VO, edcaParameters->GetVoCWmin (), edcaParameters->GetVoCWmax (), edcaParameters->GetVoAifsn (), 32 * MicroSeconds (edcaParameters->GetVoTXOPLimit ())); } m_stationManager->SetQosSupport (apAddr, qosSupported); } if (GetHtSupported ()) { - HtCapabilities htCapabilities = assocResp.GetHtCapabilities (); - if (!htCapabilities.IsSupportedMcs (0)) + Ptr htCapabilities = StaticCast (assocResp.GetInformationElement (IE_HT_CAPABILITIES)); + if (htCapabilities == 0) { m_stationManager->RemoveAllSupportedMcs (apAddr); } else { m_stationManager->AddStationHtCapabilities (apAddr, htCapabilities); - HtOperation htOperation = assocResp.GetHtOperation (); - if (htOperation.GetNonGfHtStasPresent ()) + Ptr htOperation = StaticCast (assocResp.GetInformationElement (IE_HT_OPERATION)); + NS_ASSERT (htOperation != 0); + if (htOperation->GetNonGfHtStasPresent ()) { m_stationManager->SetUseGreenfieldProtection (true); } @@ -998,7 +1013,7 @@ { m_stationManager->SetUseGreenfieldProtection (false); } - if (!GetVhtSupported () && GetRifsSupported () && htOperation.GetRifsMode ()) + if (!GetVhtSupported () && GetRifsSupported () && htOperation->GetRifsMode ()) { m_stationManager->SetRifsPermitted (true); } @@ -1010,20 +1025,20 @@ } if (GetVhtSupported ()) { - VhtCapabilities vhtCapabilities = assocResp.GetVhtCapabilities (); + Ptr vhtCapabilities = StaticCast (assocResp.GetInformationElement (IE_VHT_CAPABILITIES)); //we will always fill in RxHighestSupportedLgiDataRate field at TX, so this can be used to check whether it supports VHT - if (vhtCapabilities.GetRxHighestSupportedLgiDataRate () > 0) + if (vhtCapabilities != 0) { m_stationManager->AddStationVhtCapabilities (apAddr, vhtCapabilities); - VhtOperation vhtOperation = assocResp.GetVhtOperation (); + Ptr vhtOperation = StaticCast (assocResp.GetInformationElement (IE_VHT_OPERATION)); } } if (GetHeSupported ()) { - HeCapabilities hecapabilities = assocResp.GetHeCapabilities (); + Ptr hecapabilities = StaticCast (assocResp.GetInformationElement (IE_HE_CAPABILITIES)); //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer m_stationManager->AddStationHeCapabilities (apAddr, hecapabilities); - HeOperation heOperation = assocResp.GetHeOperation (); + Ptr heOperation = StaticCast (assocResp.GetInformationElement (IE_HE_OPERATION)); } for (uint8_t i = 0; i < m_phy->GetNModes (); i++) { @@ -1039,45 +1054,54 @@ } if (GetHtSupported ()) { - HtCapabilities htCapabilities = assocResp.GetHtCapabilities (); - for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) + Ptr htCapabilities = StaticCast (assocResp.GetInformationElement (IE_HT_CAPABILITIES)); + if (htCapabilities != 0) { - WifiMode mcs = m_phy->GetMcs (i); - if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities.IsSupportedMcs (mcs.GetMcsValue ())) + for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) { - m_stationManager->AddSupportedMcs (apAddr, mcs); - //here should add a control to add basic MCS when it is implemented + WifiMode mcs = m_phy->GetMcs (i); + if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities->IsSupportedMcs (mcs.GetMcsValue ())) + { + m_stationManager->AddSupportedMcs (apAddr, mcs); + //here should add a control to add basic MCS when it is implemented + } } } } if (GetVhtSupported ()) { - VhtCapabilities vhtcapabilities = assocResp.GetVhtCapabilities (); - for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) + Ptr vhtcapabilities = StaticCast (assocResp.GetInformationElement (IE_VHT_CAPABILITIES)); + if (vhtcapabilities != 0) { - WifiMode mcs = m_phy->GetMcs (i); - if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtcapabilities.IsSupportedRxMcs (mcs.GetMcsValue ())) + for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) { - m_stationManager->AddSupportedMcs (apAddr, mcs); - //here should add a control to add basic MCS when it is implemented + WifiMode mcs = m_phy->GetMcs (i); + if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtcapabilities->IsSupportedRxMcs (mcs.GetMcsValue ())) + { + m_stationManager->AddSupportedMcs (apAddr, mcs); + //here should add a control to add basic MCS when it is implemented + } } } } if (GetHtSupported () || GetVhtSupported ()) { - ExtendedCapabilities extendedCapabilities = assocResp.GetExtendedCapabilities (); + Ptr extendedCapabilities = StaticCast (assocResp.GetInformationElement (IE_EXTENDED_CAPABILITIES)); //TODO: to be completed } if (GetHeSupported ()) { - HeCapabilities heCapabilities = assocResp.GetHeCapabilities (); - for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) + Ptr heCapabilities = StaticCast (assocResp.GetInformationElement (IE_HE_CAPABILITIES)); + if (heCapabilities != 0) { - WifiMode mcs = m_phy->GetMcs (i); - if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities.IsSupportedRxMcs (mcs.GetMcsValue ())) + for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) { - m_stationManager->AddSupportedMcs (apAddr, mcs); - //here should add a control to add basic MCS when it is implemented + WifiMode mcs = m_phy->GetMcs (i); + if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE && heCapabilities->IsSupportedRxMcs (mcs.GetMcsValue ())) + { + m_stationManager->AddSupportedMcs (apAddr, mcs); + //here should add a control to add basic MCS when it is implemented + } } } } diff -r c648032c8079 src/wifi/model/wifi-information-element.cc --- a/src/wifi/model/wifi-information-element.cc Fri Jul 06 11:14:13 2018 +0300 +++ b/src/wifi/model/wifi-information-element.cc Sun Jul 08 21:56:33 2018 +0200 @@ -84,6 +84,14 @@ return i; } +Buffer::Iterator +WifiInformationElement::DeserializeElementBody (Buffer::Iterator i, uint8_t length) +{ + DeserializeInformationField (i, length); + i.Next (length); + return i; +} + bool WifiInformationElement::operator== (WifiInformationElement const & a) const { diff -r c648032c8079 src/wifi/model/wifi-information-element.h --- a/src/wifi/model/wifi-information-element.h Fri Jul 06 11:14:13 2018 +0300 +++ b/src/wifi/model/wifi-information-element.h Sun Jul 08 21:56:33 2018 +0200 @@ -186,7 +186,7 @@ // 200 to 220 are reserved #define IE_VENDOR_SPECIFIC ((WifiInformationElementId)221) // 222 to 255 are reserved -#define IE_HE_CAPABILITIES ((WifiInformationElementId)255) //todo: not defined yet in the standard! +#define IE_HE_CAPABILITIES ((WifiInformationElementId)254) //todo: not defined yet in the standard! #define IE_HE_OPERATION ((WifiInformationElementId)255) //todo: not defined yet in the standard! @@ -262,6 +262,15 @@ */ Buffer::Iterator DeserializeIfPresent (Buffer::Iterator i); /** + * Deserialize IE Body. The iterator passed in must be pointing at + * the Element Body of an information element. + * + * \param i an iterator which points to where the IE body should be read. + * + * \return an iterator + */ + Buffer::Iterator DeserializeElementBody (Buffer::Iterator i, uint8_t length); + /** * Get the size of the serialized IE including Element ID and * length fields. * diff -r c648032c8079 src/wifi/model/wifi-remote-station-manager.cc --- a/src/wifi/model/wifi-remote-station-manager.cc Fri Jul 06 11:14:13 2018 +0300 +++ b/src/wifi/model/wifi-remote-station-manager.cc Sun Jul 08 21:56:33 2018 +0200 @@ -1720,14 +1720,14 @@ } void -WifiRemoteStationManager::AddStationHtCapabilities (Mac48Address from, HtCapabilities htCapabilities) +WifiRemoteStationManager::AddStationHtCapabilities (Mac48Address from, Ptr htCapabilities) { //Used by all stations to record HT capabilities of remote stations NS_LOG_FUNCTION (this << from << htCapabilities); WifiRemoteStationState *state; state = LookupState (from); - state->m_shortGuardInterval = htCapabilities.GetShortGuardInterval20 (); - if (htCapabilities.GetSupportedChannelWidth () == 1) + state->m_shortGuardInterval = htCapabilities->GetShortGuardInterval20 (); + if (htCapabilities->GetSupportedChannelWidth () == 1) { state->m_channelWidth = 40; } @@ -1736,12 +1736,12 @@ state->m_channelWidth = 20; } SetQosSupport (from, true); - state->m_greenfield = htCapabilities.GetGreenfield (); - state->m_streams = htCapabilities.GetRxHighestSupportedAntennas (); + state->m_greenfield = htCapabilities->GetGreenfield (); + state->m_streams = htCapabilities->GetRxHighestSupportedAntennas (); for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++) { WifiMode mcs = m_wifiPhy->GetMcs (j); - if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities.IsSupportedMcs (mcs.GetMcsValue ())) + if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HT && htCapabilities->IsSupportedMcs (mcs.GetMcsValue ())) { AddSupportedMcs (from, mcs); } @@ -1750,13 +1750,13 @@ } void -WifiRemoteStationManager::AddStationVhtCapabilities (Mac48Address from, VhtCapabilities vhtCapabilities) +WifiRemoteStationManager::AddStationVhtCapabilities (Mac48Address from, Ptr vhtCapabilities) { //Used by all stations to record VHT capabilities of remote stations NS_LOG_FUNCTION (this << from << vhtCapabilities); WifiRemoteStationState *state; state = LookupState (from); - if (vhtCapabilities.GetSupportedChannelWidthSet () == 1) + if (vhtCapabilities->GetSupportedChannelWidthSet () == 1) { state->m_channelWidth = 160; } @@ -1770,14 +1770,14 @@ { state->m_channelWidth = m_wifiPhy->GetChannelWidth (); } - state->m_ldpc = (vhtCapabilities.GetRxLdpc () != 0); - state->m_stbc = (vhtCapabilities.GetTxStbc () != 0 || vhtCapabilities.GetRxStbc () != 0); + state->m_ldpc = (vhtCapabilities->GetRxLdpc () != 0); + state->m_stbc = (vhtCapabilities->GetTxStbc () != 0 || vhtCapabilities->GetRxStbc () != 0); for (uint8_t i = 1; i <= m_wifiPhy->GetMaxSupportedTxSpatialStreams (); i++) { for (uint8_t j = 0; j < m_wifiPhy->GetNMcs (); j++) { WifiMode mcs = m_wifiPhy->GetMcs (j); - if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities.IsSupportedMcs (mcs.GetMcsValue (), i)) + if (mcs.GetModulationClass () == WIFI_MOD_CLASS_VHT && vhtCapabilities->IsSupportedMcs (mcs.GetMcsValue (), i)) { AddSupportedMcs (from, mcs); } @@ -1787,7 +1787,7 @@ } void -WifiRemoteStationManager::AddStationHeCapabilities (Mac48Address from, HeCapabilities heCapabilities) +WifiRemoteStationManager::AddStationHeCapabilities (Mac48Address from, Ptr heCapabilities) { //Used by all stations to record HE capabilities of remote stations NS_LOG_FUNCTION (this << from << heCapabilities); @@ -1795,11 +1795,11 @@ state = LookupState (from); if (Is5Ghz (m_wifiPhy->GetFrequency ())) { - if (heCapabilities.GetChannelWidthSet () & 0x04) + if (heCapabilities->GetChannelWidthSet () & 0x04) { state->m_channelWidth = 160; } - else if (heCapabilities.GetChannelWidthSet () & 0x02) + else if (heCapabilities->GetChannelWidthSet () & 0x02) { state->m_channelWidth = 80; } @@ -1807,7 +1807,7 @@ } else if (Is2_4Ghz (m_wifiPhy->GetFrequency ())) { - if (heCapabilities.GetChannelWidthSet () & 0x01) + if (heCapabilities->GetChannelWidthSet () & 0x01) { state->m_channelWidth = 40; } @@ -1816,11 +1816,11 @@ state->m_channelWidth = 20; } } - if (heCapabilities.GetHeLtfAndGiForHePpdus () >= 2) + if (heCapabilities->GetHeLtfAndGiForHePpdus () >= 2) { state->m_guardInterval = 800; } - else if (heCapabilities.GetHeLtfAndGiForHePpdus () == 1) + else if (heCapabilities->GetHeLtfAndGiForHePpdus () == 1) { state->m_guardInterval = 1600; } @@ -1834,8 +1834,8 @@ { WifiMode mcs = m_wifiPhy->GetMcs (j); if (mcs.GetModulationClass () == WIFI_MOD_CLASS_HE - && heCapabilities.GetHighestNssSupported () >= i - && heCapabilities.GetHighestMcsSupported () >= j) + && heCapabilities->GetHighestNssSupported () >= i + && heCapabilities->GetHighestMcsSupported () >= j) { AddSupportedMcs (from, mcs); } diff -r c648032c8079 src/wifi/model/wifi-remote-station-manager.h --- a/src/wifi/model/wifi-remote-station-manager.h Fri Jul 06 11:14:13 2018 +0300 +++ b/src/wifi/model/wifi-remote-station-manager.h Sun Jul 08 21:56:33 2018 +0200 @@ -175,21 +175,21 @@ * \param from the address of the station being recorded * \param htcapabilities the HT capabilities of the station */ - void AddStationHtCapabilities (Mac48Address from, HtCapabilities htcapabilities); + void AddStationHtCapabilities (Mac48Address from, Ptr htcapabilities); /** * Records VHT capabilities of the remote station. * * \param from the address of the station being recorded * \param vhtcapabilities the VHT capabilities of the station */ - void AddStationVhtCapabilities (Mac48Address from, VhtCapabilities vhtcapabilities); + void AddStationVhtCapabilities (Mac48Address from, Ptr vhtcapabilities); /** * Records HE capabilities of the remote station. * * \param from the address of the station being recorded * \param hecapabilities the HE capabilities of the station */ - void AddStationHeCapabilities (Mac48Address from, HeCapabilities hecapabilities); + void AddStationHeCapabilities (Mac48Address from, Ptr hecapabilities); /** * Enable or disable HT capability support. * diff -r c648032c8079 src/wifi/test/wifi-test.cc --- a/src/wifi/test/wifi-test.cc Fri Jul 06 11:14:13 2018 +0300 +++ b/src/wifi/test/wifi-test.cc Sun Jul 08 21:56:33 2018 +0200 @@ -1422,8 +1422,8 @@ { MgtBeaconHeader beacon; packet->RemoveHeader (beacon); - HtOperation htOperation = beacon.GetHtOperation (); - if (htOperation.GetStaChannelWidth () > 0) + Ptr htOperation = StaticCast (beacon.GetInformationElement (IE_HT_OPERATION)); + if (htOperation->GetStaChannelWidth () > 0) { m_countOperationalChannelWidth40++; }