author | Kirill Andreev <andreev@iitp.ru> |
Fri, 31 Jul 2009 19:38:26 +0400 | |
changeset 5144 | b8a77656a7b8 |
parent 5141 | 22e79c2a4c5f |
child 5164 | b81ab8394a61 |
permissions | -rw-r--r-- |
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
2 |
/* |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
3 |
* Copyright (c) 2008,2009 IITP RAS |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
4 |
* |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
8 |
* |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
13 |
* |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
17 |
* |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
18 |
* Authors: Kirill Andreev <andreev@iitp.ru> |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
19 |
*/ |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
20 |
#include "ns3/mesh-interface-helper.h" |
5061 | 21 |
#include "dot11s-installer.h" |
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
22 |
#include "peer-management-protocol.h" |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
23 |
#include "hwmp-protocol.h" |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
24 |
|
5132
aee541a30256
Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents:
5129
diff
changeset
|
25 |
namespace ns3 { |
5081 | 26 |
using namespace dot11s; |
27 |
NS_OBJECT_ENSURE_REGISTERED (Dot11sStack); |
|
28 |
TypeId |
|
29 |
Dot11sStack::GetTypeId () |
|
30 |
{ |
|
31 |
static TypeId tid = TypeId ("ns3::Dot11sStack") |
|
32 |
.SetParent<Object> () |
|
5141
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
33 |
.AddConstructor<Dot11sStack> () |
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
34 |
.AddAttribute ("Root", |
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
35 |
"The MAC address of root mesh point.", |
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
36 |
Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")), |
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
37 |
MakeMac48AddressAccessor (&Dot11sStack::m_root), |
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
38 |
MakeMac48AddressChecker ()); |
5081 | 39 |
return tid; |
40 |
} |
|
5141
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
41 |
Dot11sStack::Dot11sStack () : |
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
42 |
m_root (Mac48Address ("ff:ff:ff:ff:ff:ff")) |
5129 | 43 |
{ |
44 |
} |
|
5081 | 45 |
Dot11sStack::~Dot11sStack () |
5129 | 46 |
{ |
47 |
} |
|
5081 | 48 |
void |
49 |
Dot11sStack::DoDispose () |
|
50 |
{ |
|
51 |
} |
|
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
52 |
bool |
5081 | 53 |
Dot11sStack::InstallStack (Ptr<MeshPointDevice> mp) |
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
54 |
{ |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
55 |
//Install Peer management protocol: |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
56 |
Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> (); |
5129 | 57 |
pmp->SetMeshId ("mesh"); |
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
58 |
bool install_ok = pmp->Install (mp); |
5124
e206046b2e44
removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents:
5096
diff
changeset
|
59 |
if (!install_ok) |
e206046b2e44
removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents:
5096
diff
changeset
|
60 |
{ |
e206046b2e44
removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents:
5096
diff
changeset
|
61 |
return false; |
e206046b2e44
removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents:
5096
diff
changeset
|
62 |
} |
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
63 |
//Install HWMP: |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
64 |
Ptr<HwmpProtocol> hwmp = CreateObject<HwmpProtocol> (); |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
65 |
install_ok = hwmp->Install (mp); |
5124
e206046b2e44
removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents:
5096
diff
changeset
|
66 |
if (!install_ok) |
e206046b2e44
removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents:
5096
diff
changeset
|
67 |
{ |
e206046b2e44
removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents:
5096
diff
changeset
|
68 |
return false; |
e206046b2e44
removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents:
5096
diff
changeset
|
69 |
} |
5141
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
70 |
if (mp->GetAddress() == m_root) |
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
71 |
{ |
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
72 |
hwmp->SetRoot (); |
22e79c2a4c5f
Added root mesh point as argument of command line
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
73 |
} |
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
74 |
//Install interaction between HWMP and Peer management protocol: |
5129 | 75 |
pmp->SetPeerLinkStatusCallback (MakeCallback (&HwmpProtocol::PeerLinkStatus, hwmp)); |
76 |
hwmp->SetNeighboursCallback (MakeCallback (&PeerManagementProtocol::GetActiveLinks, pmp)); |
|
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
77 |
return true; |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
78 |
} |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
79 |
void |
5081 | 80 |
Dot11sStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os) |
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
81 |
{ |
5096
79c84012dac7
RX/TX/FWD stats in MeshPointDevice
Pavel Boyko <boyko@iitp.ru>
parents:
5081
diff
changeset
|
82 |
mp->Report (os); |
5129 | 83 |
|
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
84 |
std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces (); |
5124
e206046b2e44
removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents:
5096
diff
changeset
|
85 |
for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i) |
5129 | 86 |
{ |
87 |
Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> (); |
|
88 |
NS_ASSERT (device != 0); |
|
89 |
MeshInterfaceHelper::Report (device, os); |
|
90 |
} |
|
91 |
Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> (); |
|
5124
e206046b2e44
removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents:
5096
diff
changeset
|
92 |
NS_ASSERT (hwmp != 0); |
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
93 |
hwmp->Report (os); |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
94 |
|
5129 | 95 |
Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> (); |
5124
e206046b2e44
removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents:
5096
diff
changeset
|
96 |
NS_ASSERT (pmp != 0); |
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
97 |
pmp->Report (os); |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
98 |
} |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
99 |
void |
5081 | 100 |
Dot11sStack::ResetStats (const Ptr<MeshPointDevice> mp) |
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
101 |
{ |
5096
79c84012dac7
RX/TX/FWD stats in MeshPointDevice
Pavel Boyko <boyko@iitp.ru>
parents:
5081
diff
changeset
|
102 |
mp->ResetStats (); |
5129 | 103 |
|
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
104 |
std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces (); |
5124
e206046b2e44
removed GetElementId from *.h files. Fixed spaces before '(' and added {} when needed.
Kirill Andreev <andreev@iitp.ru>
parents:
5096
diff
changeset
|
105 |
for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i) |
5129 | 106 |
{ |
107 |
Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> (); |
|
108 |
NS_ASSERT (device != 0); |
|
109 |
MeshInterfaceHelper::ResetStats (device); |
|
110 |
} |
|
111 |
Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> (); |
|
112 |
NS_ASSERT (hwmp != 0); |
|
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
113 |
hwmp->ResetStats (); |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
114 |
|
5129 | 115 |
Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> (); |
116 |
NS_ASSERT (pmp != 0); |
|
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
117 |
pmp->ResetStats (); |
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
118 |
} |
5081 | 119 |
} //namespace ns3 |