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 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
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  }
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  }
118  NS_ASSERT (hwmp != 0);
119  hwmp->ResetStats ();
120 
122  NS_ASSERT (pmp != 0);
123  pmp->ResetStats ();
124 }
125 } // namespace ns3