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