Fixed proactive mode. 1 root works
This commit is contained in:
@@ -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<uint32_t> 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
|
||||
|
||||
@@ -91,10 +91,10 @@ MeshWifiHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> node)
|
||||
}
|
||||
|
||||
NetDeviceContainer
|
||||
MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c, uint32_t nInterfaces) const
|
||||
MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c, std::vector<uint32_t> roots, uint32_t nInterfaces) const
|
||||
{
|
||||
NetDeviceContainer devices;
|
||||
|
||||
uint32_t node_index = 0;
|
||||
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
|
||||
{
|
||||
Ptr<Node> 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<uint32_t>::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> node, uint32_t nInterfaces) const
|
||||
MeshWifiHelper::Install (const WifiPhyHelper &phy, Ptr<Node> node, std::vector<uint32_t> roots, uint32_t nInterfaces) const
|
||||
{
|
||||
return Install (phy, NodeContainer (node), nInterfaces);
|
||||
return Install (phy, NodeContainer (node), roots, nInterfaces);
|
||||
}
|
||||
|
||||
} // namespace dot11s
|
||||
|
||||
@@ -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<uint32_t> roots = std::vector<uint32_t> (), 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> node, uint32_t nInterfaces = 1) const;
|
||||
NetDeviceContainer Install (const WifiPhyHelper &phy, Ptr<Node> node, std::vector<uint32_t> roots = std::vector<uint32_t> (), uint32_t nInterfaces = 1) const;
|
||||
|
||||
private:
|
||||
Ssid m_ssid;
|
||||
|
||||
@@ -151,6 +151,12 @@ HwmpMacPlugin::UpdateOutcomingFrame (Ptr<Packet> 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()
|
||||
|
||||
@@ -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<uint8_t> (1)
|
||||
)
|
||||
.AddAttribute ("isRoot",
|
||||
"Root mesh point",
|
||||
BooleanValue (false),
|
||||
MakeUintegerAccessor (&HwmpProtocol::m_isRoot),
|
||||
MakeUintegerChecker<bool> ()
|
||||
)
|
||||
.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<HwmpRtable> ())
|
||||
m_rtable (CreateObject<HwmpRtable> ()),
|
||||
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<IePerr::FailedDestination> 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 "<<GetAddress ()<<", resolved "<<prep.GetOriginatorAddress ());
|
||||
return;
|
||||
}
|
||||
if (result.retransmitter == Mac48Address::GetBroadcast ())
|
||||
//try to look for default route
|
||||
result = m_rtable->LookupProactive ();
|
||||
@@ -783,6 +781,7 @@ HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry)
|
||||
void
|
||||
HwmpProtocol::SetRoot ()
|
||||
{
|
||||
NS_LOG_UNCOND("ROOT IS"<<m_address);
|
||||
SendProactivePreq ();
|
||||
m_isRoot = true;
|
||||
}
|
||||
@@ -800,14 +799,16 @@ HwmpProtocol::SendProactivePreq ()
|
||||
preq.SetTTL (m_maxTtl);
|
||||
if (m_preqId == 0xffffffff)
|
||||
m_preqId = 0;
|
||||
preq.SetLifetime (m_dot11MeshHWMPpathToRootInterval.GetMicroSeconds () /1024);
|
||||
preq.SetLifetime (m_dot11MeshHWMPactiveRootTimeout.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);
|
||||
preq.SetOriginatorAddress(GetAddress ());
|
||||
preq.SetPreqID (GetNextPreqId ());
|
||||
preq.SetOriginatorSeqNumber (GetNextHwmpSeqno ());
|
||||
for(HwmpPluginMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i ++)
|
||||
i->second->SendPreq(preq);
|
||||
m_proactivePreqTimer = Simulator::Schedule (m_dot11MeshHWMPactiveRootTimeout, &HwmpProtocol::SendProactivePreq, this);
|
||||
m_proactivePreqTimer = Simulator::Schedule (m_dot11MeshHWMPpathToRootInterval, &HwmpProtocol::SendProactivePreq, this);
|
||||
}
|
||||
bool
|
||||
HwmpProtocol::GetDoFlag ()
|
||||
|
||||
@@ -68,6 +68,11 @@ public:
|
||||
//given interface
|
||||
///\param interface is the interface ID
|
||||
void SetNeighboursCallback(Callback<std::vector<Mac48Address>, 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
|
||||
|
||||
@@ -98,7 +98,6 @@ HwmpRtable::AddProactivePath (
|
||||
uint32_t seqnum
|
||||
)
|
||||
{
|
||||
NS_ASSERT(false);
|
||||
m_root.root = root;
|
||||
m_root.retransmitter = retransmitter;
|
||||
m_root.metric = metric;
|
||||
|
||||
Reference in New Issue
Block a user