diff -r 0121c3096a89 src/wifi/model/ap-wifi-mac.cc --- a/src/wifi/model/ap-wifi-mac.cc Thu Jan 08 18:16:55 2015 -0800 +++ b/src/wifi/model/ap-wifi-mac.cc Tue Jan 13 14:29:37 2015 -0800 @@ -323,17 +323,17 @@ return rates; } -HtCapabilities +Ptr ApWifiMac::GetHtCapabilities (void) const { - HtCapabilities capabilities; - capabilities.SetHtSupported(1); - capabilities.SetLdpc (m_phy->GetLdpc()); - capabilities.SetShortGuardInterval20 (m_phy->GetGuardInterval()); - capabilities.SetGreenfield (m_phy->GetGreenfield()); + Ptr capabilities; + capabilities->SetHtSupported(1); + capabilities->SetLdpc (m_phy->GetLdpc()); + capabilities->SetShortGuardInterval20 (m_phy->GetGuardInterval()); + capabilities->SetGreenfield (m_phy->GetGreenfield()); for (uint8_t i =0 ; i < m_phy->GetNMcs();i++) { - capabilities.SetRxMcsBitmask(m_phy->GetMcs(i)); + capabilities->SetRxMcsBitmask(m_phy->GetMcs(i)); } return capabilities; } @@ -553,6 +553,7 @@ // first, verify that the the station's supported // rate set is compatible with our Basic Rate set MgtAssocRequestHeader assocReq; + WifiInformationElementVector elements; packet->RemoveHeader (assocReq); SupportedRates rates = assocReq.GetSupportedRates (); bool problem = false; @@ -567,11 +568,14 @@ } if (m_htSupported) {//check that the STA supports all MCSs in Basic MCS Set - HtCapabilities htcapabilities = assocReq.GetHtCapabilities (); + packet->RemoveHeader (elements); + Ptr wifiIe = elements.FindFirst (IE_HT_CAPABILITIES); + Ptr htcapabilities = DynamicCast (wifiIe); + // Ptr htcapabilities = assocReq.GetHtCapabilities (); for (uint32_t i = 0; i < m_stationManager->GetNBasicMcs (); i++) { uint8_t mcs = m_stationManager->GetBasicMcs (i); - if (!htcapabilities.IsSupportedMcs (mcs)) + if (!htcapabilities->IsSupportedMcs (mcs)) { problem = true; break; @@ -600,12 +604,15 @@ } if (m_htSupported) { - HtCapabilities htcapabilities = assocReq.GetHtCapabilities (); + packet->RemoveHeader (elements); + Ptr wifiIe = elements.FindFirst (IE_HT_CAPABILITIES); + Ptr htcapabilities = DynamicCast (wifiIe); + //Ptr htcapabilities = assocReq.GetHtCapabilities (); m_stationManager->AddStationHtCapabilities (from,htcapabilities); for (uint32_t j = 0; j < m_phy->GetNMcs (); j++) { uint8_t mcs = m_phy->GetMcs (j); - if (htcapabilities.IsSupportedMcs (mcs)) + if (htcapabilities->IsSupportedMcs (mcs)) { m_stationManager->AddSupportedMcs (from, mcs); } diff -r 0121c3096a89 src/wifi/model/ap-wifi-mac.h --- a/src/wifi/model/ap-wifi-mac.h Thu Jan 08 18:16:55 2015 -0800 +++ b/src/wifi/model/ap-wifi-mac.h Tue Jan 13 14:29:37 2015 -0800 @@ -181,7 +181,7 @@ * * \return the HT capability that we support */ - HtCapabilities GetHtCapabilities (void) const; + Ptr GetHtCapabilities (void) const; /** * Return an instance of SupportedRates that contains all rates that we support * including HT rates. diff -r 0121c3096a89 src/wifi/model/mgt-headers.cc --- a/src/wifi/model/mgt-headers.cc Thu Jan 08 18:16:55 2015 -0800 +++ b/src/wifi/model/mgt-headers.cc Tue Jan 13 14:29:37 2015 -0800 @@ -20,6 +20,7 @@ * Author: Mirko Banchi */ #include "mgt-headers.h" +#include "wifi-information-element-vector.h" #include "ns3/simulator.h" #include "ns3/assert.h" @@ -36,6 +37,12 @@ } void +MgtProbeRequestHeader::AddInformationElement (Ptr ie) +{ + m_elements.AddInformationElement (ie); +} + +void MgtProbeRequestHeader::SetSsid (Ssid ssid) { m_ssid = ssid; @@ -51,15 +58,19 @@ m_rates = rates; } void -MgtProbeRequestHeader::SetHtCapabilities(HtCapabilities htcapabilities) +MgtProbeRequestHeader::SetHtCapabilities(Ptr htcapabilities) { - m_htCapability=htcapabilities; + //m_htCapability = htcapabilities; + m_elements.AddInformationElement (htcapabilities); } -HtCapabilities +Ptr MgtProbeRequestHeader::GetHtCapabilities (void) const { - return m_htCapability; + //return m_htCapability; + Ptr wifiIe = m_elements.FindFirst (IE_HT_CAPABILITIES); + Ptr ht = DynamicCast (wifiIe); + return ht; } SupportedRates MgtProbeRequestHeader::GetSupportedRates (void) const @@ -73,7 +84,7 @@ size += m_ssid.GetSerializedSize (); size += m_rates.GetSerializedSize (); size += m_rates.extended.GetSerializedSize (); - size += m_htCapability.GetSerializedSize(); + //size += m_htCapability.GetSerializedSize(); return size; } TypeId @@ -94,8 +105,9 @@ MgtProbeRequestHeader::Print (std::ostream &os) const { os << "ssid=" << m_ssid << ", " - << "rates=" << m_rates << ", " - << "HT Capabilities=" << m_htCapability; +// << "rates=" << m_rates << ", " +// << "HT Capabilities=" << m_htCapability; + << "rates=" << m_rates; } void MgtProbeRequestHeader::Serialize (Buffer::Iterator start) const @@ -104,7 +116,7 @@ i = m_ssid.Serialize (i); i = m_rates.Serialize (i); i = m_rates.extended.Serialize (i); - i = m_htCapability.Serialize(i); +// i = m_htCapability.Serialize(i); } uint32_t MgtProbeRequestHeader::Deserialize (Buffer::Iterator start) @@ -113,7 +125,7 @@ i = m_ssid.Deserialize (i); i = m_rates.Deserialize (i); i = m_rates.extended.DeserializeIfPresent (i); - i = m_htCapability.DeserializeIfPresent (i); +// i = m_htCapability.DeserializeIfPresent (i); return i.GetDistanceFrom (start); } @@ -130,6 +142,13 @@ MgtProbeResponseHeader::~MgtProbeResponseHeader () { } + +void +MgtProbeResponseHeader::AddInformationElement (Ptr ie) +{ + m_elements.AddInformationElement (ie); +} + uint64_t MgtProbeResponseHeader::GetTimestamp () { @@ -151,15 +170,19 @@ return m_rates; } void -MgtProbeResponseHeader::SetHtCapabilities(HtCapabilities htcapabilities) +MgtProbeResponseHeader::SetHtCapabilities(Ptr htcapabilities) { - m_htCapability=htcapabilities; + //m_htCapability = htcapabilities; + m_elements.AddInformationElement (htcapabilities); } -HtCapabilities +Ptr MgtProbeResponseHeader::GetHtCapabilities (void) const { - return m_htCapability; + //return m_htCapability; + Ptr wifiIe = m_elements.FindFirst (IE_HT_CAPABILITIES); + Ptr ht = DynamicCast (wifiIe); + return ht; } void MgtProbeResponseHeader::SetSsid (Ssid ssid) @@ -201,7 +224,7 @@ size += m_rates.GetSerializedSize (); //size += 3; // ds parameter set size += m_rates.extended.GetSerializedSize (); - size += m_htCapability.GetSerializedSize(); + //size += m_htCapability.GetSerializedSize(); // xxx return size; } @@ -209,8 +232,9 @@ MgtProbeResponseHeader::Print (std::ostream &os) const { os << "ssid=" << m_ssid << ", " - << "rates=" << m_rates << ", " - << "HT Capabilities=" << m_htCapability; +// << "rates=" << m_rates << ", " +// << "HT Capabilities=" << m_htCapability; + << "rates=" << m_rates; } void MgtProbeResponseHeader::Serialize (Buffer::Iterator start) const @@ -233,7 +257,7 @@ i = m_rates.Serialize (i); //i.WriteU8 (0, 3); // ds parameter set. i = m_rates.extended.Serialize (i); - i = m_htCapability.Serialize(i); + //i = m_htCapability.Serialize(i); } uint32_t MgtProbeResponseHeader::Deserialize (Buffer::Iterator start) @@ -247,7 +271,7 @@ i = m_rates.Deserialize (i); //i.Next (3); // ds parameter set i = m_rates.extended.DeserializeIfPresent (i); - i = m_htCapability.DeserializeIfPresent (i); + //i = m_htCapability.DeserializeIfPresent (i); return i.GetDistanceFrom (start); } @@ -266,6 +290,12 @@ } void +MgtAssocRequestHeader::AddInformationElement (Ptr ie) +{ + m_elements.AddInformationElement (ie); +} + +void MgtAssocRequestHeader::SetSsid (Ssid ssid) { m_ssid = ssid; @@ -276,19 +306,23 @@ m_rates = rates; } void -MgtAssocRequestHeader::SetHtCapabilities(HtCapabilities htcapabilities) +MgtAssocRequestHeader::SetHtCapabilities(Ptr htcapabilities) { - m_htCapability = htcapabilities; + //m_htCapability = htcapabilities; + m_elements.AddInformationElement (htcapabilities); } void MgtAssocRequestHeader::SetListenInterval (uint16_t interval) { m_listenInterval = interval; } -HtCapabilities +Ptr MgtAssocRequestHeader::GetHtCapabilities (void) const { - return m_htCapability; + //return m_htCapability; + Ptr wifiIe = m_elements.FindFirst (IE_HT_CAPABILITIES); + Ptr ht = DynamicCast (wifiIe); + return ht; } Ssid MgtAssocRequestHeader::GetSsid (void) const @@ -328,7 +362,7 @@ size += 2; size += m_ssid.GetSerializedSize (); size += m_rates.GetSerializedSize (); - size += m_htCapability.GetSerializedSize(); + //size += m_htCapability.GetSerializedSize(); size += m_rates.extended.GetSerializedSize (); return size; } @@ -336,8 +370,9 @@ MgtAssocRequestHeader::Print (std::ostream &os) const { os << "ssid=" << m_ssid << ", " - << "rates=" << m_rates<< ", " - << "HT Capabilities=" << m_htCapability; +// << "rates=" << m_rates<< ", " +// << "HT Capabilities=" << m_htCapability; + << "rates=" << m_rates; } void MgtAssocRequestHeader::Serialize (Buffer::Iterator start) const @@ -348,7 +383,7 @@ i = m_ssid.Serialize (i); i = m_rates.Serialize (i); i = m_rates.extended.Serialize (i); - i = m_htCapability.Serialize(i); + //i = m_htCapability.Serialize(i); } uint32_t MgtAssocRequestHeader::Deserialize (Buffer::Iterator start) @@ -359,7 +394,7 @@ i = m_ssid.Deserialize (i); i = m_rates.Deserialize (i); i = m_rates.extended.DeserializeIfPresent (i); - i = m_htCapability.DeserializeIfPresent (i); + //i = m_htCapability.DeserializeIfPresent (i); return i.GetDistanceFrom (start); } @@ -377,6 +412,12 @@ { } +void +MgtAssocResponseHeader::AddInformationElement (Ptr ie) +{ + m_elements.AddInformationElement (ie); +} + StatusCode MgtAssocResponseHeader::GetStatusCode (void) { @@ -398,15 +439,19 @@ m_rates = rates; } void -MgtAssocResponseHeader::SetHtCapabilities(HtCapabilities htcapabilities) +MgtAssocResponseHeader::SetHtCapabilities(Ptr htcapabilities) { - m_htCapability=htcapabilities; + //m_htCapability=htcapabilities; + m_elements.AddInformationElement (htcapabilities); } -HtCapabilities +Ptr MgtAssocResponseHeader::GetHtCapabilities (void) const { - return m_htCapability; + // return m_htCapability; + Ptr wifiIe = m_elements.FindFirst (IE_HT_CAPABILITIES); + Ptr ht = DynamicCast (wifiIe); + return ht; } TypeId MgtAssocResponseHeader::GetTypeId (void) @@ -431,7 +476,7 @@ size += 2; // aid size += m_rates.GetSerializedSize (); size += m_rates.extended.GetSerializedSize (); -size += m_htCapability.GetSerializedSize(); + //size += m_htCapability.GetSerializedSize(); return size; } @@ -439,8 +484,9 @@ MgtAssocResponseHeader::Print (std::ostream &os) const { os << "status code=" << m_code << ", " - << "rates=" << m_rates << ", " - << "HT Capabilities=" << m_htCapability; +// << "rates=" << m_rates << ", " +// << "HT Capabilities=" << m_htCapability; + << "rates=" << m_rates; } void MgtAssocResponseHeader::Serialize (Buffer::Iterator start) const @@ -451,7 +497,7 @@ i.WriteHtolsbU16 (m_aid); i = m_rates.Serialize (i); i = m_rates.extended.Serialize (i); - i = m_htCapability.Serialize(i); + //i = m_htCapability.Serialize(i); } uint32_t MgtAssocResponseHeader::Deserialize (Buffer::Iterator start) @@ -462,7 +508,7 @@ m_aid = i.ReadLsbtohU16 (); i = m_rates.Deserialize (i); i = m_rates.extended.DeserializeIfPresent (i); - i = m_htCapability.DeserializeIfPresent (i); + //i = m_htCapability.DeserializeIfPresent (i); return i.GetDistanceFrom (start); } /********************************************************** diff -r 0121c3096a89 src/wifi/model/mgt-headers.h --- a/src/wifi/model/mgt-headers.h Thu Jan 08 18:16:55 2015 -0800 +++ b/src/wifi/model/mgt-headers.h Tue Jan 13 14:29:37 2015 -0800 @@ -30,6 +30,7 @@ #include "supported-rates.h" #include "ssid.h" #include "ht-capabilities.h" +#include "wifi-information-element-vector.h" namespace ns3 { @@ -44,6 +45,10 @@ ~MgtAssocRequestHeader (); /** + * Add information element + */ + void AddInformationElement (Ptr ie); + /** * Set the Service Set Identifier (SSID). * * \param ssid SSID @@ -66,14 +71,14 @@ * * \param htcapabilities HT capabilities */ - void SetHtCapabilities(HtCapabilities htcapabilities); + void SetHtCapabilities(Ptr htcapabilities); /** * Return the HT capabilities. * * \return HT capabilities */ - HtCapabilities GetHtCapabilities (void) const; + Ptr GetHtCapabilities (void) const; /** * Return the Service Set Identifier (SSID). * @@ -106,6 +111,7 @@ CapabilityInformation m_capability; //!< Capability information HtCapabilities m_htCapability; //!< HT capabilities uint16_t m_listenInterval; + WifiInformationElementVector m_elements; }; @@ -120,6 +126,10 @@ ~MgtAssocResponseHeader (); /** + * Add information element + */ + void AddInformationElement (Ptr ie); + /** * Return the status code. * * \return the status code @@ -136,14 +146,14 @@ * * \return HT capabilities */ - HtCapabilities GetHtCapabilities (void) const; + Ptr GetHtCapabilities (void) const; /** * Set the HT capabilities. * * \param htcapabilities HT capabilities */ - void SetHtCapabilities(HtCapabilities htcapabilities); + void SetHtCapabilities(Ptr htcapabilities); /** * Set the supported rates. * @@ -170,6 +180,7 @@ StatusCode m_code; //!< Status code uint16_t m_aid; HtCapabilities m_htCapability; //!< HT capabilities + WifiInformationElementVector m_elements; }; @@ -183,6 +194,10 @@ ~MgtProbeRequestHeader (); /** + * Add information element + */ + void AddInformationElement (Ptr ie); + /** * Set the Service Set Identifier (SSID). * * \param ssid SSID @@ -211,14 +226,14 @@ * * \return HT capabilities */ - HtCapabilities GetHtCapabilities (void) const; + Ptr GetHtCapabilities (void) const; /** * Set the HT capabilities. * * \param htcapabilities HT capabilities */ - void SetHtCapabilities(HtCapabilities htcapabilities); + void SetHtCapabilities(Ptr htcapabilities); static TypeId GetTypeId (void); virtual TypeId GetInstanceTypeId (void) const; virtual void Print (std::ostream &os) const; @@ -229,6 +244,7 @@ Ssid m_ssid; //!< Service Set ID (SSID) SupportedRates m_rates; //!< List of supported rates HtCapabilities m_htCapability; //!< HT capabilities + WifiInformationElementVector m_elements; }; @@ -243,6 +259,10 @@ ~MgtProbeResponseHeader (); /** + * Add information element + */ + void AddInformationElement (Ptr ie); + /** * Return the Service Set Identifier (SSID). * * \return SSID @@ -265,14 +285,14 @@ * * \return HT capabilities */ - HtCapabilities GetHtCapabilities (void) const; + Ptr GetHtCapabilities (void) const; /** * Set the HT capabilities. * * \param htcapabilities HT capabilities */ - void SetHtCapabilities(HtCapabilities htcapabilities); + void SetHtCapabilities(Ptr htcapabilities); /** * Set the Service Set Identifier (SSID). * @@ -311,6 +331,7 @@ SupportedRates m_rates; //!< List of supported rates CapabilityInformation m_capability; //!< Capability information HtCapabilities m_htCapability; //!< HT capabilities + WifiInformationElementVector m_elements; }; diff -r 0121c3096a89 src/wifi/model/sta-wifi-mac.cc --- a/src/wifi/model/sta-wifi-mac.cc Thu Jan 08 18:16:55 2015 -0800 +++ b/src/wifi/model/sta-wifi-mac.cc Tue Jan 13 14:29:37 2015 -0800 @@ -215,8 +215,11 @@ assoc.SetSupportedRates (GetSupportedRates ()); if (m_htSupported) { + WifiInformationElementVector elements; + Ptr ht = Create (); assoc.SetHtCapabilities (GetHtCapabilities()); hdr.SetNoOrder(); + packet->AddHeader (elements); } packet->AddHeader (assoc); @@ -546,6 +549,7 @@ if (m_state == WAIT_ASSOC_RESP) { MgtAssocResponseHeader assocResp; + WifiInformationElementVector elements; packet->RemoveHeader (assocResp); if (m_assocRequestEvent.IsRunning ()) { @@ -558,7 +562,9 @@ SupportedRates rates = assocResp.GetSupportedRates (); if (m_htSupported) { - HtCapabilities htcapabilities = assocResp.GetHtCapabilities (); + Ptr wifiIe = elements.FindFirst (IE_HT_CAPABILITIES); + Ptr htcapabilities = DynamicCast (wifiIe); + //Ptr htcapabilities = assocResp.GetHtCapabilities (); m_stationManager->AddStationHtCapabilities (hdr->GetAddr2 (),htcapabilities); } @@ -576,11 +582,13 @@ } if(m_htSupported) { - HtCapabilities htcapabilities = assocResp.GetHtCapabilities (); + Ptr wifiIe = elements.FindFirst (IE_HT_CAPABILITIES); + Ptr htcapabilities = DynamicCast (wifiIe); + //Ptr htcapabilities = assocResp.GetHtCapabilities (); for (uint32_t i = 0; i < m_phy->GetNMcs(); i++) { uint8_t mcs=m_phy->GetMcs(i); - if (htcapabilities.IsSupportedMcs (mcs)) + if (htcapabilities->IsSupportedMcs (mcs)) { m_stationManager->AddSupportedMcs (hdr->GetAddr2 (), mcs); //here should add a control to add basic MCS when it is implemented @@ -625,17 +633,17 @@ } return rates; } -HtCapabilities +Ptr StaWifiMac::GetHtCapabilities (void) const { - HtCapabilities capabilities; - capabilities.SetHtSupported(1); - capabilities.SetLdpc (m_phy->GetLdpc()); - capabilities.SetShortGuardInterval20 (m_phy->GetGuardInterval()); - capabilities.SetGreenfield (m_phy->GetGreenfield()); + Ptr capabilities; + capabilities->SetHtSupported(1); + capabilities->SetLdpc (m_phy->GetLdpc()); + capabilities->SetShortGuardInterval20 (m_phy->GetGuardInterval()); + capabilities->SetGreenfield (m_phy->GetGreenfield()); for (uint8_t i =0 ; i < m_phy->GetNMcs();i++) { - capabilities.SetRxMcsBitmask(m_phy->GetMcs(i)); + capabilities->SetRxMcsBitmask(m_phy->GetMcs(i)); } return capabilities; } diff -r 0121c3096a89 src/wifi/model/sta-wifi-mac.h --- a/src/wifi/model/sta-wifi-mac.h Thu Jan 08 18:16:55 2015 -0800 +++ b/src/wifi/model/sta-wifi-mac.h Tue Jan 13 14:29:37 2015 -0800 @@ -176,7 +176,7 @@ * * \return the HT capability that we support */ - HtCapabilities GetHtCapabilities (void) const; + Ptr GetHtCapabilities (void) const; enum MacState m_state; diff -r 0121c3096a89 src/wifi/model/wifi-remote-station-manager.cc --- a/src/wifi/model/wifi-remote-station-manager.cc Thu Jan 08 18:16:55 2015 -0800 +++ b/src/wifi/model/wifi-remote-station-manager.cc Tue Jan 13 14:29:37 2015 -0800 @@ -1250,13 +1250,13 @@ } //Used by all stations to record HT capabilities of remote stations void -WifiRemoteStationManager::AddStationHtCapabilities (Mac48Address from, HtCapabilities htcapabilities) +WifiRemoteStationManager::AddStationHtCapabilities (Mac48Address from, Ptr htcapabilities) { NS_LOG_FUNCTION (this << from << htcapabilities); WifiRemoteStationState *state; state=LookupState (from); - state->m_shortGuardInterval=htcapabilities.GetShortGuardInterval20(); - state->m_greenfield=htcapabilities.GetGreenfield(); + state->m_shortGuardInterval=htcapabilities->GetShortGuardInterval20(); + state->m_greenfield=htcapabilities->GetGreenfield(); } //Used by mac low to choose format used GF, MF or Non HT diff -r 0121c3096a89 src/wifi/model/wifi-remote-station-manager.h --- a/src/wifi/model/wifi-remote-station-manager.h Thu Jan 08 18:16:55 2015 -0800 +++ b/src/wifi/model/wifi-remote-station-manager.h Tue Jan 13 14:29:37 2015 -0800 @@ -161,7 +161,7 @@ * \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); /** * Enable or disable HT capability support. *