From 99aa60cd0a54fa1355b221e3f474037578151cb3 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Fri, 31 Jul 2009 17:52:18 +0400 Subject: [PATCH] Added root mesh point as argument of command line --- examples/mesh.cc | 7 +++++-- src/devices/mesh/dot11s/dot11s-installer.cc | 22 ++++++++++++--------- src/devices/mesh/dot11s/dot11s-installer.h | 3 ++- src/helper/mesh-helper.cc | 19 +++++++++++++++++- src/helper/mesh-helper.h | 10 +++++++++- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/examples/mesh.cc b/examples/mesh.cc index 55d46b494..ebb7c2fd7 100644 --- a/examples/mesh.cc +++ b/examples/mesh.cc @@ -59,6 +59,7 @@ class MeshTest bool pcap; uint64_t seed; std::string stack; + std::string root; /// List of network nodes NodeContainer nodes; /// List of all mesh point devices @@ -89,7 +90,8 @@ MeshTest::MeshTest () : chan (true), pcap (false), seed (1), - stack ("ns3::Dot11sStack") + stack ("ns3::Dot11sStack"), + root ("ff:ff:ff:ff:ff:ff") { } void @@ -108,6 +110,7 @@ MeshTest::Configure (int argc, char *argv[]) cmd.AddValue ("pcap", "Enable PCAP traces on interfaces. [0]", pcap); cmd.AddValue ("seed", "Seed value", seed); cmd.AddValue ("stack", "Type of protocol stack. ns3::Dot11sStack by default", stack); + cmd.AddValue ("root", "Mac address of root mesh point", root); cmd.Parse (argc, argv); NS_LOG_DEBUG ("Grid:" << xSize << "*" << ySize); @@ -123,7 +126,7 @@ MeshTest::CreateNodes () YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); // Install mesh point devices & protocols - mesh.SetStackInstaller (stack); + mesh.SetStackInstaller (stack, "Root", Mac48AddressValue (Mac48Address (root.c_str ()))); mesh.SetSpreadInterfaceChannels (chan); MeshInterfaceHelper interface = MeshInterfaceHelper::Default (); interface.SetType ("RandomStart", TimeValue (Seconds(randomStart))); diff --git a/src/devices/mesh/dot11s/dot11s-installer.cc b/src/devices/mesh/dot11s/dot11s-installer.cc index 7a50ff378..26d68b6d1 100644 --- a/src/devices/mesh/dot11s/dot11s-installer.cc +++ b/src/devices/mesh/dot11s/dot11s-installer.cc @@ -30,10 +30,16 @@ Dot11sStack::GetTypeId () { static TypeId tid = TypeId ("ns3::Dot11sStack") .SetParent () - .AddConstructor (); + .AddConstructor () + .AddAttribute ("Root", + "The MAC address of root mesh point.", + Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")), + MakeMac48AddressAccessor (&Dot11sStack::m_root), + MakeMac48AddressChecker ()); return tid; } -Dot11sStack::Dot11sStack () +Dot11sStack::Dot11sStack () : + m_root (Mac48Address ("ff:ff:ff:ff:ff:ff")) { } Dot11sStack::~Dot11sStack () @@ -43,13 +49,6 @@ void Dot11sStack::DoDispose () { } -void -Dot11sStack::SetRoot (Ptr mp) -{ - Ptr hwmp = mp->GetObject (); - NS_ASSERT (hwmp != 0); - hwmp->SetRoot (); -} bool Dot11sStack::InstallStack (Ptr mp) { @@ -68,6 +67,11 @@ Dot11sStack::InstallStack (Ptr mp) { return false; } + NS_LOG_UNCOND(m_root); + if (mp->GetAddress() == m_root) + { + hwmp->SetRoot (); + } //Install interaction between HWMP and Peer management protocol: pmp->SetPeerLinkStatusCallback (MakeCallback (&HwmpProtocol::PeerLinkStatus, hwmp)); hwmp->SetNeighboursCallback (MakeCallback (&PeerManagementProtocol::GetActiveLinks, pmp)); diff --git a/src/devices/mesh/dot11s/dot11s-installer.h b/src/devices/mesh/dot11s/dot11s-installer.h index 521b0c825..e2139e09b 100644 --- a/src/devices/mesh/dot11s/dot11s-installer.h +++ b/src/devices/mesh/dot11s/dot11s-installer.h @@ -33,9 +33,10 @@ class Dot11sStack : public MeshStack ///\brief Installs 802.11s stack. needed by helper only bool InstallStack (Ptr mp); - void SetRoot (Ptr mp); void Report (const Ptr mp, std::ostream&); void ResetStats (const Ptr mp); + private: + Mac48Address m_root; }; } //namespace ns3 #endif diff --git a/src/helper/mesh-helper.cc b/src/helper/mesh-helper.cc index caf858b9e..e81ecdb50 100644 --- a/src/helper/mesh-helper.cc +++ b/src/helper/mesh-helper.cc @@ -36,10 +36,27 @@ MeshHelper::SetSpreadInterfaceChannels (bool s) m_spreadInterfaceChannels = s; } void -MeshHelper::SetStackInstaller (std::string type) +MeshHelper::SetStackInstaller (std::string type, + std::string n0, const AttributeValue &v0, + std::string n1, const AttributeValue &v1, + std::string n2, const AttributeValue &v2, + std::string n3, const AttributeValue &v3, + std::string n4, const AttributeValue &v4, + std::string n5, const AttributeValue &v5, + std::string n6, const AttributeValue &v6, + std::string n7, const AttributeValue &v7) { NS_LOG_FUNCTION (this << type); m_stackFactory.SetTypeId (type); + m_stackFactory.Set (n0, v0); + m_stackFactory.Set (n1, v1); + m_stackFactory.Set (n2, v2); + m_stackFactory.Set (n3, v3); + m_stackFactory.Set (n4, v4); + m_stackFactory.Set (n5, v5); + m_stackFactory.Set (n6, v6); + m_stackFactory.Set (n7, v7); + m_stack = m_stackFactory.Create (); if (m_stack == 0) { diff --git a/src/helper/mesh-helper.h b/src/helper/mesh-helper.h index f77c73d56..7b33d61ee 100644 --- a/src/helper/mesh-helper.h +++ b/src/helper/mesh-helper.h @@ -77,7 +77,15 @@ public: * All the attributes specified in this method should exist * in the requested station manager. */ - void SetStackInstaller (std::string type); + void SetStackInstaller (std::string type, + std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), + std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), + std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), + std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), + std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), + std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), + std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), + std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); void Report (const ns3::Ptr&, std::ostream&); void ResetStats (const ns3::Ptr&); private: