From f2a313666a4a9dcd130cecfd0efdb855567ed139 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Thu, 16 Apr 2009 14:53:21 +0400 Subject: [PATCH] Fixed proactive mode. 1 root works --- examples/mesh.cc | 12 +++++--- src/devices/mesh/dot11s/dot11s-helper.cc | 15 ++++++---- src/devices/mesh/dot11s/dot11s-helper.h | 6 ++-- src/devices/mesh/dot11s/hwmp-mac-plugin.cc | 8 ++++++ src/devices/mesh/dot11s/hwmp-protocol.cc | 33 +++++++++++----------- src/devices/mesh/dot11s/hwmp-protocol.h | 7 +++-- src/devices/mesh/dot11s/hwmp-rtable.cc | 1 - 7 files changed, 52 insertions(+), 30 deletions(-) diff --git a/examples/mesh.cc b/examples/mesh.cc index 18aa083aa..b959daf53 100644 --- a/examples/mesh.cc +++ b/examples/mesh.cc @@ -49,6 +49,7 @@ main (int argc, char *argv[]) uint32_t nIfaces = 2; bool chan = true; bool pcap = false; + uint64_t seed =1; // Command line arguments CommandLine cmd; @@ -62,10 +63,11 @@ main (int argc, char *argv[]) cmd.AddValue ("interfaces", "Number of radio interfaces used by each mesh point. [1]", nIfaces); cmd.AddValue ("channels", "Use different frequency channels for different interfaces. [0]", chan); cmd.AddValue ("pcap", "Enable PCAP traces on interfaces. [0]", pcap); + cmd.AddValue ("seed", "Seed value", seed); cmd.Parse (argc, argv); NS_LOG_DEBUG ("Grid:" << xSize << "*" << ySize); - SeedManager::SetSeed(1); + SeedManager::SetSeed(seed); // Creating nodes NodeContainer nodes; nodes.Create (ySize*xSize); @@ -78,7 +80,9 @@ main (int argc, char *argv[]) // Install mesh point devices & protocols MeshWifiHelper mesh; mesh.SetSpreadInterfaceChannels (chan); - NetDeviceContainer meshDevices = mesh.Install (wifiPhy, nodes, nIfaces); + std::vector roots; + //roots.push_back(xSize-1); + NetDeviceContainer meshDevices = mesh.Install (wifiPhy, nodes, roots, nIfaces); // Setup mobility MobilityHelper mobility; @@ -104,14 +108,14 @@ main (int argc, char *argv[]) // Install applications UdpEchoServerHelper echoServer (9); ApplicationContainer serverApps = echoServer.Install (nodes.Get (0)); - serverApps.Start (Seconds (0.0)); + serverApps.Start (Seconds (7.0)); serverApps.Stop (Seconds (totalTime)); UdpEchoClientHelper echoClient (interfaces.GetAddress (0), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue ((uint32_t)(totalTime*(1/packetInterval)))); echoClient.SetAttribute ("Interval", TimeValue (Seconds (packetInterval))); echoClient.SetAttribute ("PacketSize", UintegerValue (packetSize)); ApplicationContainer clientApps = echoClient.Install (nodes.Get (xSize*ySize-1)); - clientApps.Start (Seconds (0.0)); + clientApps.Start (Seconds (7.0)); clientApps.Stop (Seconds (totalTime)); // Enable PCAP trace diff --git a/src/devices/mesh/dot11s/dot11s-helper.cc b/src/devices/mesh/dot11s/dot11s-helper.cc index 5eb305167..29994baf2 100644 --- a/src/devices/mesh/dot11s/dot11s-helper.cc +++ b/src/devices/mesh/dot11s/dot11s-helper.cc @@ -91,10 +91,10 @@ MeshWifiHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr node) } NetDeviceContainer -MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c, uint32_t nInterfaces) const +MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c, std::vector roots, uint32_t nInterfaces) const { NetDeviceContainer devices; - + uint32_t node_index = 0; for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) { Ptr node = *i; @@ -140,16 +140,21 @@ MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c, uint32 pmp->SetPeerLinkStatusCallback(MakeCallback(&HwmpProtocol::PeerLinkStatus, hwmp)); hwmp->SetNeighboursCallback(MakeCallback(&PeerManagementProtocol::GetActiveLinks, pmp)); - + // Setting root mesh point + for(std::vector::const_iterator root_iterator = roots.begin (); root_iterator != roots.end (); root_iterator ++) + //if(*root_iterator == i.GetDistanceFrom(c.Begin ())) + if(*root_iterator == node_index) + hwmp->SetRoot (); devices.Add (mp); + node_index ++; } return devices; } NetDeviceContainer -MeshWifiHelper::Install (const WifiPhyHelper &phy, Ptr node, uint32_t nInterfaces) const +MeshWifiHelper::Install (const WifiPhyHelper &phy, Ptr node, std::vector roots, uint32_t nInterfaces) const { - return Install (phy, NodeContainer (node), nInterfaces); + return Install (phy, NodeContainer (node), roots, nInterfaces); } } // namespace dot11s diff --git a/src/devices/mesh/dot11s/dot11s-helper.h b/src/devices/mesh/dot11s/dot11s-helper.h index 819da8b1a..297a42236 100644 --- a/src/devices/mesh/dot11s/dot11s-helper.h +++ b/src/devices/mesh/dot11s/dot11s-helper.h @@ -62,21 +62,23 @@ public: * * \param phy Wifi PHY helper * \param nodes List of nodes to install + * \param roots List of root mesh points * \param nInterfaces Number of mesh point radio interfaces (= WiFi NICs) * * \return list of created mesh point devices, see MeshPointDevice */ - NetDeviceContainer Install (const WifiPhyHelper &phyHelper, NodeContainer c, uint32_t nInterfaces = 1) const; + NetDeviceContainer Install (const WifiPhyHelper &phyHelper, NodeContainer c, std::vector roots = std::vector (), uint32_t nInterfaces = 1) const; /** * \brief Install 802.11s mesh device & protocols on given node * * \param phy Wifi PHY helper * \param node Node to install + * \param roots List of root mesh points * \param nInterfaces Number of mesh point radio interfaces (= WiFi NICs) * * \return list of created mesh point devices, see MeshPointDevice */ - NetDeviceContainer Install (const WifiPhyHelper &phy, Ptr node, uint32_t nInterfaces = 1) const; + NetDeviceContainer Install (const WifiPhyHelper &phy, Ptr node, std::vector roots = std::vector (), uint32_t nInterfaces = 1) const; private: Ssid m_ssid; diff --git a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc index 46cb63a0b..be220eb94 100644 --- a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc +++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc @@ -151,6 +151,12 @@ HwmpMacPlugin::UpdateOutcomingFrame (Ptr packet, WifiMacHeader & header, void HwmpMacPlugin::SendPreq(IePreq preq) { + if(m_myPreq == m_preqQueue.end ()) + { + m_preqQueue.push_back (preq); + m_myPreq = m_preqQueue.end (); + } + else m_preqQueue.push_back (preq); SendOnePreq (); } @@ -223,6 +229,8 @@ HwmpMacPlugin::SendOnePreq () } //erase queue m_preqQueue.erase (m_preqQueue.begin()); + if(m_preqQueue.size () == 0) + m_myPreq = m_preqQueue.end (); } void HwmpMacPlugin::SendOnePerr() diff --git a/src/devices/mesh/dot11s/hwmp-protocol.cc b/src/devices/mesh/dot11s/hwmp-protocol.cc index 9e4a42a4f..2cdfeb776 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc @@ -84,7 +84,7 @@ HwmpProtocol::GetTypeId () ) .AddAttribute ("dot11MeshHWMPpathToRootInterval", "Interval between two successive proactive PREQs", - TimeValue (MicroSeconds (1024*5000)), + TimeValue (MicroSeconds (1024*2000)), MakeTimeAccessor (&HwmpProtocol::m_dot11MeshHWMPpathToRootInterval), MakeTimeChecker () ) @@ -124,12 +124,6 @@ HwmpProtocol::GetTypeId () MakeUintegerAccessor (&HwmpProtocol::m_unicastDataThreshold), MakeUintegerChecker (1) ) - .AddAttribute ("isRoot", - "Root mesh point", - BooleanValue (false), - MakeUintegerAccessor (&HwmpProtocol::m_isRoot), - MakeUintegerChecker () - ) .AddAttribute ("doFlag", "Destination only HWMP flag", BooleanValue (true), @@ -149,7 +143,8 @@ HwmpProtocol::HwmpProtocol (): m_dataSeqno (1), m_hwmpSeqno (1), m_preqId (0), - m_rtable (CreateObject ()) + m_rtable (CreateObject ()), + m_isRoot(false) { } @@ -266,15 +261,12 @@ HwmpProtocol::ForwardUnicast(uint32_t sourceIface, const Mac48Address source, c //2. If there was no reactive path, we lookup expired proactive // path. If exist - start path error procedure towards path to // root - //3. If and only if we are a root station - we queue packet - if((result.retransmitter == Mac48Address::GetBroadcast ()) && (!m_isRoot)) + if(result.retransmitter == Mac48Address::GetBroadcast ()) result = m_rtable->LookupProactiveExpired (); - if((result.retransmitter == Mac48Address::GetBroadcast ()) && (!m_isRoot)) + if(result.retransmitter == Mac48Address::GetBroadcast ()) return false; std::vector destinations = m_rtable->GetUnreachableDestinations (result.retransmitter); MakePathError (destinations); - if(!m_isRoot) - return false; } //Request a destination: result = m_rtable->LookupReactiveExpired (destination); @@ -452,9 +444,15 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, u prep.GetMetric (), MicroSeconds(prep.GetLifetime () * 1024), prep.GetOriginatorSeqNumber ()); - m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter); + if(result.retransmitter != Mac48Address::GetBroadcast ()) + m_rtable->AddPrecursor (prep.GetOriginatorAddress (), interface, result.retransmitter); ReactivePathResolved (prep.GetOriginatorAddress ()); } + if(prep.GetDestinationAddress () == GetAddress ()) + { + NS_LOG_DEBUG("I am "<LookupProactive (); @@ -783,6 +781,7 @@ HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry) void HwmpProtocol::SetRoot () { + NS_LOG_UNCOND("ROOT IS"<second->SendPreq(preq); - m_proactivePreqTimer = Simulator::Schedule (m_dot11MeshHWMPactiveRootTimeout, &HwmpProtocol::SendProactivePreq, this); + m_proactivePreqTimer = Simulator::Schedule (m_dot11MeshHWMPpathToRootInterval, &HwmpProtocol::SendProactivePreq, this); } bool HwmpProtocol::GetDoFlag () diff --git a/src/devices/mesh/dot11s/hwmp-protocol.h b/src/devices/mesh/dot11s/hwmp-protocol.h index c09d1ac94..6e9126aa4 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.h +++ b/src/devices/mesh/dot11s/hwmp-protocol.h @@ -68,6 +68,11 @@ public: //given interface ///\param interface is the interface ID void SetNeighboursCallback(Callback, uint32_t> cb); + ///\name Proactive PREQ mechanism: + ///\{ + void SetRoot (); + void UnsetRoot (); + ///\} private: friend class HwmpMacPlugin; @@ -139,8 +144,6 @@ private: ///\name Proactive Preq routines: //\{ - void SetRoot (); - void UnsetRoot (); void SendProactivePreq (); //\} ///\return address of MeshPointDevice diff --git a/src/devices/mesh/dot11s/hwmp-rtable.cc b/src/devices/mesh/dot11s/hwmp-rtable.cc index 8d410051c..3823d9112 100644 --- a/src/devices/mesh/dot11s/hwmp-rtable.cc +++ b/src/devices/mesh/dot11s/hwmp-rtable.cc @@ -98,7 +98,6 @@ HwmpRtable::AddProactivePath ( uint32_t seqnum ) { - NS_ASSERT(false); m_root.root = root; m_root.retransmitter = retransmitter; m_root.metric = metric;