More than one root works
This commit is contained in:
@@ -82,6 +82,7 @@ main (int argc, char *argv[])
|
||||
mesh.SetSpreadInterfaceChannels (chan);
|
||||
std::vector<uint32_t> 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
|
||||
|
||||
@@ -73,7 +73,10 @@ HwmpMacPlugin::Receive (Ptr<Packet> 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);
|
||||
|
||||
@@ -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<bool> ()
|
||||
)
|
||||
.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_address);
|
||||
UniformVariable coefficient (0.0, m_randomStart.GetSeconds());
|
||||
Time randomStart = Seconds (coefficient.GetValue());
|
||||
m_proactivePreqTimer = Simulator::Schedule (randomStart, &HwmpProtocol::SendProactivePreq, this);
|
||||
NS_LOG_UNCOND("ROOT IS: "<<m_address);
|
||||
SendProactivePreq ();
|
||||
m_isRoot = true;
|
||||
}
|
||||
|
||||
@@ -172,11 +172,12 @@ private:
|
||||
//\{
|
||||
std::map<Mac48Address, EventId> m_preqTimeouts;
|
||||
EventId m_proactivePreqTimer;
|
||||
//Random start in Proactive PREQ propagation
|
||||
Time m_randomStart;
|
||||
//\}
|
||||
|
||||
/// Packet Queue
|
||||
std::vector<QueuedPacket> m_rqueue;
|
||||
|
||||
std::vector<QueuedPacket> m_rqueue;
|
||||
private:
|
||||
///\name HWMP-protocol parameters (attributes of GetTypeId)
|
||||
//\{
|
||||
|
||||
@@ -41,26 +41,26 @@ TypeId
|
||||
MeshWifiInterfaceMac::GetTypeId ()
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::MeshWifiInterfaceMac")
|
||||
.SetParent<WifiMac> ()
|
||||
.AddConstructor<MeshWifiInterfaceMac> ()
|
||||
.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<WifiMac> ()
|
||||
.AddConstructor<MeshWifiInterfaceMac> ()
|
||||
.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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user