diff --git a/src/devices/mesh/dot11s/ie-dot11s-peer-management.h b/src/devices/mesh/dot11s/ie-dot11s-peer-management.h index 5da375545..f3fa9727c 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-peer-management.h +++ b/src/devices/mesh/dot11s/ie-dot11s-peer-management.h @@ -59,8 +59,8 @@ public: IePeerManagement (); enum Subtype { PEER_OPEN = 0, - PEER_CLOSE = 1, - PEER_CONFIRM = 2, + PEER_CONFIRM, + PEER_CLOSE, }; void SetPeerOpen (uint16_t localLinkId); void SetPeerClose (uint16_t localLinkID, uint16_t peerLinkId, PmpReasonCode reasonCode); diff --git a/src/devices/mesh/dot11s/peer-link-frame.cc b/src/devices/mesh/dot11s/peer-link-frame.cc index 37d2de94d..d6aefdcc5 100644 --- a/src/devices/mesh/dot11s/peer-link-frame.cc +++ b/src/devices/mesh/dot11s/peer-link-frame.cc @@ -19,18 +19,24 @@ */ #include "peer-link-frame.h" +#include "ie-dot11s-peer-management.h" #include "ns3/mesh-wifi-interface-mac.h" #include "ns3/test.h" #include "ns3/packet.h" + namespace ns3 { namespace dot11s { NS_OBJECT_ENSURE_REGISTERED (PeerLinkFrameStart); PeerLinkFrameStart::PeerLinkFrameStart (): m_subtype (255), + m_capability (0), m_aid (0), m_rates (SupportedRates()), - m_meshId (Ssid()) + m_meshId (Ssid()), + m_config(IeConfiguration ()), + //m_reasonCode (REASON11S_RESERVED), + m_reasonCode ((uint16_t)REASON11S_RESERVED) { } void @@ -42,12 +48,16 @@ void PeerLinkFrameStart::SetPlinkFrameStart(PeerLinkFrameStart::PlinkFrameStartFields fields) { m_subtype = fields.subtype; + //TODO: protocol version + if(m_subtype != (uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE)) + m_capability = fields.capability; if(m_subtype == (uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM)) m_aid = fields.aid; if(m_subtype != (uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE)) { m_rates = fields.rates; m_meshId = fields.meshId; + m_config = fields.config; } else m_reasonCode = fields.reasonCode; @@ -57,10 +67,14 @@ PeerLinkFrameStart::PlinkFrameStartFields PeerLinkFrameStart::GetFields () { PlinkFrameStartFields retval; + //TODO: protocol version: retval.subtype = m_subtype; + retval.capability = m_capability; retval.aid = m_aid; retval.rates = m_rates; retval.meshId = m_meshId; + retval.config = m_config; + retval.reasonCode = m_reasonCode; return retval; } @@ -95,23 +109,28 @@ void PeerLinkFrameStart::Print (std::ostream &os) const { os << "subtype = " << (uint16_t)m_subtype + << "\ncapability = " << m_capability << "\naid = " << (uint16_t)m_aid << "\nrates = " << m_rates - << "\nmeshId = " << m_meshId; + << "\nmeshId = " << m_meshId + << "\nconfiguration = " << m_config + << "\nreason code = " << m_reasonCode; } uint32_t PeerLinkFrameStart::GetSerializedSize () const { - uint32_t size = 0; + uint32_t size = 3; //Peering protocol NS_ASSERT(m_subtype < 3); + if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE) != m_subtype) + size += 2; //capability if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM) == m_subtype) size += 2; //AID of remote peer if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE) != m_subtype) { size += m_rates.GetSerializedSize (); - size += 2; size += m_meshId.GetSerializedSize (); + size += m_config.GetSerializedSize (); } else size += 2; //reasonCode @@ -123,14 +142,17 @@ PeerLinkFrameStart::Serialize (Buffer::Iterator start) const { Buffer::Iterator i = start; NS_ASSERT(m_subtype < 3); - //i.WriteU8 (m_subtype); + i.Next(3); + if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE) != m_subtype) + i.WriteHtonU16(m_capability); if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM) == m_subtype) i.WriteHtonU16 (m_aid); if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE) != m_subtype) { i = m_rates.Serialize (i); - i.Next(2); //QoS i = m_meshId.Serialize (i); + m_config.Serialize (i); + i.Next(m_config.GetSerializedSize ()); } else i.WriteHtonU16(m_reasonCode); @@ -141,14 +163,17 @@ PeerLinkFrameStart::Deserialize (Buffer::Iterator start) { Buffer::Iterator i = start; NS_ASSERT(m_subtype < 3); - //m_subtype = (IePeerManagement::Subtype)i.ReadU8 (); + i.Next(3); //peering protocol: + if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE) != m_subtype) + m_capability = i.ReadNtohU16(); if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CONFIRM) == m_subtype) m_aid = i.ReadNtohU16 (); if ((uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE) != m_subtype) { i = m_rates.Deserialize (i); - i.Next(2); //QoS i = m_meshId.Deserialize (i); + m_config.Deserialize (i); + i.Next (m_config.GetSerializedSize ()); } else m_reasonCode = i.ReadNtohU16(); @@ -158,8 +183,11 @@ bool operator== (const PeerLinkFrameStart & a, const PeerLinkFrameStart & b) { return ( (a.m_subtype == b.m_subtype) && + (a.m_capability == b.m_capability) && (a.m_aid == b.m_aid) && - (a.m_meshId.IsEqual(b.m_meshId)) + (a.m_meshId.IsEqual(b.m_meshId)) && + (a.m_config == b.m_config) && + (a.m_reasonCode == b.m_reasonCode) ); } #ifdef RUN_SELF_TESTS diff --git a/src/devices/mesh/dot11s/peer-link-frame.h b/src/devices/mesh/dot11s/peer-link-frame.h index c9866fc84..2bfdbff84 100644 --- a/src/devices/mesh/dot11s/peer-link-frame.h +++ b/src/devices/mesh/dot11s/peer-link-frame.h @@ -24,6 +24,7 @@ #include "ns3/supported-rates.h" #include "ns3/ssid.h" #include "dot11s-mac-header.h" +#include "ie-dot11s-configuration.h" namespace ns3 { class MeshWifiInterfaceMac; namespace dot11s { @@ -46,10 +47,13 @@ public: struct PlinkFrameStartFields { uint8_t subtype; - uint16_t reasonCode; //close only - uint16_t aid; //confirm only - SupportedRates rates; //open and confirm - Ssid meshId; //open and confirm + // //Peering protocol version - in all subtypes - 3 octets + uint16_t capability; //open and confirm + uint16_t aid; //confirm only + SupportedRates rates; //open and confirm + Ssid meshId; //open and confirm + IeConfiguration config; //open and confirm + uint16_t reasonCode; //close only }; ///\attention: must be set before deserialize, before only multihop //action header knows about subtype @@ -71,10 +75,12 @@ public: */ private: uint8_t m_subtype; - uint16_t m_reasonCode; + uint16_t m_capability; uint16_t m_aid; SupportedRates m_rates; Ssid m_meshId; + IeConfiguration m_config; + uint16_t m_reasonCode; friend bool operator== (const PeerLinkFrameStart & a, const PeerLinkFrameStart & b); }; diff --git a/src/devices/mesh/dot11s/peer-management-plugin.cc b/src/devices/mesh/dot11s/peer-management-plugin.cc index 6bc262793..3c4723673 100644 --- a/src/devices/mesh/dot11s/peer-management-plugin.cc +++ b/src/devices/mesh/dot11s/peer-management-plugin.cc @@ -105,13 +105,6 @@ PeerManagerMacPlugin::Receive (Ptr const_packet, const WifiMacHeader & h return false; } } - // MeshConfiguration Element - exists in all peer link management - // frames except CLOSE - IeConfiguration meshConfig; - if(fields.subtype != (uint8_t)(WifiMeshMultihopActionHeader::PEER_LINK_CLOSE)) - { - packet->RemoveHeader(meshConfig); - } IePeerManagement peerElement; packet->RemoveHeader(peerElement); //Check taht frame subtype corresponds peer link subtype @@ -128,7 +121,7 @@ PeerManagerMacPlugin::Receive (Ptr const_packet, const WifiMacHeader & h NS_ASSERT(actionValue.peerLink == WifiMeshMultihopActionHeader::PEER_LINK_CLOSE); } //Deliver Peer link management frame to protocol: - m_protocol->ReceivePeerLinkFrame(m_ifIndex, peerAddress, peerMpAddress, fields.aid, peerElement, meshConfig); + m_protocol->ReceivePeerLinkFrame(m_ifIndex, peerAddress, peerMpAddress, fields.aid, peerElement, fields.config); // if we can handle a frame - drop it return false; } @@ -160,11 +153,10 @@ PeerManagerMacPlugin::SendPeerLinkManagementFrame( //Create a packet: Ptr packet = Create (); packet->AddHeader (peerElement); - if(!peerElement.SubtypeIsClose()) - packet->AddHeader (meshConfig); PeerLinkFrameStart::PlinkFrameStartFields fields; fields.rates = m_parent->GetSupportedRates (); fields.meshId = m_parent->GetSsid (); + fields.config = meshConfig; PeerLinkFrameStart plinkFrame; //Create an 802.11 frame header: //Send management frame to MAC: