diff --git a/src/devices/mesh/dot11s-parameters.cc b/src/devices/mesh/dot11s-parameters.cc deleted file mode 100644 index e8883af86..000000000 --- a/src/devices/mesh/dot11s-parameters.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2008,2009 IITP RAS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Authors: Aleksey Kovalenko - * Kirill Andreev - */ - - -#include "ns3/dot11s-parameters.h" - -namespace ns3 { - -uint8_t dot11sParameters::dot11MeshMaxRetries = 4; -Time dot11sParameters::dot11MeshRetryTimeout = TU_TO_TIME (40); -Time dot11sParameters::dot11MeshHoldingTimeout = TU_TO_TIME (40); -Time dot11sParameters::dot11MeshConfirmTimeout = TU_TO_TIME (40); - - -uint8_t dot11sParameters::dot11MeshHWMPmaxPREQretries = 3; -Time dot11sParameters::dot11MeshHWMPnetDiameterTraversalTime = TU_TO_TIME (10); -Time dot11sParameters::dot11MeshHWMPpreqMinInterval = TU_TO_TIME (100); -Time dot11sParameters::dot11MeshHWMPperrMinInterval = TU_TO_TIME (100); -Time dot11sParameters::dot11MeshHWMPactiveRootTimeout = TU_TO_TIME (5000); -Time dot11sParameters::dot11MeshHWMPactivePathTimeout = TU_TO_TIME (5000); -Time dot11sParameters::dot11MeshHWMPpathToRootInterval = TU_TO_TIME (5000); -Time dot11sParameters::dot11MeshHWMPrannInterval = TU_TO_TIME (1000); - -} diff --git a/src/devices/mesh/dot11s-parameters.h b/src/devices/mesh/dot11s-parameters.h deleted file mode 100644 index a2a46c9e5..000000000 --- a/src/devices/mesh/dot11s-parameters.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2008,2009 IITP RAS - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Authors: Aleksey Kovalenko - * Kirill Andreev - */ - - -#ifndef DOT11S_PARAMETERS_H -#define DOT11S_PARAMETERS_H -#include "ns3/uinteger.h" -#include "ns3/nstime.h" - -namespace ns3 { - -#define TU_TO_TIME(x) (MicroSeconds((x)*1024)) -#define TIME_TO_TU(x) ((x).GetMicroSeconds()/1024) - -/** - * \ingroup mesh -*/ -struct dot11sParameters -{ - /** Peer Link */ - static uint8_t dot11MeshMaxRetries; - static Time dot11MeshRetryTimeout; - static Time dot11MeshHoldingTimeout; - static Time dot11MeshConfirmTimeout; - /** HWMP */ - static uint8_t dot11MeshHWMPmaxPREQretries; - static Time dot11MeshHWMPnetDiameterTraversalTime; - static Time dot11MeshHWMPpreqMinInterval; - static Time dot11MeshHWMPperrMinInterval; - static Time dot11MeshHWMPactiveRootTimeout; - static Time dot11MeshHWMPactivePathTimeout; - static Time dot11MeshHWMPpathToRootInterval; - static Time dot11MeshHWMPrannInterval; -}; - -}; -#endif diff --git a/src/devices/mesh/dot11s/hwmp-mac-plugin.h b/src/devices/mesh/dot11s/hwmp-mac-plugin.h index ab674e5c8..8d135af19 100644 --- a/src/devices/mesh/dot11s/hwmp-mac-plugin.h +++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.h @@ -51,9 +51,9 @@ class HwmpMacPlugin : public MeshWifiInterfaceMacPlugin private: friend class HwmpProtocol; ///\brief Interaction with protocol: - void SendPreq(Ptr preq); - void SendPrep(Ptr prep); - void SendPerr(Ptr perr); + 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; diff --git a/src/devices/mesh/dot11s/hwmp-protocol.cc b/src/devices/mesh/dot11s/hwmp-protocol.cc index 69909efbe..b12f3130e 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc @@ -41,8 +41,62 @@ TypeId HwmpProtocol::GetTypeId () { static TypeId tid = TypeId ("ns3::HwmpProtocol") - .SetParent () - .AddConstructor (); + .SetParent () + .AddConstructor () + .AddAttribute ("dot11MeshHWMPmaxPREQretries", + "Maximum number of retries before we suppose the destination to be unreachable", + UintegerValue (3), + MakeUintegerAccessor (&HwmpProtocol::m_dot11MeshHWMPmaxPREQretries), + MakeUintegerChecker (1) + ) + .AddAttribute ("dot11MeshHWMPnetDiameterTraversalTime", + "Time we suppose the packet to go from one edge of the network to another", + TimeValue (MicroSeconds (1024*10)), + MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPnetDiameterTraversalTime), + MakeTimeChecker () + ) + .AddAttribute ("dot11MeshHWMPpreqMinInterva", + "Minimal interval between to successive PREQs", + TimeValue (MicroSeconds (1024*100)), + MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPpreqMinInterval), + MakeTimeChecker () + ) + .AddAttribute ("dot11MeshHWMPperrMinInterval", + "Minimal interval between to successive PREQs", + TimeValue (MicroSeconds (1024*100)), + MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPperrMinInterval), + MakeTimeChecker () + ) + .AddAttribute ("dot11MeshHWMPactiveRootTimeout", + "Lifetime of poractive routing information", + TimeValue (MicroSeconds (1024*5000)), + MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPactiveRootTimeout), + MakeTimeChecker () + ) + .AddAttribute ("dot11MeshHWMPactiveRootTimeout", + "Lifetime of poractive routing information", + TimeValue (MicroSeconds (1024*5000)), + MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPactiveRootTimeout), + MakeTimeChecker () + ) + .AddAttribute ("dot11MeshHWMPactivePathTimeout", + "Lifetime of reactive routing information", + TimeValue (MicroSeconds (1024*5000)), + MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPactivePathTimeout), + MakeTimeChecker () + ) + .AddAttribute ("dot11MeshHWMPpathToRootInterval", + "Interval between two successive proactive PREQs", + TimeValue (MicroSeconds (1024*5000)), + MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPpathToRootInterval), + MakeTimeChecker () + ) + .AddAttribute ("dot11MeshHWMPrannInterval", + "Lifetime of poractive routing information", + TimeValue (MicroSeconds (1024*5000)), + MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPrannInterval), + MakeTimeChecker () + ); return tid; } HwmpProtocol::HwmpProtocol (): @@ -61,9 +115,9 @@ void HwmpProtocol::DoDispose () { #if 0 - for (std::map::iterator i = m_timeoutDatabase.begin (); i != m_timeoutDatabase.end(); i ++) + for (std::map::iterator i = m_preqTimeouts.begin (); i != m_preqTimeouts.end(); i ++) i->second.Cancel (); - m_timeoutDatabase.clear (); + m_preqTimeouts.clear (); m_seqnoDatabase.clear (); m_rtable = 0; @@ -531,16 +585,15 @@ HwmpProtocol::SendAllPossiblePackets (Mac48Address dst) } #endif } -#if 0 bool HwmpProtocol::ShouldSendPreq (Mac48Address dst) { - std::map::iterator i = m_timeoutDatabase.find (dst); - if (i == m_timeoutDatabase.end ()) + std::map::iterator i = m_preqTimeouts.find (dst); + if (i == m_preqTimeouts.end ()) { - m_timeoutDatabase[dst] = Simulator::Schedule ( - MilliSeconds (2*(dot11sParameters::dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())), - &HwmpProtocol::RetryPathDiscovery, this, dst, 0); + m_preqTimeouts[dst] = Simulator::Schedule ( + MilliSeconds (2*(m_dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())), + &HwmpProtocol::RetryPathDiscovery, this, dst, 0); return true; } return false; @@ -548,12 +601,13 @@ HwmpProtocol::ShouldSendPreq (Mac48Address dst) void HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry) { +#if 0 HwmpRtable::LookupResult result = m_rtable->LookupReactive (dst); if (result.retransmitter != Mac48Address::GetBroadcast ()) { - std::map::iterator i = m_timeoutDatabase.find (dst); - NS_ASSERT (i != m_timeoutDatabase.end()); - m_timeoutDatabase.erase (i); + std::map::iterator i = m_preqTimeouts.find (dst); + NS_ASSERT (i != m_preqTimeouts.end()); + m_preqTimeouts.erase (i); return; } numOfRetry++; @@ -568,18 +622,20 @@ HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry) break; packet.reply (false, packet.pkt, packet.src, packet.dst, packet.protocol, HwmpRtable::MAX_METRIC); } - std::map::iterator i = m_timeoutDatabase.find (dst); - NS_ASSERT (i != m_timeoutDatabase.end()); - m_timeoutDatabase.erase (i); + std::map::iterator i = m_preqTimeouts.find (dst); + NS_ASSERT (i != m_preqTimeouts.end()); + m_preqTimeouts.erase (i); return; } +#if 0 for (unsigned int i = 0; i < m_requestCallback.size (); i++) if ((m_modes[i] == REACTIVE) || (m_modes[i] == ROOT)) m_requestCallback[i] (dst); - m_timeoutDatabase[dst] = Simulator::Schedule ( +#endif + m_preqTimeouts[dst] = Simulator::Schedule ( MilliSeconds (2*(dot11sParameters::dot11MeshHWMPnetDiameterTraversalTime.GetMilliSeconds())), &HwmpProtocol::RetryPathDiscovery, this, dst, numOfRetry); -} #endif +} } //namespace dot11s } //namespace ns3 diff --git a/src/devices/mesh/dot11s/hwmp-protocol.h b/src/devices/mesh/dot11s/hwmp-protocol.h index e35f49120..d9a2d85ff 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.h +++ b/src/devices/mesh/dot11s/hwmp-protocol.h @@ -23,12 +23,14 @@ #define HWMP_PROTOCOL_H #include "ns3/mesh-l2-routing-protocol.h" +#include "ns3/nstime.h" #include namespace ns3 { class MeshPointDevice; class Packet; class Mac48Address; +class EventId; namespace dot11s { class HwmpMacPlugin; class HwmpRtable; @@ -112,9 +114,9 @@ public: private: friend class HwmpMacPlugin; ///\brief interaction with HWMP MAC plugin - void ReceivePreq(Ptr preq); - void ReceivePrep(Ptr prep); - void ReceivePerr(Ptr perr); + void ReceivePreq(Ptr preq, Mac48Address from); + void ReceivePrep(Ptr prep, Mac48Address from); + void ReceivePerr(Ptr perr, Mac48Address from); ///\brief MAC-plugin asks wether the frame can be dropeed. Protocol //automatically updates seqno. //\returns true if frame can be dropped @@ -127,6 +129,17 @@ private: bool QueuePacket (MeshL2RoutingProtocol::QueuedPacket packet); MeshL2RoutingProtocol::QueuedPacket DequeuePacket (Mac48Address dst); void SendAllPossiblePackets (Mac48Address dst); + ///\name Methods responsible for Path discovery retry procedure: + //\{ + //\brief checks when the last path discovery procedure was started + //for a given destination. If the retry counter has not achieved the + //maximum level - preq should not be sent + bool ShouldSendPreq (Mac48Address dst); + //\brief Generates PREQ retry when retry timeout has expired and + //route is still unresolved. When PREQ retry has achieved the + //maximum level - retry mechanish should be cancelled + void RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry); + ///\} private: //fields: std::map > m_interfaces; @@ -138,24 +151,31 @@ private: std::map > m_lastHwmpSeqno; ///\brief Routing table Ptr m_rtable; - + ///\name Timers: + //\{ + std::map m_preqTimeouts; + //\} +private: + ///\name HWMP-protocol parameters + ///\{ + uint8_t m_dot11MeshHWMPmaxPREQretries; + Time m_dot11MeshHWMPnetDiameterTraversalTime; + Time m_dot11MeshHWMPpreqMinInterval; + Time m_dot11MeshHWMPperrMinInterval; + Time m_dot11MeshHWMPactiveRootTimeout; + Time m_dot11MeshHWMPactivePathTimeout; + Time m_dot11MeshHWMPpathToRootInterval; + Time m_dot11MeshHWMPrannInterval; + ///\} #if 0 std::map > m_rqueue; //devices and HWMP states: - enum DeviceState { - ENABLED, - DISABLED - }; enum DeviceMode { REACTIVE, PROACTIVE, ROOT }; - std::vector m_states; std::vector m_modes; - std::vector > m_hwmpStates; - //Routing table: - Ptr m_rtable; //Proactive routines: /** * \brief Set port state as proactive. @@ -170,27 +190,7 @@ private: * port */ bool IsRoot (uint32_t port); - /** - * \brief Interaction with HwmpProtocolState class - - * request for starting routing discover - * procedure (reactive route discovery!) - * \param Mac48Address is destination to be - * resolved - */ - std::vector< Callback > m_requestCallback; - /** - * \brief Callback that shall be executed when - * need to send Path error - * \param std::vector is the - * list of unreachable destinations - * \param std::vector is - * receivers of PERR - */ - std::vector > > m_pathErrorCallback; - void StartPathErrorProcedure ( - std::vector destinations, - uint32_t port); - /** + /** * \brief HwmpProtocolState need to know where to * retransmit PERR, only HWMP knows how to * retransmit it (broadcast/unicast) and only @@ -231,11 +231,10 @@ private: * Keeps PREQ retry timers for every * destination */ - std::map m_timeoutDatabase; + std::map m_preqTimeouts; /** * Configurable parameters: */ - uint8_t m_maxTtl; bool m_broadcastPerr; #endif }; diff --git a/src/devices/mesh/dot11s/peer-link.cc b/src/devices/mesh/dot11s/peer-link.cc index 13389125b..c0f1f0d8f 100644 --- a/src/devices/mesh/dot11s/peer-link.cc +++ b/src/devices/mesh/dot11s/peer-link.cc @@ -40,22 +40,22 @@ PeerLink::GetTypeId() .AddConstructor () .AddAttribute ("RetryTimeout", "Retry timeout", TimeValue (TimeValue (MicroSeconds (40 * 1024))), - MakeTimeAccessor (&PeerLink::m_retryTimeout), + MakeTimeAccessor (&PeerLink::m_dot11MeshRetryTimeout), MakeTimeChecker () ) .AddAttribute ("HoldingTimeout", "Holding timeout", TimeValue (TimeValue (MicroSeconds (40 * 1024))), - MakeTimeAccessor (&PeerLink::m_holdingTimeout), + MakeTimeAccessor (&PeerLink::m_dot11MeshHoldingTimeout), MakeTimeChecker () ) .AddAttribute ("ConfirmTimeout", "Confirm timeout", TimeValue (TimeValue (MicroSeconds (40 * 1024))), - MakeTimeAccessor (&PeerLink::m_confirmTimeout), + MakeTimeAccessor (&PeerLink::m_dot11MeshConfirmTimeout), MakeTimeChecker () ) .AddAttribute ("MaxRetries", "Maximum number of retries", UintegerValue (4), - MakeUintegerAccessor (&PeerLink::m_maxRetries), + MakeUintegerAccessor (&PeerLink::m_dot11MeshMaxRetries), MakeUintegerChecker () ) .AddAttribute ("MaxBeaconLoss", "Maximum number of lost beacons before link will be closed", @@ -530,8 +530,8 @@ void PeerLink::SendPeerLinkConfirm () void PeerLink::SetHoldingTimer () { - NS_ASSERT(m_holdingTimeout.GetMicroSeconds() !=0); - m_holdingTimer = Simulator::Schedule (m_holdingTimeout, &PeerLink::HoldingTimeout, this); + NS_ASSERT(m_dot11MeshHoldingTimeout.GetMicroSeconds() !=0); + m_holdingTimer = Simulator::Schedule (m_dot11MeshHoldingTimeout, &PeerLink::HoldingTimeout, this); } void PeerLink::HoldingTimeout () @@ -541,13 +541,13 @@ void PeerLink::HoldingTimeout () void PeerLink::SetRetryTimer () { - NS_ASSERT(m_retryTimeout.GetMicroSeconds() !=0); - m_retryTimer = Simulator::Schedule (m_retryTimeout, &PeerLink::RetryTimeout, this); + NS_ASSERT(m_dot11MeshRetryTimeout.GetMicroSeconds() !=0); + m_retryTimer = Simulator::Schedule (m_dot11MeshRetryTimeout, &PeerLink::RetryTimeout, this); } void PeerLink::RetryTimeout () { - if ( m_retryCounter < m_maxRetries) + if ( m_retryCounter < m_dot11MeshMaxRetries) StateMachine (TOR1); else StateMachine (TOR2); @@ -555,8 +555,8 @@ void PeerLink::RetryTimeout () void PeerLink::SetConfirmTimer () { - NS_ASSERT(m_confirmTimeout.GetMicroSeconds() !=0); - m_confirmTimer = Simulator::Schedule (m_confirmTimeout, &PeerLink::ConfirmTimeout, this); + NS_ASSERT(m_dot11MeshConfirmTimeout.GetMicroSeconds() !=0); + m_confirmTimer = Simulator::Schedule (m_dot11MeshConfirmTimeout, &PeerLink::ConfirmTimeout, this); } void PeerLink::ConfirmTimeout () diff --git a/src/devices/mesh/dot11s/peer-link.h b/src/devices/mesh/dot11s/peer-link.h index ce0645dcc..feddc6e2c 100644 --- a/src/devices/mesh/dot11s/peer-link.h +++ b/src/devices/mesh/dot11s/peer-link.h @@ -231,13 +231,14 @@ private: * \name Timers & counters used for internal state transitions * \{ */ - Time m_retryTimeout; + uint16_t m_dot11MeshMaxRetries; + Time m_dot11MeshRetryTimeout; + Time m_dot11MeshHoldingTimeout; + Time m_dot11MeshConfirmTimeout; + EventId m_retryTimer; - Time m_holdingTimeout; EventId m_holdingTimer; - Time m_confirmTimeout; EventId m_confirmTimer; - uint16_t m_maxRetries; uint16_t m_retryCounter; EventId m_beaconLossTimer; uint16_t m_maxBeaconLoss; diff --git a/src/devices/mesh/dot11s/peer-management-plugin.cc b/src/devices/mesh/dot11s/peer-management-plugin.cc index 3a00dcfe9..bc3cfd4d3 100644 --- a/src/devices/mesh/dot11s/peer-management-plugin.cc +++ b/src/devices/mesh/dot11s/peer-management-plugin.cc @@ -87,7 +87,6 @@ PeerManagerMacPlugin::Receive (Ptr const_packet, const WifiMacHeader & h if(multihopHdr.GetCategory () != WifiMeshMultihopActionHeader::MESH_PEER_LINK_MGT) return true; NS_ASSERT(meshHdr.GetMeshTtl () == 1); - NS_LOG_UNCOND("ext = "<<(uint32_t)meshHdr.GetAddressExt()); NS_ASSERT(meshHdr.GetAddressExt () == 1); NS_ASSERT(meshHdr.GetAddr4 () == header.GetAddr2 ()); @@ -210,7 +209,6 @@ PeerManagerMacPlugin::SendPeerLinkManagementFrame( meshHdr.SetMeshTtl (1); meshHdr.SetMeshSeqno (0); meshHdr.SetAddressExt(1); - NS_LOG_UNCOND("Address ext = "<<(uint32_t)meshHdr.GetAddressExt ()); meshHdr.SetAddr4(m_parent->GetAddress ()); packet->AddHeader (meshHdr); //Wifi Mac header: diff --git a/src/devices/mesh/wscript b/src/devices/mesh/wscript index c722191cc..b91c15d77 100644 --- a/src/devices/mesh/wscript +++ b/src/devices/mesh/wscript @@ -13,7 +13,7 @@ def build(bld): 'mesh-wifi-mac-header.cc', 'tx-statistics.cc', #'hwmp-rtable.cc', - 'dot11s-parameters.cc', + #'dot11s-parameters.cc', #'hwmp.cc', #'mesh-wifi-mac.cc', #'hwmp-state.cc', @@ -33,7 +33,7 @@ def build(bld): # Dirty 'dot11s-codes.h', #'hwmp-state.h', - 'dot11s-parameters.h', + #'dot11s-parameters.h', #'mesh-mgt-headers.h', #'hwmp.h', 'tx-statistics.h',