A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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<Object> ()
35  .AddConstructor<Dot11sStack> ()
36  .AddAttribute ("Root",
37  "The MAC address of root mesh point.",
38  Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
39  MakeMac48AddressAccessor (&Dot11sStack::m_root),
40  MakeMac48AddressChecker ());
41  return tid;
42 }
44  m_root (Mac48Address ("ff:ff:ff:ff:ff:ff"))
45 {
46 }
48 {
49 }
50 void
52 {
53 }
54 bool
56 {
57  //Install Peer management protocol:
58  Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> ();
59  pmp->SetMeshId ("mesh");
60  bool install_ok = pmp->Install (mp);
61  if (!install_ok)
62  {
63  return false;
64  }
65  //Install HWMP:
66  Ptr<HwmpProtocol> hwmp = CreateObject<HwmpProtocol> ();
67  install_ok = hwmp->Install (mp);
68  if (!install_ok)
69  {
70  return false;
71  }
72  if (mp->GetAddress () == m_root)
73  {
74  hwmp->SetRoot ();
75  }
76  //Install interaction between HWMP and Peer management protocol:
77  //PeekPointer()'s to avoid circular Ptr references
78  pmp->SetPeerLinkStatusCallback (MakeCallback (&HwmpProtocol::PeerLinkStatus, PeekPointer (hwmp)));
79  hwmp->SetNeighboursCallback (MakeCallback (&PeerManagementProtocol::GetPeers, PeekPointer (pmp)));
80  return true;
81 }
82 void
83 Dot11sStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os)
84 {
85  mp->Report (os);
86 
87  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
88  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
89  {
90  Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
91  NS_ASSERT (device != 0);
92  Ptr<MeshWifiInterfaceMac> mac = device->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
93  NS_ASSERT (mac != 0);
94  mac->Report (os);
95  }
96  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
97  NS_ASSERT (hwmp != 0);
98  hwmp->Report (os);
99 
100  Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
101  NS_ASSERT (pmp != 0);
102  pmp->Report (os);
103 }
104 void
106 {
107  mp->ResetStats ();
108 
109  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
110  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
111  {
112  Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
113  NS_ASSERT (device != 0);
114  Ptr<MeshWifiInterfaceMac> mac = device->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
115  NS_ASSERT (mac != 0);
116  mac->ResetStats ();
117  }
118  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
119  NS_ASSERT (hwmp != 0);
120  hwmp->ResetStats ();
121 
122  Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
123  NS_ASSERT (pmp != 0);
124  pmp->ResetStats ();
125 }
126 } // namespace ns3
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
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:61
~Dot11sStack()
Destroy a Dot11sStack() installer helper.
std::vector< Mac48Address > GetPeers(uint32_t interface) const
Get list of active peers of my given interface.
Hybrid wireless mesh protocol – a routing protocol of IEEE 802.11s draft.
Definition: hwmp-protocol.h:47
void Report(const Ptr< MeshPointDevice > mp, std::ostream &)
Iterate through the referenced devices and protocols and print their statistics.
T * PeekPointer(const Ptr< T > &p)
Definition: ptr.h:280
Hold together all Wifi-related objects.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1242
Dot11sStack()
Create a Dot11sStack() installer helper.
Mac48Address m_root
an EUI-48 address
Definition: mac48-address.h:41
hold objects of type ns3::Mac48Address
static TypeId GetTypeId()
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.
a base class which provides memory management and object aggregation
Definition: object.h:64
void PeerLinkStatus(Mac48Address meshPontAddress, Mac48Address peerAddress, uint32_t interface, bool status)
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
Basic MAC of mesh point Wi-Fi interface.
802.11s Peer Management Protocol model