From 9d109ef6016d27eb54a223648c4b10407012cfbf Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Thu, 16 Apr 2009 15:21:09 +0400 Subject: [PATCH] More than one root works --- examples/mesh.cc | 5 +-- src/devices/mesh/dot11s/hwmp-mac-plugin.cc | 3 ++ src/devices/mesh/dot11s/hwmp-protocol.cc | 34 ++++++++++++------ src/devices/mesh/dot11s/hwmp-protocol.h | 5 +-- src/devices/mesh/mesh-wifi-interface-mac.cc | 40 ++++++++++----------- 5 files changed, 53 insertions(+), 34 deletions(-) diff --git a/examples/mesh.cc b/examples/mesh.cc index b959daf53..432dd07d6 100644 --- a/examples/mesh.cc +++ b/examples/mesh.cc @@ -82,6 +82,7 @@ main (int argc, char *argv[]) mesh.SetSpreadInterfaceChannels (chan); std::vector roots; //roots.push_back(xSize-1); + //roots.push_back(xSize*ySize-xSize); NetDeviceContainer meshDevices = mesh.Install (wifiPhy, nodes, roots, nIfaces); // Setup mobility @@ -108,14 +109,14 @@ main (int argc, char *argv[]) // Install applications UdpEchoServerHelper echoServer (9); ApplicationContainer serverApps = echoServer.Install (nodes.Get (0)); - serverApps.Start (Seconds (7.0)); + serverApps.Start (Seconds (0.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 (7.0)); + clientApps.Start (Seconds (0.0)); clientApps.Stop (Seconds (totalTime)); // Enable PCAP trace diff --git a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc index be220eb94..d7b56f438 100644 --- a/src/devices/mesh/dot11s/hwmp-mac-plugin.cc +++ b/src/devices/mesh/dot11s/hwmp-mac-plugin.cc @@ -73,7 +73,10 @@ HwmpMacPlugin::Receive (Ptr packet, const WifiMacHeader & header) }; tag.SetSeqno (meshHdr.GetMeshSeqno ()); if(meshHdr.GetMeshTtl () == 0) + { + NS_ASSERT(false); return false; + } tag.SetTtl (meshHdr.GetMeshTtl () - 1); if(m_protocol->GetAddress() != destination) packet->AddPacketTag(tag); diff --git a/src/devices/mesh/dot11s/hwmp-protocol.cc b/src/devices/mesh/dot11s/hwmp-protocol.cc index 2cdfeb776..2a51be1e9 100644 --- a/src/devices/mesh/dot11s/hwmp-protocol.cc +++ b/src/devices/mesh/dot11s/hwmp-protocol.cc @@ -30,6 +30,7 @@ #include "ns3/wifi-net-device.h" #include "ns3/mesh-point-device.h" #include "ns3/mesh-wifi-interface-mac.h" +#include "ns3/random-variable.h" #include "ie-dot11s-preq.h" #include "ie-dot11s-prep.h" #include "ie-dot11s-perr.h" @@ -135,8 +136,12 @@ HwmpProtocol::GetTypeId () BooleanValue (false), MakeUintegerAccessor (&HwmpProtocol::m_rfFlag), MakeUintegerChecker () + ) + .AddAttribute ("RandomStart", "Random delay at first proactive PREQ", + TimeValue (Seconds (0.1)), + MakeTimeAccessor (&HwmpProtocol::m_randomStart), + MakeTimeChecker () ); - return tid; } HwmpProtocol::HwmpProtocol (): @@ -326,14 +331,20 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, u //per destination flags DO and RF NS_ASSERT (preq.GetDestCount() == 1); NS_ASSERT (((*i)->IsDo()) && ((*i)->IsRf())); - m_rtable->AddProactivePath ( - preq.GetMetric (), - preq.GetOriginatorAddress (), - from, - interface, - MicroSeconds (preq.GetLifetime () * 1024), - preq.GetOriginatorSeqNumber () - ); + //Add proactive path only if it is the better then existed + //before + if( + ((m_rtable->LookupProactive ()).retransmitter == Mac48Address::GetBroadcast ()) || + ((m_rtable->LookupProactive ()).metric > preq.GetMetric ()) + ) + m_rtable->AddProactivePath ( + preq.GetMetric (), + preq.GetOriginatorAddress (), + from, + interface, + MicroSeconds (preq.GetLifetime () * 1024), + preq.GetOriginatorSeqNumber () + ); ProactivePathResolved (); if (!preq.IsNeedNotPrep ()) SendPrep ( @@ -781,7 +792,10 @@ HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry) void HwmpProtocol::SetRoot () { - NS_LOG_UNCOND("ROOT IS"< m_preqTimeouts; EventId m_proactivePreqTimer; + //Random start in Proactive PREQ propagation + Time m_randomStart; //\} /// Packet Queue - std::vector m_rqueue; - + std::vector m_rqueue; private: ///\name HWMP-protocol parameters (attributes of GetTypeId) //\{ diff --git a/src/devices/mesh/mesh-wifi-interface-mac.cc b/src/devices/mesh/mesh-wifi-interface-mac.cc index f2c7754bb..e33fe4ffb 100644 --- a/src/devices/mesh/mesh-wifi-interface-mac.cc +++ b/src/devices/mesh/mesh-wifi-interface-mac.cc @@ -41,26 +41,26 @@ TypeId MeshWifiInterfaceMac::GetTypeId () { static TypeId tid = TypeId ("ns3::MeshWifiInterfaceMac") - .SetParent () - .AddConstructor () - .AddAttribute ("BeaconInterval", "Beacon Interval", - TimeValue (Seconds (1.0)), - MakeTimeAccessor (&MeshWifiInterfaceMac::m_beaconInterval), - MakeTimeChecker () - ) - .AddAttribute ("RandomStart", "Window when beacon generating starts (uniform random) in seconds", - TimeValue (Seconds (0.1)), - MakeTimeAccessor (&MeshWifiInterfaceMac::m_randomStart), - MakeTimeChecker () - ) - .AddAttribute ("BeaconGeneration", "Enable/Disable Beaconing.", - BooleanValue (true), - MakeBooleanAccessor ( - &MeshWifiInterfaceMac::SetBeaconGeneration, - &MeshWifiInterfaceMac::GetBeaconGeneration - ), - MakeBooleanChecker () - ); + .SetParent () + .AddConstructor () + .AddAttribute ("BeaconInterval", "Beacon Interval", + TimeValue (Seconds (1.0)), + MakeTimeAccessor (&MeshWifiInterfaceMac::m_beaconInterval), + MakeTimeChecker () + ) + .AddAttribute ("RandomStart", "Window when beacon generating starts (uniform random) in seconds", + TimeValue (Seconds (0.1)), + MakeTimeAccessor (&MeshWifiInterfaceMac::m_randomStart), + MakeTimeChecker () + ) + .AddAttribute ("BeaconGeneration", "Enable/Disable Beaconing.", + BooleanValue (true), + MakeBooleanAccessor ( + &MeshWifiInterfaceMac::SetBeaconGeneration, + &MeshWifiInterfaceMac::GetBeaconGeneration + ), + MakeBooleanChecker () + ); return tid; }