A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dot11s-installer.cc
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 TypeId
31 {
32  static TypeId tid = TypeId ("ns3::Dot11sStack")
33  .SetParent<Object> ()
34  .AddConstructor<Dot11sStack> ()
35  .AddAttribute ("Root",
36  "The MAC address of root mesh point.",
37  Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
38  MakeMac48AddressAccessor (&Dot11sStack::m_root),
39  MakeMac48AddressChecker ());
40  return tid;
41 }
43  m_root (Mac48Address ("ff:ff:ff:ff:ff:ff"))
44 {
45 }
47 {
48 }
49 void
51 {
52 }
53 bool
55 {
56  //Install Peer management protocol:
57  Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> ();
58  pmp->SetMeshId ("mesh");
59  bool install_ok = pmp->Install (mp);
60  if (!install_ok)
61  {
62  return false;
63  }
64  //Install HWMP:
65  Ptr<HwmpProtocol> hwmp = CreateObject<HwmpProtocol> ();
66  install_ok = hwmp->Install (mp);
67  if (!install_ok)
68  {
69  return false;
70  }
71  if (mp->GetAddress () == m_root)
72  {
73  hwmp->SetRoot ();
74  }
75  //Install interaction between HWMP and Peer management protocol:
76  //PeekPointer()'s to avoid circular Ptr references
77  pmp->SetPeerLinkStatusCallback (MakeCallback (&HwmpProtocol::PeerLinkStatus, PeekPointer (hwmp)));
78  hwmp->SetNeighboursCallback (MakeCallback (&PeerManagementProtocol::GetPeers, PeekPointer (pmp)));
79  return true;
80 }
81 void
82 Dot11sStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os)
83 {
84  mp->Report (os);
85 
86  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
87  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
88  {
89  Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
90  NS_ASSERT (device != 0);
91  Ptr<MeshWifiInterfaceMac> mac = device->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
92  NS_ASSERT (mac != 0);
93  mac->Report (os);
94  }
95  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
96  NS_ASSERT (hwmp != 0);
97  hwmp->Report (os);
98 
100  NS_ASSERT (pmp != 0);
101  pmp->Report (os);
102 }
103 void
105 {
106  mp->ResetStats ();
107 
108  std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
109  for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i)
110  {
111  Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> ();
112  NS_ASSERT (device != 0);
113  Ptr<MeshWifiInterfaceMac> mac = device->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
114  NS_ASSERT (mac != 0);
115  mac->ResetStats ();
116  }
117  Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> ();
118  NS_ASSERT (hwmp != 0);
119  hwmp->ResetStats ();
120 
121  Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> ();
122  NS_ASSERT (pmp != 0);
123  pmp->ResetStats ();
124 }
125 } // namespace ns3
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
#define NS_ASSERT(condition)
Definition: assert.h:64
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.
Hold together all Wifi-related objects.This class holds together ns3::WifiChannel, ns3::WifiPhy, ns3::WifiMac, and, ns3::WifiRemoteStationManager.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:502
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:63
a unique identifier for an interface.
Definition: type-id.h:44
TypeId SetParent(TypeId tid)
Definition: type-id.cc:471
Basic MAC of mesh point Wi-Fi interface. Its function is extendable through plugins mechanism...
802.11s Peer Management Protocol model