# HG changeset patch # Parent 3d01242318ef9524dc6d2a0485c31355ab544bff diff -r 3d01242318ef src/mesh/model/mesh-information-element-vector.cc --- a/src/mesh/model/mesh-information-element-vector.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/mesh/model/mesh-information-element-vector.cc Sat Jul 21 11:09:57 2018 +0200 @@ -22,7 +22,6 @@ #include "ns3/packet.h" #include #include "ns3/hwmp-protocol.h" -// All information elements: #include "ns3/ie-dot11s-beacon-timing.h" #include "ns3/ie-dot11s-configuration.h" #include "ns3/ie-dot11s-id.h" @@ -46,7 +45,6 @@ { } - TypeId MeshInformationElementVector::GetTypeId () { @@ -108,15 +106,10 @@ i.Prev (2); return WifiInformationElementVector::DeserializeSingleIe (i); } - if (GetSize () + length > m_maxSize) - { - NS_FATAL_ERROR ("Check max size for information element!"); - } newElement->DeserializeInformationField (i, length); i.Next (length); m_elements.push_back (newElement); return i.GetDistanceFrom (start); } - } // namespace ns3 diff -r 3d01242318ef src/wifi/model/ap-wifi-mac.cc --- a/src/wifi/model/ap-wifi-mac.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/ap-wifi-mac.cc Sat Jul 21 11:09:57 2018 +0200 @@ -442,15 +442,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; } @@ -470,114 +470,117 @@ 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.SetPrimaryChannel (m_phy->GetChannelNumber ()); - operation.SetRifsMode (GetRifsMode ()); - operation.SetNonGfHtStasPresent (IsNonGfHtStasPresent ()); + operation->SetHtSupported (1); + operation->SetPrimaryChannel (m_phy->GetChannelNumber ()); + 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++) @@ -632,44 +635,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++) { @@ -682,23 +685,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; @@ -725,31 +728,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); @@ -807,27 +810,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); @@ -859,35 +862,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); @@ -1136,14 +1139,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 = + DynamicCast (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; @@ -1154,13 +1158,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 = + DynamicCast (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; @@ -1171,13 +1176,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 = + DynamicCast (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; @@ -1212,23 +1218,24 @@ } if (GetHtSupported ()) { - HtCapabilities htCapabilities = assocReq.GetHtCapabilities (); - if (htCapabilities.IsSupportedMcs (0)) + Ptr htCapabilities = + DynamicCast (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 = + DynamicCast (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 @@ -1238,21 +1245,25 @@ } if (GetHtSupported () || GetVhtSupported ()) { - ExtendedCapabilities extendedCapabilities = assocReq.GetExtendedCapabilities (); + Ptr extendedCapabilities = + DynamicCast (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 = + DynamicCast (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 + } } } } @@ -1330,14 +1341,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 = + DynamicCast (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; @@ -1348,13 +1360,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 = + DynamicCast (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; @@ -1365,13 +1378,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 = + DynamicCast (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; @@ -1398,23 +1412,25 @@ } if (GetHtSupported ()) { - HtCapabilities htCapabilities = reassocReq.GetHtCapabilities (); - if (htCapabilities.IsSupportedMcs (0)) + Ptr htCapabilities = + DynamicCast (reassocReq.GetInformationElement (IE_HT_CAPABILITIES)); + if (htCapabilities != 0) { m_stationManager->AddStationHtCapabilities (from, htCapabilities); } } if (GetVhtSupported ()) { - VhtCapabilities vhtCapabilities = reassocReq.GetVhtCapabilities (); + Ptr vhtCapabilities = + DynamicCast (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 @@ -1424,21 +1440,25 @@ } if (GetHtSupported () || GetVhtSupported ()) { - ExtendedCapabilities extendedCapabilities = reassocReq.GetExtendedCapabilities (); + Ptr extendedCapabilities = + DynamicCast (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 = + DynamicCast (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 3d01242318ef src/wifi/model/ap-wifi-mac.h --- a/src/wifi/model/ap-wifi-mac.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/ap-wifi-mac.h Sat Jul 21 11:09:57 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 3d01242318ef src/wifi/model/cf-parameter-set.cc --- a/src/wifi/model/cf-parameter-set.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/cf-parameter-set.cc Sat Jul 21 11:09:57 2018 +0200 @@ -146,22 +146,27 @@ m_CFPDurRemaining = durRemaining; } +void +CfParameterSet::Print (std::ostream& os) const +{ + os << +GetCFPCount () + << "|" << +GetCFPPeriod () + << "|" << GetCFPMaxDurationUs () + << "|" << GetCFPDurRemainingUs (); +} + /** * output operator * * \param os output stream - * \param cfParameterSet + * \param cfparameterset the CF parameter set * * \return output stream */ std::ostream & -operator << (std::ostream &os, const CfParameterSet &cfParameterSet) +operator << (std::ostream &os, const CfParameterSet &cfparameterset) { - os << (uint16_t)cfParameterSet.GetCFPCount () - << "|" << (uint16_t)cfParameterSet.GetCFPPeriod () - << "|" << cfParameterSet.GetCFPMaxDurationUs () - << "|" << cfParameterSet.GetCFPDurRemainingUs (); - + cfparameterset.Print (os); return os; } diff -r 3d01242318ef src/wifi/model/cf-parameter-set.h --- a/src/wifi/model/cf-parameter-set.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/cf-parameter-set.h Sat Jul 21 11:09:57 2018 +0200 @@ -126,12 +126,19 @@ */ Buffer::Iterator Serialize (Buffer::Iterator start) const; /** - * Return the serialized size of this EDCA Parameter Set. + * Return the serialized size of this CF Parameter Set. * - * \return the serialized size of this EDCA Parameter Set + * \return the serialized size of this CF Parameter Set */ uint16_t GetSerializedSize () const; + /** + * Generate human-readable form of CF Parameter Set + * + * \param os output stream + */ + void Print (std::ostream& os) const; + private: uint8_t m_CFPCount; ///< CFP Count @@ -143,7 +150,7 @@ uint8_t m_pcfSupported; }; -std::ostream &operator << (std::ostream &os, const CfParameterSet &cfParameterSet); +std::ostream &operator << (std::ostream &os, const CfParameterSet &cfparameterset); } //namespace ns3 diff -r 3d01242318ef src/wifi/model/dsss-parameter-set.cc --- a/src/wifi/model/dsss-parameter-set.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/dsss-parameter-set.cc Sat Jul 21 11:09:57 2018 +0200 @@ -90,4 +90,25 @@ return length; } +void +DsssParameterSet::Print (std::ostream& os) const +{ + os << +m_currentChannel; +} + +/** + * output stream output operator + * + * \param os output stream + * \param dsssparameterset the DSSS parameter set + * + * \returns output stream + */ +std::ostream & +operator << (std::ostream &os, const DsssParameterSet &dsssparameterset) +{ + dsssparameterset.Print (os); + return os; +} + } //namespace ns3 diff -r 3d01242318ef src/wifi/model/dsss-parameter-set.h --- a/src/wifi/model/dsss-parameter-set.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/dsss-parameter-set.h Sat Jul 21 11:09:57 2018 +0200 @@ -90,6 +90,13 @@ */ uint16_t GetSerializedSize () const; + /** + * Generate human-readable form of DSSS Parameter Set + * + * \param os output stream + */ + void Print (std::ostream& os) const; + private: uint8_t m_currentChannel; ///< current channel number @@ -98,6 +105,8 @@ bool m_dsssSupported; }; +std::ostream &operator << (std::ostream &os, const DsssParameterSet &dsssparameterset); + } //namespace ns3 #endif /* DSSS_PARAMETER_SET_H */ diff -r 3d01242318ef src/wifi/model/edca-parameter-set.cc --- a/src/wifi/model/edca-parameter-set.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/edca-parameter-set.cc Sat Jul 21 11:09:57 2018 +0200 @@ -350,4 +350,29 @@ return length; } +void +EdcaParameterSet::Print (std::ostream& os) const +{ + os << +m_qosInfo << "|" + << m_acBE << "|" + << m_acBK << "|" + << m_acVI << "|" + << m_acVO; +} + +/** + * output stream output operator + * + * \param os output stream + * \param edcaparameterset the EDCA parameter set + * + * \returns output stream + */ +std::ostream & +operator << (std::ostream &os, const EdcaParameterSet &edcaparameterset) +{ + edcaparameterset.Print (os); + return os; +} + } //namespace ns3 diff -r 3d01242318ef src/wifi/model/edca-parameter-set.h --- a/src/wifi/model/edca-parameter-set.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/edca-parameter-set.h Sat Jul 21 11:09:57 2018 +0200 @@ -311,12 +311,19 @@ */ Buffer::Iterator Serialize (Buffer::Iterator start) const; /** - * Return the serialized size of this EDCA Parameter Set. + * Return the serialized size of this EDCA Parameter Set IE. * - * \return the serialized size of this EDCA Parameter Set + * \return the serialized size of this EDCA Parameter Set IE */ uint16_t GetSerializedSize () const; + /** + * Generate human-readable form of EDCA Parameter Set IE + * + * \param os output stream + */ + void Print (std::ostream& os) const; + private: uint8_t m_qosInfo; ///< QOS info @@ -330,6 +337,8 @@ bool m_qosSupported; }; +std::ostream &operator << (std::ostream &os, const EdcaParameterSet &edcaparameterset); + } //namespace ns3 #endif /* EDCA_PARAMETER_SET_H */ diff -r 3d01242318ef src/wifi/model/erp-information.cc --- a/src/wifi/model/erp-information.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/erp-information.cc Sat Jul 21 11:09:57 2018 +0200 @@ -121,21 +121,26 @@ return length; } +void +ErpInformation::Print (std::ostream& os) const +{ + os << bool (GetBarkerPreambleMode ()) + << "|" << bool (GetUseProtection ()) + << "|" << bool (GetNonErpPresent ()); +} + /** * output stream output operator * * \param os output stream - * \param erpinformation + * \param erpinformation the ERP information * * \returns output stream */ std::ostream & operator << (std::ostream &os, const ErpInformation &erpinformation) { - os << bool (erpinformation.GetBarkerPreambleMode ()) - << "|" << bool (erpinformation.GetUseProtection ()) - << "|" << bool (erpinformation.GetNonErpPresent ()); - + erpinformation.Print (os); return os; } diff -r 3d01242318ef src/wifi/model/erp-information.h --- a/src/wifi/model/erp-information.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/erp-information.h Sat Jul 21 11:09:57 2018 +0200 @@ -121,12 +121,20 @@ */ Buffer::Iterator Serialize (Buffer::Iterator start) const; /** - * Return the serialized size of this ErpInformation information element. + * Return the serialized size of this ERP Information IE. * - * \return the serialized size of this ErpInformation information element + * \return the serialized size of this ERP Information IE */ uint16_t GetSerializedSize () const; + /** + * Generate human-readable form of ERP Information IE + * + * \param os output stream + */ + void Print (std::ostream& os) const; + + private: uint8_t m_erpInformation; ///< ERP information @@ -134,14 +142,6 @@ bool m_erpSupported; }; -/** - * output stream output operator - * - * \param os output stream - * \param erpinformation - * - * \returns output stream - */ std::ostream &operator << (std::ostream &os, const ErpInformation &erpinformation); } //namespace ns3 diff -r 3d01242318ef src/wifi/model/extended-capabilities.cc --- a/src/wifi/model/extended-capabilities.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/extended-capabilities.cc Sat Jul 21 11:09:57 2018 +0200 @@ -393,6 +393,12 @@ return length; } +void +ExtendedCapabilities::Print (std::ostream& os) const +{ + os << +GetExtendedCapabilitiesByte1 (); +} + /** * output stream output operator * @@ -404,7 +410,7 @@ std::ostream & operator << (std::ostream &os, const ExtendedCapabilities &extendedcapabilities) { - os << +extendedcapabilities.GetExtendedCapabilitiesByte1 (); + extendedcapabilities.Print (os); return os; } diff -r 3d01242318ef src/wifi/model/extended-capabilities.h --- a/src/wifi/model/extended-capabilities.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/extended-capabilities.h Sat Jul 21 11:09:57 2018 +0200 @@ -194,6 +194,13 @@ */ uint16_t GetSerializedSize () const; + /** + * Generate human-readable form of extended capabilities information element + * + * \param os output stream + */ + void Print (std::ostream& os) const; + private: //fields supported by HT and VHT diff -r 3d01242318ef src/wifi/model/he-capabilities.cc --- a/src/wifi/model/he-capabilities.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/he-capabilities.cc Sat Jul 21 11:09:57 2018 +0200 @@ -469,20 +469,26 @@ return m_highestNssSupportedM1 + 1; } +void +HeCapabilities::Print (std::ostream& os) const +{ + os << GetHeMacCapabilitiesInfo1 () << "|" + << +GetHeMacCapabilitiesInfo2 () << "|" + << GetHePhyCapabilitiesInfo1 () << "|" + << +GetHePhyCapabilitiesInfo2 () << "|" + << GetSupportedMcsAndNss (); +} + /** * output stream output operator * \param os the output stream - * \param HeCapabilities the HE capabilities + * \param hecapabilities the HE capabilities * \returns the output stream */ std::ostream & -operator << (std::ostream &os, const HeCapabilities &HeCapabilities) +operator << (std::ostream &os, const HeCapabilities &hecapabilities) { - os << HeCapabilities.GetHeMacCapabilitiesInfo1 () << "|" - << +HeCapabilities.GetHeMacCapabilitiesInfo2 () << "|" - << HeCapabilities.GetHePhyCapabilitiesInfo1 () << "|" - << +HeCapabilities.GetHePhyCapabilitiesInfo2 () << "|" - << HeCapabilities.GetSupportedMcsAndNss (); + hecapabilities.Print (os); return os; } diff -r 3d01242318ef src/wifi/model/he-capabilities.h --- a/src/wifi/model/he-capabilities.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/he-capabilities.h Sat Jul 21 11:09:57 2018 +0200 @@ -210,6 +210,13 @@ */ uint16_t GetSerializedSize () const; + /** + * Generate human-readable form of HE capabilities information element + * + * \param os output stream + */ + void Print (std::ostream& os) const; + private: //MAC Capabilities Info fields @@ -285,7 +292,7 @@ uint8_t m_heSupported; }; -std::ostream &operator << (std::ostream &os, const HeCapabilities &HeCapabilities); +std::ostream &operator << (std::ostream &os, const HeCapabilities &hecapabilities); } //namespace ns3 diff -r 3d01242318ef src/wifi/model/he-operation.cc --- a/src/wifi/model/he-operation.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/he-operation.cc Sat Jul 21 11:09:57 2018 +0200 @@ -150,19 +150,25 @@ return length; } +void +HeOperation::Print (std::ostream& os) const +{ + os << GetHeOperationParameters () << "|" + << GetBasicHeMcsAndNssSet (); +} + /** * output stream output operator * * \param os output stream - * \param HeOperation the HE operation + * \param heoperation the HE operation * * \returns output stream */ std::ostream & -operator << (std::ostream &os, const HeOperation &HeOperation) +operator << (std::ostream &os, const HeOperation &heoperation) { - os << HeOperation.GetHeOperationParameters () << "|" - << HeOperation.GetBasicHeMcsAndNssSet (); + heoperation.Print (os); return os; } diff -r 3d01242318ef src/wifi/model/he-operation.h --- a/src/wifi/model/he-operation.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/he-operation.h Sat Jul 21 11:09:57 2018 +0200 @@ -117,6 +117,13 @@ */ uint16_t GetSerializedSize () const; + /** + * Generate human-readable form of HE Operations IE + * + * \param os output stream + */ + void Print (std::ostream& os) const; + private: //HE Operation Parameters fields diff -r 3d01242318ef src/wifi/model/ht-capabilities.cc --- a/src/wifi/model/ht-capabilities.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/ht-capabilities.cc Sat Jul 21 11:09:57 2018 +0200 @@ -523,6 +523,19 @@ return length; } +void +HtCapabilities::Print (std::ostream& os) const +{ + os << bool (GetLdpc ()) + << "|" << bool (GetSupportedChannelWidth ()) + << "|" << bool (GetGreenfield ()) + << "|" << bool (GetShortGuardInterval20 ()) << "|"; + for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++) + { + os << IsSupportedMcs (i) << " "; + } +} + /** * output stream output operator * @@ -534,14 +547,7 @@ std::ostream & operator << (std::ostream &os, const HtCapabilities &htcapabilities) { - os << bool (htcapabilities.GetLdpc ()) - << "|" << bool (htcapabilities.GetSupportedChannelWidth ()) - << "|" << bool (htcapabilities.GetGreenfield ()) - << "|" << bool (htcapabilities.GetShortGuardInterval20 ()) << "|"; - for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++) - { - os << htcapabilities.IsSupportedMcs (i) << " "; - } + htcapabilities.Print (os); return os; } diff -r 3d01242318ef src/wifi/model/ht-capabilities.h --- a/src/wifi/model/ht-capabilities.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/ht-capabilities.h Sat Jul 21 11:09:57 2018 +0200 @@ -298,13 +298,20 @@ */ Buffer::Iterator Serialize (Buffer::Iterator start) const; /** - * Return the serialized size of this HT capability + * Return the serialized size of this HT capabilities * information element. * - * \return the serialized size of this HT capability information element + * \return the serialized size of this HT capabilities information element */ uint16_t GetSerializedSize () const; + /** + * Generate human-readable form of HT capabilities information element + * + * \param os output stream + */ + void Print (std::ostream& os) const; + private: //HT Capabilities Info field @@ -388,4 +395,4 @@ } //namespace ns3 -#endif /* HT_CAPABILITY_H */ +#endif /* HT_CAPABILITIES_H */ diff -r 3d01242318ef src/wifi/model/ht-operation.cc --- a/src/wifi/model/ht-operation.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/ht-operation.cc Sat Jul 21 11:09:57 2018 +0200 @@ -489,6 +489,33 @@ return length; } +void +HtOperation::Print (std::ostream& os) const +{ + os << bool (GetPrimaryChannel ()) + << "|" << +GetSecondaryChannelOffset () + << "|" << bool (GetStaChannelWidth ()) + << "|" << bool (GetRifsMode ()) + << "|" << +GetHtProtection () + << "|" << bool (GetNonGfHtStasPresent ()) + << "|" << bool (GetObssNonHtStasPresent ()) + << "|" << bool (GetDualBeacon ()) + << "|" << bool (GetDualCtsProtection ()) + << "|" << bool (GetStbcBeacon ()) + << "|" << bool (GetLSigTxopProtectionFullSupport ()) + << "|" << bool (GetPcoActive ()) + << "|" << bool (GetPhase ()) + << "|" << GetRxHighestSupportedDataRate () + << "|" << bool (GetTxMcsSetDefined ()) + << "|" << bool (GetTxRxMcsSetUnequal ()) + << "|" << +GetTxMaxNSpatialStreams () + << "|" << bool (GetTxUnequalModulation ()) << "|"; + for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++) + { + os << IsSupportedMcs (i) << " "; + } +} + /** * output stream output operator * @@ -500,28 +527,7 @@ std::ostream & operator << (std::ostream &os, const HtOperation &htOperation) { - os << bool (htOperation.GetPrimaryChannel ()) - << "|" << +htOperation.GetSecondaryChannelOffset () - << "|" << bool (htOperation.GetStaChannelWidth ()) - << "|" << bool (htOperation.GetRifsMode ()) - << "|" << +htOperation.GetHtProtection () - << "|" << bool (htOperation.GetNonGfHtStasPresent ()) - << "|" << bool (htOperation.GetObssNonHtStasPresent ()) - << "|" << bool (htOperation.GetDualBeacon ()) - << "|" << bool (htOperation.GetDualCtsProtection ()) - << "|" << bool (htOperation.GetStbcBeacon ()) - << "|" << bool (htOperation.GetLSigTxopProtectionFullSupport ()) - << "|" << bool (htOperation.GetPcoActive ()) - << "|" << bool (htOperation.GetPhase ()) - << "|" << htOperation.GetRxHighestSupportedDataRate () - << "|" << bool (htOperation.GetTxMcsSetDefined ()) - << "|" << bool (htOperation.GetTxRxMcsSetUnequal ()) - << "|" << +htOperation.GetTxMaxNSpatialStreams () - << "|" << bool (htOperation.GetTxUnequalModulation ()) << "|"; - for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++) - { - os << htOperation.IsSupportedMcs (i) << " "; - } + htOperation.Print (os); return os; } diff -r 3d01242318ef src/wifi/model/ht-operation.h --- a/src/wifi/model/ht-operation.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/ht-operation.h Sat Jul 21 11:09:57 2018 +0200 @@ -400,6 +400,13 @@ */ uint16_t GetSerializedSize () const; + /** + * Generate human-readable form of HT Operation IE + * + * \param os output stream + */ + void Print (std::ostream& os) const; + private: uint8_t m_primaryChannel; ///< primary channel diff -r 3d01242318ef src/wifi/model/mgt-headers.cc --- a/src/wifi/model/mgt-headers.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/mgt-headers.cc Sat Jul 21 11:09:57 2018 +0200 @@ -26,8 +26,171 @@ 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 +{ + Ptr element; + for (WifiInformationElementMap::const_iterator elem = m_map.begin (); elem != m_map.end ();) + { + switch (elem->first) + { + case IE_HT_CAPABILITIES: + os << "HT Capabilities="; + break; + case IE_VHT_CAPABILITIES: + os << "VHT Capabilities="; + break; + case IE_HE_CAPABILITIES: + os << "HE Capabilities="; + break; + case IE_EXTENDED_CAPABILITIES: + os << "Extended Capabilities="; + break; + case IE_HT_OPERATION: + os << "HT Operation="; + break; + case IE_VHT_OPERATION: + os << "VHT Operation="; + break; + case IE_HE_OPERATION: + os << "HE Operation="; + break; + case IE_ERP_INFORMATION: + os << "ERP information="; + break; + case IE_EDCA_PARAMETER_SET: + os << "EDCA parameter set="; + break; + case IE_DSSS_PARAMETER_SET: + os << "DSSS parameter set="; + break; + case IE_CF_PARAMETER_SET: + os << "CF parameter set="; + break; + default: + os << "Unknown IE="; + break; + } + elem->second->Print (os); + ++elem; + if (elem != m_map.end ()) + { + os << " , "; + } + } +} + +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_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 +223,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 +236,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; } @@ -149,11 +261,8 @@ 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; + << "rates=" << m_rates << ", "; + PrintInformationElements (os); } void @@ -163,10 +272,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 +282,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 +338,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 +355,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 +381,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 +404,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 +424,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 +450,7 @@ /*********************************************************** - * Assoc Request + * Assoc Request ***********************************************************/ NS_OBJECT_ENSURE_REGISTERED (MgtAssocRequestHeader); @@ -562,54 +494,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 +538,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 +559,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 +571,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 +621,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 +672,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 +681,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 +695,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 +708,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 +764,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 +789,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 +799,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 +811,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 +823,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 3d01242318ef src/wifi/model/mgt-headers.h --- a/src/wifi/model/mgt-headers.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/mgt-headers.h Sat Jul 21 11:09:57 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 3d01242318ef src/wifi/model/regular-wifi-mac.cc --- a/src/wifi/model/regular-wifi-mac.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/regular-wifi-mac.cc Sat Jul 21 11:09:57 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 3d01242318ef src/wifi/model/regular-wifi-mac.h --- a/src/wifi/model/regular-wifi-mac.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/regular-wifi-mac.h Sat Jul 21 11:09:57 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 3d01242318ef src/wifi/model/sta-wifi-mac.cc --- a/src/wifi/model/sta-wifi-mac.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/sta-wifi-mac.cc Sat Jul 21 11:09:57 2018 +0200 @@ -156,16 +156,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); @@ -197,16 +197,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); } @@ -220,16 +220,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); } @@ -568,17 +568,17 @@ NS_LOG_LOGIC ("Beacon is for our SSID"); goodBeacon = true; } - CfParameterSet cfParameterSet = beacon.GetCfParameterSet (); - if (cfParameterSet.GetCFPCount () == 0) + Ptr cfParameterSet = DynamicCast (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 (); @@ -742,15 +742,18 @@ bool isShortPreambleEnabled = capabilities.IsShortPreamble (); if (GetErpSupported ()) { - ErpInformation erpInformation = beacon.GetErpInformation (); - isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode (); - if (erpInformation.GetUseProtection () != 0) + Ptr erpInformation = DynamicCast (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) { @@ -766,30 +769,31 @@ if (GetQosSupported ()) { bool qosSupported = false; - EdcaParameterSet edcaParameters = beacon.GetEdcaParameterSet (); - if (edcaParameters.IsQosSupported ()) + Ptr edcaParameters = DynamicCast (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 = DynamicCast (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 = DynamicCast (beacon.GetInformationElement (IE_HT_OPERATION)); + NS_ASSERT (htOperation != 0); + if (htOperation->GetNonGfHtStasPresent ()) { m_stationManager->SetUseGreenfieldProtection (true); } @@ -797,7 +801,7 @@ { m_stationManager->SetUseGreenfieldProtection (false); } - if (!GetVhtSupported () && GetRifsSupported () && htOperation.GetRifsMode ()) + if (!GetVhtSupported () && GetRifsSupported () && htOperation->GetRifsMode ()) { m_stationManager->SetRifsPermitted (true); } @@ -809,16 +813,17 @@ } if (GetVhtSupported ()) { - VhtCapabilities vhtCapabilities = beacon.GetVhtCapabilities (); + Ptr vhtCapabilities = DynamicCast (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 = DynamicCast (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); } @@ -827,21 +832,24 @@ } if (GetHtSupported () || GetVhtSupported ()) { - ExtendedCapabilities extendedCapabilities = beacon.GetExtendedCapabilities (); + Ptr extendedCapabilities = DynamicCast (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 = DynamicCast (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 = DynamicCast (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); + } } } } @@ -898,8 +906,11 @@ } else { - ErpInformation erpInformation = probeResp.GetErpInformation (); - isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode (); + Ptr erpInformation = DynamicCast (probeResp.GetInformationElement (IE_ERP_INFORMATION)); + if (erpInformation != 0) + { + isShortPreambleEnabled &= !erpInformation->GetBarkerPreambleMode (); + } if (m_stationManager->GetShortSlotTimeEnabled ()) { //enable short slot time @@ -945,8 +956,11 @@ } else { - ErpInformation erpInformation = assocResp.GetErpInformation (); - isShortPreambleEnabled &= !erpInformation.GetBarkerPreambleMode (); + Ptr erpInformation = DynamicCast (assocResp.GetInformationElement (IE_ERP_INFORMATION)); + if (erpInformation != 0) + { + isShortPreambleEnabled &= !erpInformation->GetBarkerPreambleMode (); + } if (m_stationManager->GetShortSlotTimeEnabled ()) { //enable short slot time @@ -965,30 +979,31 @@ if (GetQosSupported ()) { bool qosSupported = false; - EdcaParameterSet edcaParameters = assocResp.GetEdcaParameterSet (); - if (edcaParameters.IsQosSupported ()) + Ptr edcaParameters = DynamicCast (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 = DynamicCast (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 = DynamicCast (assocResp.GetInformationElement (IE_HT_OPERATION)); + NS_ASSERT (htOperation != 0); + if (htOperation->GetNonGfHtStasPresent ()) { m_stationManager->SetUseGreenfieldProtection (true); } @@ -996,7 +1011,7 @@ { m_stationManager->SetUseGreenfieldProtection (false); } - if (!GetVhtSupported () && GetRifsSupported () && htOperation.GetRifsMode ()) + if (!GetVhtSupported () && GetRifsSupported () && htOperation->GetRifsMode ()) { m_stationManager->SetRifsPermitted (true); } @@ -1008,20 +1023,20 @@ } if (GetVhtSupported ()) { - VhtCapabilities vhtCapabilities = assocResp.GetVhtCapabilities (); + Ptr vhtCapabilities = DynamicCast (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 = DynamicCast (assocResp.GetInformationElement (IE_VHT_OPERATION)); } } if (GetHeSupported ()) { - HeCapabilities hecapabilities = assocResp.GetHeCapabilities (); + Ptr hecapabilities = DynamicCast (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 = DynamicCast (assocResp.GetInformationElement (IE_HE_OPERATION)); } for (uint8_t i = 0; i < m_phy->GetNModes (); i++) { @@ -1037,45 +1052,54 @@ } if (GetHtSupported ()) { - HtCapabilities htCapabilities = assocResp.GetHtCapabilities (); - for (uint8_t i = 0; i < m_phy->GetNMcs (); i++) + Ptr htCapabilities = DynamicCast (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 = DynamicCast (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 = DynamicCast (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 = DynamicCast (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 3d01242318ef src/wifi/model/vht-capabilities.cc --- a/src/wifi/model/vht-capabilities.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/vht-capabilities.cc Sat Jul 21 11:09:57 2018 +0200 @@ -370,6 +370,13 @@ return m_rxHighestSupportedLongGuardIntervalDataRate; } +void +VhtCapabilities::Print (std::ostream& os) const +{ + os << GetVhtCapabilitiesInfo () + << "|" << GetSupportedMcsAndNssSet (); +} + /** * output stream output operator * @@ -381,8 +388,7 @@ std::ostream & operator << (std::ostream &os, const VhtCapabilities &VhtCapabilities) { - os << VhtCapabilities.GetVhtCapabilitiesInfo () << "|" << VhtCapabilities.GetSupportedMcsAndNssSet (); - + VhtCapabilities.Print (os); return os; } diff -r 3d01242318ef src/wifi/model/vht-capabilities.h --- a/src/wifi/model/vht-capabilities.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/vht-capabilities.h Sat Jul 21 11:09:57 2018 +0200 @@ -240,6 +240,13 @@ */ uint16_t GetSerializedSize () const; + /** + * Generate human-readable form of VHT capabilities information element + * + * \param os output stream + */ + void Print (std::ostream& os) const; + private: //Capabilities Info fields diff -r 3d01242318ef src/wifi/model/vht-operation.cc --- a/src/wifi/model/vht-operation.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/vht-operation.cc Sat Jul 21 11:09:57 2018 +0200 @@ -161,6 +161,15 @@ return length; } +void +VhtOperation::Print (std::ostream& os) const +{ + os << +GetChannelWidth () << "|" + << +GetChannelCenterFrequencySegment0 () << "|" + << +GetChannelCenterFrequencySegment1 () << "|" + << GetBasicVhtMcsAndNssSet (); +} + /** * output stream output operator * @@ -172,10 +181,7 @@ std::ostream & operator << (std::ostream &os, const VhtOperation &VhtOperation) { - os << +VhtOperation.GetChannelWidth () << "|" - << +VhtOperation.GetChannelCenterFrequencySegment0 () << "|" - << +VhtOperation.GetChannelCenterFrequencySegment1 () << "|" - << VhtOperation.GetBasicVhtMcsAndNssSet (); + VhtOperation.Print (os); return os; } diff -r 3d01242318ef src/wifi/model/vht-operation.h --- a/src/wifi/model/vht-operation.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/vht-operation.h Sat Jul 21 11:09:57 2018 +0200 @@ -147,6 +147,13 @@ */ uint16_t GetSerializedSize () const; + /** + * Generate human-readable form of VHT Operations IE + * + * \param os output stream + */ + void Print (std::ostream& os) const; + private: //VHT Operation Information diff -r 3d01242318ef src/wifi/model/wifi-information-element-vector.cc --- a/src/wifi/model/wifi-information-element-vector.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/wifi-information-element-vector.cc Sat Jul 21 11:09:57 2018 +0200 @@ -25,7 +25,6 @@ NS_OBJECT_ENSURE_REGISTERED (WifiInformationElementVector); WifiInformationElementVector::WifiInformationElementVector () - : m_maxSize (1500) { } @@ -108,16 +107,6 @@ NS_FATAL_ERROR ("Information element " << +id << " is not implemented"); return 0; } - /* unreachable: b/c switch is guaranteed to return from this function - if (GetSize () + length > m_maxSize) - { - NS_FATAL_ERROR ("Check max size for information element!"); - } - newElement->DeserializeInformationField (i, length); - i.Next (length); - m_elements.push_back (newElement); - return i.GetDistanceFrom (start); - */ } void @@ -143,15 +132,10 @@ return m_elements.end (); } -bool +void WifiInformationElementVector::AddInformationElement (Ptr element) { - if (element->GetInformationFieldSize () + 2 + GetSize () > m_maxSize) - { - return false; - } m_elements.push_back (element); - return true; } Ptr diff -r 3d01242318ef src/wifi/model/wifi-information-element-vector.h --- a/src/wifi/model/wifi-information-element-vector.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/wifi-information-element-vector.h Sat Jul 21 11:09:57 2018 +0200 @@ -91,12 +91,11 @@ */ Iterator End (); /** - * add an IE, if maxSize has exceeded, returns false + * add an IE * * \param element wifi information element to add - * \returns true is added */ - bool AddInformationElement (Ptr element); + void AddInformationElement (Ptr element); /** * vector of pointers to information elements is the body of IeVector * @@ -127,8 +126,6 @@ */ uint32_t GetSize () const; IE_VECTOR m_elements; //!< Information element vector - /// Size in bytes (actually, max packet length) - uint16_t m_maxSize; }; } //namespace ns3 diff -r 3d01242318ef src/wifi/model/wifi-information-element.cc --- a/src/wifi/model/wifi-information-element.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/wifi-information-element.cc Sat Jul 21 11:09:57 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 3d01242318ef src/wifi/model/wifi-information-element.h --- a/src/wifi/model/wifi-information-element.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/wifi-information-element.h Sat Jul 21 11:09:57 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 3d01242318ef src/wifi/model/wifi-remote-station-manager.cc --- a/src/wifi/model/wifi-remote-station-manager.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/wifi-remote-station-manager.cc Sat Jul 21 11:09:57 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 3d01242318ef src/wifi/model/wifi-remote-station-manager.h --- a/src/wifi/model/wifi-remote-station-manager.h Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/model/wifi-remote-station-manager.h Sat Jul 21 11:09:57 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 3d01242318ef src/wifi/test/wifi-test.cc --- a/src/wifi/test/wifi-test.cc Fri Jul 20 18:54:48 2018 +0300 +++ b/src/wifi/test/wifi-test.cc Sat Jul 21 11:09:57 2018 +0200 @@ -1422,8 +1422,8 @@ { MgtBeaconHeader beacon; packet->RemoveHeader (beacon); - HtOperation htOperation = beacon.GetHtOperation (); - if (htOperation.GetStaChannelWidth () > 0) + Ptr htOperation = DynamicCast (beacon.GetInformationElement (IE_HT_OPERATION)); + if (htOperation->GetStaChannelWidth () > 0) { m_countOperationalChannelWidth40++; }