A Discrete-Event Network Simulator
QKDNetSim v2.0 (NS-3 v3.41) @ (+)
API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
dot11s-installer.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008,2009 IITP RAS
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Authors: Kirill Andreev <andreev@iitp.ru>
18  */
19 #include "dot11s-installer.h"
20 
21 #include "ns3/hwmp-protocol.h"
22 #include "ns3/mesh-wifi-interface-mac.h"
23 #include "ns3/peer-management-protocol.h"
24 #include "ns3/wifi-net-device.h"
25 
26 namespace ns3
27 {
28 using namespace dot11s;
29 NS_OBJECT_ENSURE_REGISTERED(Dot11sStack);
30 
31 TypeId
33 {
34  static TypeId tid = TypeId("ns3::Dot11sStack")
36  .SetGroupName("Mesh")
37  .AddConstructor<Dot11sStack>()
38  .AddAttribute("Root",
39  "The MAC address of root mesh point.",
40  Mac48AddressValue(Mac48Address("ff:ff:ff:ff:ff:ff")),
41  MakeMac48AddressAccessor(&Dot11sStack::m_root),
42  MakeMac48AddressChecker());
43  return tid;
44 }
45 
47  : m_root(Mac48Address("ff:ff:ff:ff:ff:ff"))
48 {
49 }
50 
52 {
53 }
54 
55 void
57 {
58 }
59 
60 bool
62 {
63  // Install Peer management protocol:
64  Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol>();
65  pmp->SetMeshId("mesh");
66  bool install_ok = pmp->Install(mp);
67  if (!install_ok)
68  {
69  return false;
70  }
71  // Install HWMP:
72  Ptr<HwmpProtocol> hwmp = CreateObject<HwmpProtocol>();
73  install_ok = hwmp->Install(mp);
74  if (!install_ok)
75  {
76  return false;
77  }
78  if (mp->GetAddress() == m_root)
79  {
80  hwmp->SetRoot();
81  }
82  // Install interaction between HWMP and Peer management protocol:
83  // PeekPointer()'s to avoid circular Ptr references
84  pmp->SetPeerLinkStatusCallback(MakeCallback(&HwmpProtocol::PeerLinkStatus, PeekPointer(hwmp)));
85  hwmp->SetNeighboursCallback(MakeCallback(&PeerManagementProtocol::GetPeers, PeekPointer(pmp)));
86  return true;
87 }
88 
89 void
90 Dot11sStack::Report(const Ptr<MeshPointDevice> mp, std::ostream& os)
91 {
92  mp->Report(os);
93 
94  std::vector<Ptr<NetDevice>> ifaces = mp->GetInterfaces();
95  for (auto i = ifaces.begin(); i != ifaces.end(); ++i)
96  {
97  Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice>();
98  NS_ASSERT(device);
100  NS_ASSERT(mac);
101  mac->Report(os);
102  }
103  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol>();
104  NS_ASSERT(hwmp);
105  hwmp->Report(os);
106 
108  NS_ASSERT(pmp);
109  pmp->Report(os);
110 }
111 
112 void
114 {
115  mp->ResetStats();
116 
117  std::vector<Ptr<NetDevice>> ifaces = mp->GetInterfaces();
118  for (auto i = ifaces.begin(); i != ifaces.end(); ++i)
119  {
120  Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice>();
121  NS_ASSERT(device);
123  NS_ASSERT(mac);
124  mac->ResetStats();
125  }
126  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol>();
127  NS_ASSERT(hwmp);
128  hwmp->ResetStats();
129 
131  NS_ASSERT(pmp);
132  pmp->ResetStats();
133 }
134 } // namespace ns3
Helper class to allow easy installation of 802.11s stack.
static TypeId GetTypeId()
Get the type ID.
~Dot11sStack() override
Destroy a Dot11sStack() installer helper.
void DoDispose() override
Break any reference cycles in the installer helper.
void Report(const Ptr< MeshPointDevice > mp, std::ostream &) override
Iterate through the referenced devices and protocols and print their statistics.
void ResetStats(const Ptr< MeshPointDevice > mp) override
Reset the statistics on the referenced devices and protocols.
bool InstallStack(Ptr< MeshPointDevice > mp) override
Install an 802.11s stack.
Dot11sStack()
Create a Dot11sStack() installer helper.
Mac48Address m_root
root
an EUI-48 address
Definition: mac48-address.h:46
Prototype for class, which helps to install MAC-layer routing stack to ns3::MeshPointDevice.
Basic MAC of mesh point Wi-Fi interface.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
Hold together all Wifi-related objects.
Ptr< WifiMac > GetMac() const
Hybrid wireless mesh protocol – a mesh routing protocol defined in IEEE 802.11-2012 standard.
Definition: hwmp-protocol.h:68
void PeerLinkStatus(Mac48Address meshPointAddress, Mac48Address peerAddress, uint32_t interface, bool status)
Peer link status function.
802.11s Peer Management Protocol model
std::vector< Mac48Address > GetPeers(uint32_t interface) const
Get list of active peers of my given interface.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:704
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:449
mac
Definition: third.py:92