OLD | NEW |
(Empty) | |
| 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 |
| 30 Dot11sStack::GetTypeId () |
| 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 } |
| 42 Dot11sStack::Dot11sStack () : |
| 43 m_root (Mac48Address ("ff:ff:ff:ff:ff:ff")) |
| 44 { |
| 45 } |
| 46 Dot11sStack::~Dot11sStack () |
| 47 { |
| 48 } |
| 49 void |
| 50 Dot11sStack::DoDispose () |
| 51 { |
| 52 } |
| 53 bool |
| 54 Dot11sStack::InstallStack (Ptr<MeshPointDevice> mp) |
| 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 pmp->SetPeerLinkStatusCallback (MakeCallback (&HwmpProtocol::PeerLinkStatus, h
wmp)); |
| 77 hwmp->SetNeighboursCallback (MakeCallback (&PeerManagementProtocol::GetActiveL
inks, pmp)); |
| 78 return true; |
| 79 } |
| 80 void |
| 81 Dot11sStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os) |
| 82 { |
| 83 mp->Report (os); |
| 84 |
| 85 std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces (); |
| 86 for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != if
aces.end (); ++i) |
| 87 { |
| 88 Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> (); |
| 89 NS_ASSERT (device != 0); |
| 90 Ptr<MeshWifiInterfaceMac> mac = device->GetMac ()->GetObject<MeshWifiInter
faceMac> (); |
| 91 NS_ASSERT (mac != 0); |
| 92 mac->Report (os); |
| 93 } |
| 94 Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> (); |
| 95 NS_ASSERT (hwmp != 0); |
| 96 hwmp->Report (os); |
| 97 |
| 98 Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> (); |
| 99 NS_ASSERT (pmp != 0); |
| 100 pmp->Report (os); |
| 101 } |
| 102 void |
| 103 Dot11sStack::ResetStats (const Ptr<MeshPointDevice> mp) |
| 104 { |
| 105 mp->ResetStats (); |
| 106 |
| 107 std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces (); |
| 108 for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != if
aces.end (); ++i) |
| 109 { |
| 110 Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> (); |
| 111 NS_ASSERT (device != 0); |
| 112 Ptr<MeshWifiInterfaceMac> mac = device->GetMac ()->GetObject<MeshWifiInter
faceMac> (); |
| 113 NS_ASSERT (mac != 0); |
| 114 mac->ResetStats (); |
| 115 } |
| 116 Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> (); |
| 117 NS_ASSERT (hwmp != 0); |
| 118 hwmp->ResetStats (); |
| 119 |
| 120 Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> (); |
| 121 NS_ASSERT (pmp != 0); |
| 122 pmp->ResetStats (); |
| 123 } |
| 124 } //namespace ns3 |
OLD | NEW |