From cbe755a7f7fc75fd88635ca942c8d9d5a084bf57 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Fri, 27 Mar 2009 20:03:13 +0300 Subject: [PATCH] First PREQ delivered --- examples/mesh.cc | 4 +- src/devices/mesh/dot11s/hwmp-mac-plugin.cc | 277 +++++++----------- src/devices/mesh/dot11s/hwmp-mac-plugin.h | 84 +++--- src/devices/mesh/dot11s/hwmp-protocol.cc | 103 ++++++- src/devices/mesh/dot11s/hwmp-protocol.h | 40 ++- .../mesh/dot11s/peer-management-plugin.cc | 9 +- .../mesh/dot11s/peer-management-protocol.cc | 3 +- 7 files changed, 270 insertions(+), 250 deletions(-) diff --git a/examples/mesh.cc b/examples/mesh.cc index 26219fc6d..32418e73b 100644 --- a/examples/mesh.cc +++ b/examples/mesh.cc @@ -39,8 +39,8 @@ int main (int argc, char *argv[]) { // Creating square topology with nNodes x nNodes grid: - int xSize = 3; - int ySize = 3; + int xSize = 4; + int ySize = 4; double step = 100.0; //Grid with one-hop edge double randomStart = 0.1; //One beacon interval NodeContainer nodes; diff --git a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc index 8c33784ca..6feeb2959 100644 --- a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc +++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc @@ -23,7 +23,6 @@ #include "ns3/simulator.h" #include "ns3/nstime.h" #include "ns3/log.h" -#include "ns3/dot11s-parameters.h" #include "ns3/mesh-wifi-mac-header.h" #include "hwmp-mac-plugin.h" @@ -80,12 +79,55 @@ HwmpMacPlugin::Receive (Ptr packet, const WifiMacHeader & header) if(m_protocol->DropDataFrame (meshHdr.GetMeshSeqno (), header.GetAddr4 ()) ) return false; } + if(header.IsMultihopAction()) + { + WifiMeshHeader meshHdr; + packet->RemoveHeader (meshHdr); + //parse multihop action header: + WifiMeshMultihopActionHeader multihopHdr; + packet->RemoveHeader (multihopHdr); + WifiMeshMultihopActionHeader::ACTION_VALUE actionValue = multihopHdr.GetAction (); + if(multihopHdr.GetCategory () != WifiMeshMultihopActionHeader::MESH_PATH_SELECTION) + return true; + if(meshHdr.GetMeshTtl () == 0) + return false; + switch (actionValue.pathSelection) + { + case WifiMeshMultihopActionHeader::PATH_REQUEST: + { + IePreq preq; + NS_ASSERT(false); + packet->RemoveHeader (preq); + //TODO:recalculate + //metric + //m_preqReceived (preq, hdr->GetAddr2(), CalculateMetric(hdr->GetAddr2())); + return false; + } + case WifiMeshMultihopActionHeader::PATH_REPLY: + { + IePrep prep; + packet->RemoveHeader (prep); + //m_prepReceived (prep, hdr->GetAddr2(), CalculateMetric(hdr->GetAddr2())); + return false; + } + case WifiMeshMultihopActionHeader::PATH_ERROR: + { + IePerr perr; + packet->RemoveHeader (perr); + //m_perrReceived (perr, hdr->GetAddr2()); + return false; + } + case WifiMeshMultihopActionHeader::ROOT_ANNOUNCEMENT: + return false; + } + } return true; } bool HwmpMacPlugin::UpdateOutcomingFrame (Ptr packet, WifiMacHeader & header, Mac48Address from, Mac48Address to) const { //TODO: add a mesh header and remove a TAG + NS_ASSERT(header.IsData ()); HwmpTag tag; NS_ASSERT(packet->FindFirstMatchingTag(tag)); WifiMeshHeader meshHdr; @@ -97,111 +139,49 @@ HwmpMacPlugin::UpdateOutcomingFrame (Ptr packet, WifiMacHeader & header, return true; } #if 0 -TypeId -HwmpMacPlugin::GetTypeId () -{ - static TypeId tid = TypeId ("ns3::HwmpMacPlugin") - .SetParent () - .AddConstructor () - ; - return tid; -} - HwmpMacPlugin::HwmpMacPlugin (): m_myPreq (m_preqQueue.end()), - m_preqId (1), - m_myDsn (1), - m_disabled (false), - m_maxTtl (10) { } -void -HwmpMacPlugin::SetRequestRouteCallback ( - Callback cb) -{ - m_requestRouteCallback = cb; -} -void -HwmpMacPlugin::SetRequestRootPathCallback ( - Callback cb) -{ - m_requestRootPathCallback = cb; -} - -//Setting MAC -void -HwmpMacPlugin::SetMac (Ptr mac) -{ - mac->SetPeerStatusCallback (MakeCallback(&HwmpMacPlugin::PeerStatus, this)); - mac->SetPreqReceivedCallback (MakeCallback(&HwmpMacPlugin::ReceivePreq, this)); - mac->SetPrepReceivedCallback (MakeCallback(&HwmpMacPlugin::ReceivePrep, this)); - mac->SetPerrReceivedCallback (MakeCallback(&HwmpMacPlugin::ReceivePerr, this)); - m_address = mac->GetAddress (); - m_preqCallback = MakeCallback (&MeshWifiMac::SendPreq, mac); - m_prepCallback = MakeCallback (&MeshWifiMac::SendPrep, mac); - m_perrCallback = MakeCallback (&MeshWifiMac::SendPerr, mac); -} HwmpMacPlugin::~HwmpMacPlugin () { m_preqQueue.clear (); } //Interaction with HWMP: +#endif void -HwmpMacPlugin::SetRoutingInfoCallback ( - Callback cb -) +HwmpMacPlugin::SendPreq(IePreq, std::vector receivers) { - m_routingInfoCallback = cb; + NS_ASSERT(false); } - -void -HwmpMacPlugin::SetRetransmittersOfPerrCallback ( - Callback, std::vector, uint32_t> cb) -{ - m_retransmittersOfPerrCallback = cb; -} - void HwmpMacPlugin::RequestDestination (Mac48Address dst) { if (m_preqQueue.end () == m_myPreq) - { - IeDot11sPreq preq; - //fill PREQ: - preq.SetHopcount (0); - preq.SetTTL (m_maxTtl); - preq.SetPreqID (m_preqId++); - if (m_preqId == MAX_PREQ_ID) - m_preqId = 0; - preq.SetLifetime (TIME_TO_TU(dot11sParameters::dot11MeshHWMPactivePathTimeout)); - preq.SetOriginatorSeqNumber (m_myDsn++); - if (m_myDsn == MAX_DSN) - m_myDsn = 0; - preq.SetOriginatorAddress (m_address); - preq.AddDestinationAddressElement (false, false, dst, 0); //DO = 0, RF = 0 - if (m_preqTimer.IsRunning ()) - { - NS_LOG_DEBUG ("No my preq"); - m_preqQueue.push_back (preq); - //set iterator position to my preq: - m_myPreq = m_preqQueue.end () -1; - } - else - { - NS_LOG_DEBUG ("Send PREQ now, "<GetMaxTtl ()); + preq.SetPreqID (m_protocol->GetNextPreqId ()); + preq.SetOriginatorAddress (m_parent->GetAddress ()); + preq.SetOriginatorSeqNumber (m_protocol->GetNextHwmpSeqno()); + preq.AddDestinationAddressElement (false, false, dst, 0); //DO = 0, RF = 0 + m_preqQueue.push_back (preq); + //set iterator position to my preq: + m_myPreq = m_preqQueue.end () -1; + NS_LOG_UNCOND("no preq"); + SendOnePreq (); + } else - { - NS_ASSERT (m_myPreq->GetOriginatorAddress() == m_address); - NS_LOG_DEBUG ("add a destination "<AddDestinationAddressElement (false, false, dst, 0); //DO = 0, RF = 0 - } + { + NS_ASSERT (m_myPreq->GetOriginatorAddress() == m_parent->GetAddress()); + NS_LOG_UNCOND ("add a destination "<AddDestinationAddressElement (false, false, dst, 0); //DO = 0, RF = 0 + } } +#if 0 void HwmpMacPlugin::SendPathError (std::vector destinations) { @@ -229,17 +209,6 @@ HwmpMacPlugin::SendPathError (std::vector destina } } //needed to fill routing information structure -void -HwmpMacPlugin::SetAssociatedIfaceId (uint32_t interface) -{ - m_ifIndex = interface; -} - -uint32_t -HwmpMacPlugin::GetAssociatedIfaceId () -{ - return m_ifIndex; -} //Interaction with MAC: void @@ -472,53 +441,6 @@ HwmpMacPlugin::PeerStatus (const Mac48Address peerAddress, const bool status, co newInfo.type = INFO_FAILED_PEER; m_routingInfoCallback (newInfo); } - -bool -HwmpMacPlugin::SetRoot () -{ -#if 0 - //TODO:: delete this lines!!!!!!! - if (m_address != Mac48Address ("00:00:00:00:00:10")) - return false; - //TODO -#endif - Simulator::Schedule (dot11sParameters::dot11MeshHWMPactiveRootTimeout, &HwmpMacPlugin::SendProactivePreq, this); - return true; -} - -void -HwmpMacPlugin::SendProactivePreq () -{ - NS_LOG_DEBUG ("Sending proactive PREQ"); - IeDot11sPreq preq; - //By default: must answer - preq.SetHopcount (0); - preq.SetTTL (m_maxTtl); - preq.SetPreqID (m_preqId++); - if (m_preqId == MAX_PREQ_ID) - m_preqId = 0; - preq.SetLifetime (TIME_TO_TU(dot11sParameters::dot11MeshHWMPpathToRootInterval)); - preq.SetOriginatorSeqNumber (m_myDsn++); - if (m_myDsn == MAX_DSN) - m_myDsn = 0; - preq.SetOriginatorAddress (m_address); - preq.AddDestinationAddressElement ( - true, - true, - Mac48Address::GetBroadcast () - ,0); - if (m_preqTimer.IsRunning ()) - m_preqQueue.push_back (preq); - else - { - NS_LOG_DEBUG ("Send now "<GetAddress ()); + //Create packet + Ptr packet = Create (); + packet->AddHeader(preq); + //Multihop action header: + WifiMeshMultihopActionHeader multihopHdr; + WifiMeshMultihopActionHeader::ACTION_VALUE action; + action.pathSelection = WifiMeshMultihopActionHeader::PATH_REQUEST; + multihopHdr.SetAction (WifiMeshMultihopActionHeader::MESH_PATH_SELECTION, action); + packet->AddHeader (multihopHdr); + //Mesh header + WifiMeshHeader meshHdr; + meshHdr.SetMeshTtl (m_protocol->GetMaxTtl ()); + //TODO: should seqno be here? + meshHdr.SetMeshSeqno (0); + meshHdr.SetAddressExt(1); + meshHdr.SetAddr4(preq.GetOriginatorAddress ()); + packet->AddHeader (meshHdr); + //create 802.11 header: + WifiMacHeader hdr; + hdr.SetMultihopAction (); + hdr.SetDsNotFrom (); + hdr.SetDsNotTo (); + hdr.SetAddr1 (Mac48Address::GetBroadcast ()); + hdr.SetAddr2 (m_parent->GetAddress ()); + hdr.SetAddr3 (Mac48Address::GetBroadcast ()); + //Send Management frame + m_parent->SendManagementFrame(packet, hdr); //erase first! m_preqQueue.erase (m_preqQueue.begin()); //reschedule sending PREQ NS_ASSERT (!m_preqTimer.IsRunning()); - m_preqTimer = Simulator::Schedule (dot11sParameters::dot11MeshHWMPpreqMinInterval, &HwmpMacPlugin::SendOnePreq, this); + m_preqTimer = Simulator::Schedule (m_protocol->GetPreqMinInterval (), &HwmpMacPlugin::SendOnePreq, this); } - +#if 0 void HwmpMacPlugin::SendPrep (Mac48Address dst, Mac48Address src, diff --git a/src/devices/mesh/dot11s/hwmp-mac-plugin.h b/src/devices/mesh/dot11s/hwmp-mac-plugin.h index 8d135af19..9ebe1ed88 100644 --- a/src/devices/mesh/dot11s/hwmp-mac-plugin.h +++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.h @@ -36,29 +36,43 @@ class IePerr; */ class HwmpMacPlugin : public MeshWifiInterfaceMacPlugin { - public: - HwmpMacPlugin (uint32_t, Ptr); - ~HwmpMacPlugin (); - ///\name Inherited from MAC plugin - //\{ - void SetParent (Ptr parent); - bool Receive (Ptr packet, const WifiMacHeader & header); - bool UpdateOutcomingFrame (Ptr packet, WifiMacHeader & header, Mac48Address from, Mac48Address to) const; - ///\brief Update beacon is empty, because HWMP does not know - //anything about beacons - void UpdateBeacon (MeshWifiBeacon & beacon) const {}; - //\} - private: - friend class HwmpProtocol; - ///\brief Interaction with protocol: - void SendPreq(Ptr preq, std::vector receivers); - void SendPrep(Ptr prep, std::vector receivers); - void SendPerr(Ptr perr, std::vector receivers); - private: - Ptr m_parent; - uint32_t m_ifIndex; - Ptr m_protocol; +public: + HwmpMacPlugin (uint32_t, Ptr); + ~HwmpMacPlugin (); + ///\name Inherited from MAC plugin + //\{ + void SetParent (Ptr parent); + bool Receive (Ptr packet, const WifiMacHeader & header); + bool UpdateOutcomingFrame (Ptr packet, WifiMacHeader & header, Mac48Address from, Mac48Address to) const; + ///\brief Update beacon is empty, because HWMP does not know + //anything about beacons + void UpdateBeacon (MeshWifiBeacon & beacon) const {}; + //\} +private: + friend class HwmpProtocol; + ///\brief Interaction with protocol: + ///\name Intercation with HWMP: + ///\{ + void SendPreq(IePreq preq, std::vector receivers); + void SendPrep(IePreq prep, Mac48Address receiver); + void SendPerr(IePreq perr, std::vector receivers); + void RequestDestination (Mac48Address dest); + ///\} + ///\brief Sends one PREQ when PreqMinInterval after last PREQ + //expires (if any PREQ exists in rhe queue) + void SendOnePreq (); +private: + Ptr m_parent; + uint32_t m_ifIndex; + Ptr m_protocol; + ///\name PREQ queue and PREQ timer: + ///\{ + EventId m_preqTimer; + std::vector m_preqQueue; + std::vector::iterator m_myPreq; + ///\} }; + #if 0 class HwmpMacPlugin : public MeshWifiInterfaceMacPlugin { public: @@ -102,7 +116,6 @@ public: ); void SetRetransmittersOfPerrCallback ( Callback, std::vector, uint32_t> cb); - void RequestDestination (Mac48Address dest); void SendPathError (std::vector destinations); void SetAssociatedIfaceId (uint32_t interface); uint32_t GetAssociatedIfaceId (); @@ -117,34 +130,10 @@ public: void ReceivePreq (IeDot11sPreq&, const Mac48Address& from, const uint32_t& metric); void ReceivePrep (IeDot11sPrep&, const Mac48Address& from, const uint32_t& metric); void ReceivePerr (IeDot11sPerr&, const Mac48Address& from); - void PeerStatus ( - const Mac48Address peerAddress, - const bool status, - const uint32_t metric - ); - //Proactive mode routines: - bool SetRoot (); - void UnSetRoot (); - //external handling: - void Disable (); - void Enable (); - //DEBUG purpose: - Mac48Address GetAddress (); private: - static const uint32_t MAX_PREQ_ID = 0xffffffff; - static const uint32_t MAX_DSN = 0xffffffff; - //information about associated port: - Mac48Address m_address; - //index when HWMP state is attached - uint32_t m_ifIndex; - //timers for PREQ and PREP: - EventId m_preqTimer; - void SendOnePreq (); - std::vector m_preqQueue; //true means that we can add a destination to //existing PREQ element //False means that we must send - EventId m_prepTimer; void SendPrep ( Mac48Address dst, //dst is PREQ's originator address Mac48Address src, //src is PREQ's destination address @@ -154,7 +143,6 @@ private: uint32_t originatorDsn, //taken from rtable or as m_myDsn ++; uint32_t lifetime //taken from PREQ ); - std::vector::iterator m_myPreq; //HWMP interaction callbacks: Callback m_routingInfoCallback; Callback, std::vector, uint32_t> m_retransmittersOfPerrCallback; diff --git a/src/devices/mesh/dot11s/hwmp-protocol.cc b/src/devices/mesh/dot11s/hwmp-protocol.cc index fc63b6966..22f460d56 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc @@ -30,6 +30,9 @@ #include "ns3/wifi-net-device.h" #include "ns3/mesh-point-device.h" #include "ns3/mesh-wifi-interface-mac.h" +#include "ie-dot11s-preq.h" +#include "ie-dot11s-prep.h" +#include "ie-dot11s-perr.h" NS_LOG_COMPONENT_DEFINE ("HwmpProtocol"); @@ -55,7 +58,7 @@ HwmpProtocol::GetTypeId () MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPnetDiameterTraversalTime), MakeTimeChecker () ) - .AddAttribute ("dot11MeshHWMPpreqMinInterva", + .AddAttribute ("dot11MeshHWMPpreqMinInterval", "Minimal interval between to successive PREQs", TimeValue (MicroSeconds (1024*100)), MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPpreqMinInterval), @@ -118,10 +121,13 @@ HwmpProtocol::GetTypeId () return tid; } HwmpProtocol::HwmpProtocol (): - m_dataSeqno(1), - m_hwmpSeqno(1), + m_dataSeqno (1), + m_hwmpSeqno (1), + m_preqId (0), m_rtable (CreateObject ()), - m_isRoot (false) + m_isRoot (false), + m_doFlag (false), + m_rfFlag (false) { } @@ -139,6 +145,7 @@ HwmpProtocol::DoDispose () m_lastHwmpSeqno.clear (); m_rqueue.clear (); m_rtable = 0; + //TODO: clear plugins } @@ -157,7 +164,6 @@ HwmpProtocol::RequestRoute ( if (sourceIface == GetMeshPoint ()->GetIfIndex()) // packet from level 3 { - NS_LOG_UNCOND("Packet from upper layer. Broadcast frame"); NS_ASSERT (!packet->FindFirstMatchingTag(tag)); //Filling TAG: tag.SetSeqno (m_dataSeqno++); @@ -208,7 +214,9 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, const Mac48Address source, c return false; } //Request a destination: - NS_ASSERT(false); + if(ShouldSendPreq(destination)) + for(PLUGINS::iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++) + i->second->RequestDestination(destination); QueuedPacket pkt; HwmpTag tag; tag.SetAddress(Mac48Address::GetBroadcast ()); @@ -369,6 +377,13 @@ HwmpProtocol::GetPerrReceivers (std::vector failedDes } return retransmitters; } +std::vector +HwmpProtocol::GetPreqReceivers () +{ + std::vector retval; + retval.push_back (Mac48Address::GetBroadcast ()); + return retval; +} bool HwmpProtocol::QueuePacket (QueuedPacket packet) { @@ -452,6 +467,7 @@ HwmpProtocol::ShouldSendPreq (Mac48Address dst) std::map::iterator i = m_preqTimeouts.find (dst); if (i == m_preqTimeouts.end ()) { + NS_LOG_UNCOND("Timeout is:" <<2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())); m_preqTimeouts[dst] = Simulator::Schedule ( MilliSeconds (2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())), &HwmpProtocol::RetryPathDiscovery, this, dst, 0); @@ -489,11 +505,82 @@ HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry) m_preqTimeouts.erase (i); return; } - //TODO: Request a destination again - NS_ASSERT(false); + for(PLUGINS::iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++) + i->second->RequestDestination(dst); m_preqTimeouts[dst] = Simulator::Schedule ( MilliSeconds (2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())), &HwmpProtocol::RetryPathDiscovery, this, dst, numOfRetry); } +//Proactive PREQ routines: +void +HwmpProtocol::SetRoot () +{ + SendProactivePreq (); + m_isRoot = true; +} +void +HwmpProtocol::UnsetRoot () +{ + m_proactivePreqTimer.Cancel (); +} +void +HwmpProtocol::SendProactivePreq () +{ + NS_LOG_DEBUG ("Sending proactive PREQ"); + IePreq preq; + //By default: must answer + preq.SetHopcount (0); + preq.SetTTL (m_maxTtl); + if (m_preqId == 0xffffffff) + m_preqId = 0; + preq.SetLifetime (m_dot11MeshHWMPpathToRootInterval.GetMicroSeconds () /1024); + //\attention: do not forget to set originator address, sequence + //number and preq ID in HWMP-MAC plugin + preq.AddDestinationAddressElement (true, true, Mac48Address::GetBroadcast (), 0); + for(PLUGINS::iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++) + i->second->SendPreq(preq, GetPreqReceivers ()); + m_proactivePreqTimer = Simulator::Schedule (m_dot11MeshHWMPactiveRootTimeout, &HwmpProtocol::SendProactivePreq, this); +} +bool +HwmpProtocol::GetDoFlag () +{ + return m_doFlag; +} +bool +HwmpProtocol::GetRfFlag () +{ + return m_rfFlag; +} +Time +HwmpProtocol::GetPreqMinInterval () +{ + return m_dot11MeshHWMPpreqMinInterval; +} +Time +HwmpProtocol::GetPerrMinInterval () +{ + return m_dot11MeshHWMPperrMinInterval; +} +uint8_t +HwmpProtocol::GetMaxTtl () +{ + return m_maxTtl; +} +uint32_t +HwmpProtocol::GetNextPreqId () +{ + m_preqId ++; + if(m_preqId == 0xffffffff) + m_preqId = 0; + return m_preqId; +} +uint32_t +HwmpProtocol::GetNextHwmpSeqno () +{ + m_hwmpSeqno ++; + if(m_hwmpSeqno == 0xffffffff) + m_hwmpSeqno = 0; + return m_hwmpSeqno; +} } //namespace dot11s } //namespace ns3 diff --git a/src/devices/mesh/dot11s/hwmp-protocol.h b/src/devices/mesh/dot11s/hwmp-protocol.h index 4802095a3..b1a3c2845 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.h +++ b/src/devices/mesh/dot11s/hwmp-protocol.h @@ -25,6 +25,7 @@ #include "ns3/mesh-l2-routing-protocol.h" #include "ns3/nstime.h" #include "ns3/ie-dot11s-perr.h" +#include "ns3/event-id.h" #include #include @@ -32,7 +33,6 @@ namespace ns3 { class MeshPointDevice; class Packet; class Mac48Address; -class EventId; namespace dot11s { class HwmpMacPlugin; class HwmpRtable; @@ -65,9 +65,9 @@ private: //destination fails on a given interface //\param uint32_t is an interface ID, where route has failed void MakePathError (Mac48Address, uint32_t); - ///\return list of addresses where a perr should be sent to + ///\return list of addresses where a PERR/PREQ should be sent to std::vector GetPerrReceivers (std::vector failedDest, uint32_t port); - + std::vector GetPreqReceivers (); ///\brief MAC-plugin asks wether the frame can be dropeed. Protocol //automatically updates seqno. //\returns true if frame can be dropped @@ -96,24 +96,33 @@ private: //maximum level - retry mechanish should be cancelled void RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry); ///\} + ///\name Proactive Preq routines: + ///\{ + void SetRoot (); + void UnsetRoot (); + void SendProactivePreq (); + ///\} private: //fields: - std::map > m_interfaces; + typedef std::map > PLUGINS; + PLUGINS m_interfaces; uint32_t m_dataSeqno; uint32_t m_hwmpSeqno; + uint32_t m_preqId; ///\brief Sequence number filters: - std::map > m_lastDataSeqno; - std::map > m_lastHwmpSeqno; + std::map > m_lastDataSeqno; + std::map > m_lastHwmpSeqno; ///\brief Routing table Ptr m_rtable; ///\name Timers: //\{ - std::map m_preqTimeouts; + std::map m_preqTimeouts; + EventId m_proactivePreqTimer; //\} ///\Packet Queue - std::vector m_rqueue; + std::vector m_rqueue; private: - ///\name HWMP-protocol parameters + ///\name HWMP-protocol parameters (attributes of GetTypeId) ///\{ uint8_t m_dot11MeshHWMPmaxPREQretries; Time m_dot11MeshHWMPnetDiameterTraversalTime; @@ -127,6 +136,19 @@ private: uint8_t m_maxTtl; uint8_t m_unicastPerrThreshold; uint8_t m_unicastPreqThreshold; + bool m_doFlag; + bool m_rfFlag; + ///\} + ///\name Methods needed by HwmpMacLugin to access protocol + //parameters: + ///\{ + bool GetDoFlag (); + bool GetRfFlag (); + Time GetPreqMinInterval (); + Time GetPerrMinInterval (); + uint8_t GetMaxTtl (); + uint32_t GetNextPreqId (); + uint32_t GetNextHwmpSeqno (); ///\} }; } //namespace dot11s diff --git a/src/devices/mesh/dot11s/peer-management-plugin.cc b/src/devices/mesh/dot11s/peer-management-plugin.cc index bc3cfd4d3..52ecad804 100644 --- a/src/devices/mesh/dot11s/peer-management-plugin.cc +++ b/src/devices/mesh/dot11s/peer-management-plugin.cc @@ -89,7 +89,6 @@ PeerManagerMacPlugin::Receive (Ptr const_packet, const WifiMacHeader & h NS_ASSERT(meshHdr.GetMeshTtl () == 1); NS_ASSERT(meshHdr.GetAddressExt () == 1); NS_ASSERT(meshHdr.GetAddr4 () == header.GetAddr2 ()); - Mac48Address peerAddress = header.GetAddr2 (); PeerLinkFrameStart::PlinkFrameStartFields fields; { @@ -116,7 +115,7 @@ PeerManagerMacPlugin::Receive (Ptr const_packet, const WifiMacHeader & h // frames except CLOSE IeConfiguration meshConfig; if(fields.subtype != IePeerManagement::PEER_CLOSE) - packet->RemoveHeader(meshConfig); + packet->RemoveHeader(meshConfig); IePeerManagement peerElement; packet->RemoveHeader(peerElement); // Check the correspondance betwee action valuse and peer link @@ -141,11 +140,7 @@ PeerManagerMacPlugin::Receive (Ptr const_packet, const WifiMacHeader & h // if we can handle a frame - drop it return false; } - if(header.IsData()) - { - return m_protocol->IsActiveLink(m_ifIndex,header.GetAddr2()); - } - return true; + return m_protocol->IsActiveLink(m_ifIndex,header.GetAddr2()); } bool diff --git a/src/devices/mesh/dot11s/peer-management-protocol.cc b/src/devices/mesh/dot11s/peer-management-protocol.cc index 910f24499..4b5dea24b 100644 --- a/src/devices/mesh/dot11s/peer-management-protocol.cc +++ b/src/devices/mesh/dot11s/peer-management-protocol.cc @@ -26,7 +26,6 @@ #include "ie-dot11s-configuration.h" #include "ns3/mesh-point-device.h" -#include "ns3/dot11s-parameters.h" #include "ns3/simulator.h" #include "ns3/assert.h" #include "ns3/log.h" @@ -272,9 +271,11 @@ PeerManagerProtocol::InitiateLink ( BeaconInfoMap::iterator beaconsOnInterface = m_neighbourBeacons.find (interface); if(beaconsOnInterface == m_neighbourBeacons.end()) FillBeaconInfo(interface, peerAddress, lastBeacon, beaconInterval); + beaconsOnInterface = m_neighbourBeacons.find (interface); BeaconsOnInterface::iterator beacon = beaconsOnInterface->second.find (peerAddress); if(beacon == beaconsOnInterface->second.end ()) FillBeaconInfo(interface, peerAddress, lastBeacon, beaconInterval); + beacon = beaconsOnInterface->second.find (peerAddress); //find a peer link - it must not exist NS_ASSERT(FindPeerLink(interface, peerAddress) == 0); // Plugin must exist