author | Pavel Boyko <boyko@iitp.ru> |
Wed, 01 Apr 2009 18:05:36 +0400 | |
changeset 4929 | 1689c94d7442 |
parent 4919 | b8a0476c7e06 |
child 4930 | fa5e570d56fa |
permissions | -rw-r--r-- |
4793 | 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 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
4793 | 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 |
* |
|
4811
080b8f23fa4a
Added license information to some files.
Andrey Mazo <mazo@iitp.ru>
parents:
4796
diff
changeset
|
18 |
* Author: Kirill Andreev <andreev@iitp.ru> |
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
19 |
* Pavel Boyko <boyko@iitp.ru> |
4793 | 20 |
*/ |
21 |
||
22 |
||
4860
bb5194d57734
New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents:
4858
diff
changeset
|
23 |
#include "dot11s-helper.h" |
bb5194d57734
New peer management protocol moved to 802.11s/
Pavel Boyko <boyko@iitp.ru>
parents:
4858
diff
changeset
|
24 |
|
4855
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
25 |
#include "ns3/mesh-point-device.h" |
4793 | 26 |
#include "ns3/wifi-net-device.h" |
27 |
#include "ns3/wifi-phy.h" |
|
28 |
#include "ns3/wifi-channel.h" |
|
4855
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
29 |
#include "ns3/wifi-remote-station-manager.h" |
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
30 |
#include "ns3/mesh-wifi-interface-mac.h" |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
31 |
#include "ns3/aarf-wifi-manager.h" |
4793 | 32 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4811
diff
changeset
|
33 |
namespace ns3 { |
4872 | 34 |
namespace dot11s { |
4793 | 35 |
|
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
36 |
MeshWifiHelper::MeshWifiHelper () : m_ssid("Mesh"), m_randomStartDelay (Seconds (0)) |
4793 | 37 |
{ |
38 |
} |
|
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
39 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
40 |
void MeshWifiHelper::SetSsid (Ssid const & s) |
4793 | 41 |
{ |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
42 |
m_ssid = s; |
4793 | 43 |
} |
44 |
||
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
45 |
void MeshWifiHelper::SetRandomStartDelay (Time t) |
4793 | 46 |
{ |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
47 |
m_randomStartDelay = t; |
4793 | 48 |
} |
49 |
||
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
50 |
Ptr<WifiNetDevice> MeshWifiHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> node) const |
4793 | 51 |
{ |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
52 |
Ptr<WifiNetDevice> device = CreateObject<WifiNetDevice> (); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
53 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
54 |
// Creating MAC for this interface |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
55 |
Ptr<MeshWifiInterfaceMac> mac = CreateObject<MeshWifiInterfaceMac> (); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
56 |
mac->SetSsid (m_ssid); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
57 |
if (m_randomStartDelay > Seconds (0)) |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
58 |
mac->SetRandomStartDelay (m_randomStartDelay); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
59 |
Ptr<WifiRemoteStationManager> manager = CreateObject<AarfWifiManager> (); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
60 |
Ptr<WifiPhy> phy = phyHelper.Create (node, device); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
61 |
mac->SetAddress (Mac48Address::Allocate ()); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
62 |
device->SetMac (mac); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
63 |
device->SetPhy (phy); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
64 |
device->SetRemoteStationManager (manager); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
65 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
66 |
return device; |
4858
78437693dcc7
Peer manager restructure - unfinished
Kirill Andreev <andreev@iitp.ru>
parents:
4857
diff
changeset
|
67 |
} |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
68 |
|
4855
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
69 |
NetDeviceContainer |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
70 |
MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c, uint32_t nInterfaces) const |
4793 | 71 |
{ |
4855
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
72 |
NetDeviceContainer devices; |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
73 |
|
4855
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
74 |
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) |
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
75 |
{ |
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
76 |
Ptr<Node> node = *i; |
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
77 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
78 |
// Create a mesh point device |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
79 |
Ptr<MeshPointDevice> mp = CreateObject<MeshPointDevice> (); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
80 |
node->AddDevice (mp); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
81 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
82 |
// Create wifi interfaces (single interface by default) |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
83 |
for (uint32_t i = 0; i < nInterfaces; ++i) |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
84 |
{ |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
85 |
Ptr<WifiNetDevice> iface = CreateInterface (phyHelper, node); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
86 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
87 |
node->AddDevice (iface); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
88 |
mp->AddInterface (iface); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
89 |
} |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
90 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
91 |
// Install 802.11s protocols |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
92 |
Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> (); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
93 |
bool pmp_ok = pmp->Install (mp); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
94 |
NS_ASSERT (pmp_ok); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
95 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
96 |
Ptr<HwmpProtocol> hwmp = CreateObject<HwmpProtocol> (); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
97 |
bool hwmp_ok = hwmp->Install (mp); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
98 |
NS_ASSERT (hwmp_ok); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
99 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
100 |
pmp->SetPeerLinkStatusCallback(MakeCallback(&HwmpProtocol::PeerLinkStatus, hwmp)); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
101 |
hwmp->SetNeighboursCallback(MakeCallback(&PeerManagementProtocol::GetActiveLinks, pmp)); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
102 |
|
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
103 |
mp->SetRoutingProtocol (hwmp); |
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
104 |
|
4888
dec245c213ab
Attach interfaces replaced with Install. Helper is simplifyed
Kirill Andreev <andreev@iitp.ru>
parents:
4887
diff
changeset
|
105 |
devices.Add (mp); |
4855
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
106 |
} |
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
107 |
return devices; |
4793 | 108 |
} |
109 |
||
110 |
NetDeviceContainer |
|
4929
1689c94d7442
802.11s helper (ns3::dot11s::MeshWifiHelper) refactored
Pavel Boyko <boyko@iitp.ru>
parents:
4919
diff
changeset
|
111 |
MeshWifiHelper::Install (const WifiPhyHelper &phy, Ptr<Node> node, uint32_t nInterfaces) const |
4815 | 112 |
{ |
4855
0b5980b04249
Restructured helper: switch to new mac, now only beacon functionality works
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
113 |
return Install (phy, NodeContainer (node)); |
4815 | 114 |
} |
4872 | 115 |
|
116 |
} // namespace dot11s |
|
117 |
} //namespace ns3 |
|
4793 | 118 |