A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
dot11s-installer.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008,2009 IITP RAS
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Kirill Andreev <andreev@iitp.ru>
7 */
8#include "dot11s-installer.h"
9
10#include "ns3/hwmp-protocol.h"
11#include "ns3/mesh-wifi-interface-mac.h"
12#include "ns3/peer-management-protocol.h"
13#include "ns3/wifi-net-device.h"
14
15namespace ns3
16{
17using namespace dot11s;
19
20TypeId
22{
23 static TypeId tid = TypeId("ns3::Dot11sStack")
25 .SetGroupName("Mesh")
26 .AddConstructor<Dot11sStack>()
27 .AddAttribute("Root",
28 "The MAC address of root mesh point.",
29 Mac48AddressValue(Mac48Address("ff:ff:ff:ff:ff:ff")),
32 return tid;
33}
34
36 : m_root(Mac48Address("ff:ff:ff:ff:ff:ff"))
37{
38}
39
43
44void
48
49bool
51{
52 // Install Peer management protocol:
54 pmp->SetMeshId("mesh");
55 bool install_ok = pmp->Install(mp);
56 if (!install_ok)
57 {
58 return false;
59 }
60 // Install HWMP:
62 install_ok = hwmp->Install(mp);
63 if (!install_ok)
64 {
65 return false;
66 }
67 if (mp->GetAddress() == m_root)
68 {
69 hwmp->SetRoot();
70 }
71 // Install interaction between HWMP and Peer management protocol:
72 // PeekPointer()'s to avoid circular Ptr references
73 pmp->SetPeerLinkStatusCallback(MakeCallback(&HwmpProtocol::PeerLinkStatus, PeekPointer(hwmp)));
74 hwmp->SetNeighboursCallback(MakeCallback(&PeerManagementProtocol::GetPeers, PeekPointer(pmp)));
75 return true;
76}
77
78void
79Dot11sStack::Report(const Ptr<MeshPointDevice> mp, std::ostream& os)
80{
81 mp->Report(os);
82
83 std::vector<Ptr<NetDevice>> ifaces = mp->GetInterfaces();
84 for (auto i = ifaces.begin(); i != ifaces.end(); ++i)
85 {
86 Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice>();
87 NS_ASSERT(device);
88 Ptr<MeshWifiInterfaceMac> mac = device->GetMac()->GetObject<MeshWifiInterfaceMac>();
89 NS_ASSERT(mac);
90 mac->Report(os);
91 }
92 Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol>();
93 NS_ASSERT(hwmp);
94 hwmp->Report(os);
95
97 NS_ASSERT(pmp);
98 pmp->Report(os);
99}
100
101void
103{
104 mp->ResetStats();
105
106 std::vector<Ptr<NetDevice>> ifaces = mp->GetInterfaces();
107 for (auto i = ifaces.begin(); i != ifaces.end(); ++i)
108 {
109 Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice>();
110 NS_ASSERT(device);
111 Ptr<MeshWifiInterfaceMac> mac = device->GetMac()->GetObject<MeshWifiInterfaceMac>();
112 NS_ASSERT(mac);
113 mac->ResetStats();
114 }
115 Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol>();
116 NS_ASSERT(hwmp);
117 hwmp->ResetStats();
118
120 NS_ASSERT(pmp);
121 pmp->ResetStats();
122}
123} // 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
AttributeValue implementation for Mac48Address.
Prototype for class, which helps to install MAC-layer routing stack to ns3::MeshPointDevice.
Basic MAC of mesh point Wi-Fi interface.
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold together all Wifi-related objects.
Hybrid wireless mesh protocol – a mesh routing protocol defined in IEEE 802.11-2012 standard.
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:55
Ptr< const AttributeAccessor > MakeMac48AddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeMac48AddressChecker()
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
Definition ptr.h:443
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:684