author | Kirill Andreev <andreev@iitp.ru> |
Thu, 18 Jun 2009 16:50:52 +0400 | |
changeset 5084 | ddf23699f0b7 |
parent 5083 | 5b154b30a8a1 |
child 5091 | 15b8fe26aa0d |
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:
4809
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 |
* |
|
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 |
||
23 |
#include "ns3/node.h" |
|
24 |
#include "ns3/packet.h" |
|
25 |
#include "ns3/log.h" |
|
4967
ba4b79124d30
Fix after update from ns-3-dev: substitute removed NetDevice::GetName() method.
Andrey Mazo <mazo@iitp.ru>
parents:
4953
diff
changeset
|
26 |
#include "ns3/pointer.h" |
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
27 |
#include "ns3/mesh-point-device.h" |
4985
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
28 |
#include "ns3/wifi-net-device.h" |
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
29 |
#include "ns3/mesh-wifi-interface-mac.h" |
4793 | 30 |
|
4815 | 31 |
NS_LOG_COMPONENT_DEFINE ("MeshPointDevice"); |
4793 | 32 |
|
33 |
namespace ns3 { |
|
34 |
||
4815 | 35 |
NS_OBJECT_ENSURE_REGISTERED (MeshPointDevice); |
4793 | 36 |
|
37 |
TypeId |
|
4815 | 38 |
MeshPointDevice::GetTypeId () |
4793 | 39 |
{ |
4815 | 40 |
static TypeId tid = TypeId ("ns3::MeshPointDevice") |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
41 |
.SetParent<NetDevice> () |
4815 | 42 |
.AddConstructor<MeshPointDevice> () |
4928
825037c2d7ab
Make routing protocol attribute of mesh point to be accessable by Config::
Pavel Boyko <boyko@iitp.ru>
parents:
4906
diff
changeset
|
43 |
.AddAttribute ("RoutingProtocol", "The mesh routing protocol used by this mesh point.", |
825037c2d7ab
Make routing protocol attribute of mesh point to be accessable by Config::
Pavel Boyko <boyko@iitp.ru>
parents:
4906
diff
changeset
|
44 |
PointerValue (), |
825037c2d7ab
Make routing protocol attribute of mesh point to be accessable by Config::
Pavel Boyko <boyko@iitp.ru>
parents:
4906
diff
changeset
|
45 |
MakePointerAccessor (&MeshPointDevice::GetRoutingProtocol, |
825037c2d7ab
Make routing protocol attribute of mesh point to be accessable by Config::
Pavel Boyko <boyko@iitp.ru>
parents:
4906
diff
changeset
|
46 |
&MeshPointDevice::SetRoutingProtocol), |
825037c2d7ab
Make routing protocol attribute of mesh point to be accessable by Config::
Pavel Boyko <boyko@iitp.ru>
parents:
4906
diff
changeset
|
47 |
MakePointerChecker<MeshL2RoutingProtocol> ()) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
48 |
; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
49 |
return tid; |
4793 | 50 |
} |
51 |
||
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
52 |
MeshPointDevice::MeshPointDevice () : m_ifIndex (0), m_mtu(1500) |
4793 | 53 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
54 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
55 |
m_channel = CreateObject<BridgeChannel> (); |
4793 | 56 |
} |
57 |
||
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
58 |
MeshPointDevice::~MeshPointDevice () |
4793 | 59 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
60 |
NS_LOG_FUNCTION_NOARGS (); |
4793 | 61 |
} |
62 |
||
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
63 |
void |
4815 | 64 |
MeshPointDevice::DoDispose () |
4793 | 65 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
66 |
NS_LOG_FUNCTION_NOARGS (); |
4815 | 67 |
for (std::vector< Ptr<NetDevice> >::iterator iter = m_ifaces.begin (); iter != m_ifaces.end (); iter++) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
68 |
*iter = 0; |
4815 | 69 |
m_ifaces.clear (); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
70 |
m_node = 0; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
71 |
NetDevice::DoDispose (); |
4793 | 72 |
|
73 |
} |
|
74 |
||
4815 | 75 |
//----------------------------------------------------------------------------- |
76 |
// NetDevice interface implementation |
|
77 |
//----------------------------------------------------------------------------- |
|
78 |
||
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
79 |
void |
4815 | 80 |
MeshPointDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol, |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
81 |
Address const &src, Address const &dst, PacketType packetType) |
4793 | 82 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
83 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
84 |
NS_LOG_DEBUG ("UID is " << packet->GetUid ()); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
85 |
const Mac48Address src48 = Mac48Address::ConvertFrom (src); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
86 |
const Mac48Address dst48 = Mac48Address::ConvertFrom (dst); |
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
87 |
uint16_t& realProtocol = protocol; |
4953
0226369989a3
Added {} in 'if' where ASSERT exists
Kirill Andreev <andreev@iitp.ru>
parents:
4947
diff
changeset
|
88 |
NS_LOG_DEBUG ("SRC="<<src48<<", DST = "<<dst48<<", I am: "<<m_address); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
89 |
if (!m_promiscRxCallback.IsNull ()) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
90 |
m_promiscRxCallback (this, packet, protocol, src, dst, packetType); |
5057
95a72c98f08d
Added dot11s installator, fixed bug with adding tag in proactive mode of HWMP
Kirill Andreev <andreev@iitp.ru>
parents:
4996
diff
changeset
|
91 |
if(dst48.IsGroup ()) |
4947 | 92 |
{ |
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
93 |
Ptr<Packet> packet_copy = packet->Copy (); |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
94 |
if(m_removeRoutingStuff (incomingPort->GetIfIndex(), src48, dst48, packet_copy, realProtocol)) |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
95 |
{ |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
96 |
m_rxCallback (this, packet_copy, realProtocol, src); |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
97 |
Forward (incomingPort, packet, protocol, src48, dst48); |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
98 |
} |
4947 | 99 |
return; |
100 |
} |
|
101 |
if(dst48 == m_address) |
|
5084
ddf23699f0b7
Initial flame implementation
Kirill Andreev <andreev@iitp.ru>
parents:
5083
diff
changeset
|
102 |
{ |
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
103 |
Ptr<Packet> packet_copy = packet->Copy (); |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
104 |
if(m_removeRoutingStuff (incomingPort->GetIfIndex (), src48, dst48, packet_copy, realProtocol)) |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
105 |
{ |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
106 |
m_rxCallback (this, packet_copy, realProtocol, src); |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
107 |
} |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
108 |
return; |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
109 |
} |
4947 | 110 |
else |
111 |
Forward (incomingPort, packet->Copy (), protocol, src48, dst48); |
|
4793 | 112 |
} |
113 |
||
114 |
void |
|
5070
c70964936d2e
added 'const' label to packet in MeshPointDevice::Forward and
Kirill Andreev <andreev@iitp.ru>
parents:
5068
diff
changeset
|
115 |
MeshPointDevice::Forward (Ptr<NetDevice> inport, Ptr<const Packet> packet, |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
116 |
uint16_t protocol, const Mac48Address src, const Mac48Address dst) |
4793 | 117 |
{ |
4815 | 118 |
// pass through routing protocol |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
119 |
m_requestRoute (inport->GetIfIndex(), src, dst, packet, protocol, m_myResponse); |
4793 | 120 |
} |
121 |
||
122 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
123 |
MeshPointDevice::SetName (const std::string name) |
4793 | 124 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
125 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
126 |
m_name = name; |
4793 | 127 |
} |
128 |
||
129 |
std::string |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
130 |
MeshPointDevice::GetName () const |
4815 | 131 |
{ |
132 |
NS_LOG_FUNCTION_NOARGS (); |
|
133 |
return m_name; |
|
134 |
} |
|
4793 | 135 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
136 |
void |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
137 |
MeshPointDevice::SetIfIndex (const uint32_t index) |
4793 | 138 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
139 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
140 |
m_ifIndex = index; |
4793 | 141 |
} |
142 |
||
143 |
uint32_t |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
144 |
MeshPointDevice::GetIfIndex () const |
4815 | 145 |
{ |
146 |
NS_LOG_FUNCTION_NOARGS (); |
|
147 |
return m_ifIndex; |
|
148 |
} |
|
4793 | 149 |
|
150 |
Ptr<Channel> |
|
4815 | 151 |
MeshPointDevice::GetChannel () const |
152 |
{ |
|
153 |
NS_LOG_FUNCTION_NOARGS (); |
|
154 |
return m_channel; |
|
155 |
} |
|
4793 | 156 |
|
157 |
Address |
|
4815 | 158 |
MeshPointDevice::GetAddress () const |
159 |
{ |
|
160 |
NS_LOG_FUNCTION_NOARGS (); |
|
161 |
return m_address; |
|
162 |
} |
|
4793 | 163 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
164 |
bool |
4815 | 165 |
MeshPointDevice::SetMtu (const uint16_t mtu) |
4793 | 166 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
167 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
168 |
m_mtu = mtu; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
169 |
return true; |
4793 | 170 |
} |
171 |
||
172 |
uint16_t |
|
4815 | 173 |
MeshPointDevice::GetMtu () const |
174 |
{ |
|
175 |
NS_LOG_FUNCTION_NOARGS (); |
|
176 |
return m_mtu; |
|
177 |
} |
|
178 |
||
179 |
bool |
|
180 |
MeshPointDevice::IsLinkUp () const |
|
181 |
{ |
|
182 |
NS_LOG_FUNCTION_NOARGS (); |
|
183 |
return true; |
|
184 |
} |
|
185 |
||
186 |
void |
|
187 |
MeshPointDevice::SetLinkChangeCallback (Callback<void> callback) |
|
188 |
{ |
|
189 |
// do nothing |
|
190 |
} |
|
191 |
||
192 |
bool |
|
193 |
MeshPointDevice::IsBroadcast () const |
|
194 |
{ |
|
195 |
NS_LOG_FUNCTION_NOARGS (); |
|
196 |
return true; |
|
197 |
} |
|
198 |
||
199 |
Address |
|
200 |
MeshPointDevice::GetBroadcast () const |
|
201 |
{ |
|
202 |
NS_LOG_FUNCTION_NOARGS (); |
|
203 |
return Mac48Address ("ff:ff:ff:ff:ff:ff"); |
|
204 |
} |
|
205 |
||
206 |
bool |
|
207 |
MeshPointDevice::IsMulticast () const |
|
208 |
{ |
|
209 |
NS_LOG_FUNCTION_NOARGS (); |
|
210 |
return true; |
|
211 |
} |
|
212 |
||
213 |
Address |
|
214 |
MeshPointDevice::GetMulticast (Ipv4Address multicastGroup) const |
|
215 |
{ |
|
216 |
NS_LOG_FUNCTION (this << multicastGroup); |
|
217 |
Mac48Address multicast = Mac48Address::GetMulticast (multicastGroup); |
|
218 |
return multicast; |
|
219 |
} |
|
220 |
||
221 |
bool |
|
222 |
MeshPointDevice::IsPointToPoint () const |
|
223 |
{ |
|
224 |
NS_LOG_FUNCTION_NOARGS (); |
|
225 |
return false; |
|
226 |
} |
|
227 |
||
228 |
bool |
|
229 |
MeshPointDevice::IsBridge () const |
|
230 |
{ |
|
231 |
NS_LOG_FUNCTION_NOARGS (); |
|
232 |
return false; |
|
233 |
} |
|
4793 | 234 |
|
235 |
||
236 |
bool |
|
4815 | 237 |
MeshPointDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) |
4793 | 238 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
239 |
const Mac48Address dst48 = Mac48Address::ConvertFrom (dest); |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
240 |
return m_requestRoute (m_ifIndex, m_address, dst48, packet, protocolNumber, m_myResponse); |
4793 | 241 |
} |
242 |
||
243 |
bool |
|
4815 | 244 |
MeshPointDevice::SendFrom (Ptr<Packet> packet, const Address& src, const Address& dest, uint16_t protocolNumber) |
4793 | 245 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
246 |
const Mac48Address src48 = Mac48Address::ConvertFrom (src); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
247 |
const Mac48Address dst48 = Mac48Address::ConvertFrom (dest); |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
248 |
return m_requestRoute (m_ifIndex, src48, dst48, packet, protocolNumber, m_myResponse); |
4793 | 249 |
} |
250 |
||
251 |
Ptr<Node> |
|
4815 | 252 |
MeshPointDevice::GetNode () const |
253 |
{ |
|
254 |
NS_LOG_FUNCTION_NOARGS (); |
|
255 |
return m_node; |
|
256 |
} |
|
4793 | 257 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
258 |
void |
4815 | 259 |
MeshPointDevice::SetNode (Ptr<Node> node) |
4793 | 260 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
261 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
262 |
m_node = node; |
4793 | 263 |
} |
264 |
||
265 |
bool |
|
4815 | 266 |
MeshPointDevice::NeedsArp () const |
267 |
{ |
|
268 |
NS_LOG_FUNCTION_NOARGS (); |
|
269 |
return true; |
|
270 |
} |
|
4793 | 271 |
|
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
272 |
void |
4815 | 273 |
MeshPointDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb) |
4793 | 274 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
275 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
276 |
m_rxCallback = cb; |
4793 | 277 |
} |
278 |
||
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
279 |
void |
4815 | 280 |
MeshPointDevice::SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb) |
4793 | 281 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
282 |
NS_LOG_FUNCTION_NOARGS (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
283 |
m_promiscRxCallback = cb; |
4793 | 284 |
} |
285 |
||
286 |
bool |
|
4815 | 287 |
MeshPointDevice::SupportsSendFrom () const |
288 |
{ |
|
289 |
NS_LOG_FUNCTION_NOARGS (); |
|
4986
73ca74882f12
don't allow bridge mesh points
Pavel Boyko <boyko@iitp.ru>
parents:
4985
diff
changeset
|
290 |
return false; // don't allow to bridge mesh network with something else. |
4815 | 291 |
} |
4793 | 292 |
|
293 |
Address |
|
4815 | 294 |
MeshPointDevice::GetMulticast (Ipv6Address addr) const |
295 |
{ |
|
296 |
NS_LOG_FUNCTION (this << addr); |
|
297 |
return Mac48Address::GetMulticast (addr); |
|
298 |
} |
|
4793 | 299 |
|
4815 | 300 |
//----------------------------------------------------------------------------- |
301 |
// Interfaces |
|
302 |
//----------------------------------------------------------------------------- |
|
303 |
uint32_t |
|
304 |
MeshPointDevice::GetNInterfaces () const |
|
4793 | 305 |
{ |
4815 | 306 |
NS_LOG_FUNCTION_NOARGS (); |
307 |
return m_ifaces.size (); |
|
308 |
} |
|
309 |
||
310 |
Ptr<NetDevice> |
|
311 |
MeshPointDevice::GetInterface (uint32_t n) const |
|
312 |
{ |
|
4932 | 313 |
for(std::vector< Ptr<NetDevice> >::const_iterator i = m_ifaces.begin (); i != m_ifaces.end (); i ++) |
314 |
if((*i)->GetIfIndex() == n) |
|
315 |
return (*i); |
|
5063 | 316 |
|
317 |
NS_FATAL_ERROR ("Mesh point interface is not found by index"); |
|
4932 | 318 |
return 0; |
4793 | 319 |
} |
4888
dec245c213ab
Attach interfaces replaced with Install. Helper is simplifyed
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
320 |
std::vector<Ptr<NetDevice> > |
dec245c213ab
Attach interfaces replaced with Install. Helper is simplifyed
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
321 |
MeshPointDevice::GetInterfaces () const |
dec245c213ab
Attach interfaces replaced with Install. Helper is simplifyed
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
322 |
{ |
dec245c213ab
Attach interfaces replaced with Install. Helper is simplifyed
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
323 |
return m_ifaces; |
dec245c213ab
Attach interfaces replaced with Install. Helper is simplifyed
Kirill Andreev <andreev@iitp.ru>
parents:
4852
diff
changeset
|
324 |
} |
4793 | 325 |
void |
4815 | 326 |
MeshPointDevice::AddInterface (Ptr<NetDevice> iface) |
327 |
{ |
|
328 |
NS_LOG_FUNCTION_NOARGS (); |
|
329 |
||
330 |
NS_ASSERT (iface != this); |
|
331 |
if (!Mac48Address::IsMatchingType (iface->GetAddress ())) |
|
4953
0226369989a3
Added {} in 'if' where ASSERT exists
Kirill Andreev <andreev@iitp.ru>
parents:
4947
diff
changeset
|
332 |
{ |
4985
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
333 |
NS_FATAL_ERROR ("Device does not support eui 48 addresses: cannot be used as a mesh point interface."); |
4953
0226369989a3
Added {} in 'if' where ASSERT exists
Kirill Andreev <andreev@iitp.ru>
parents:
4947
diff
changeset
|
334 |
} |
4815 | 335 |
if (!iface->SupportsSendFrom ()) |
4953
0226369989a3
Added {} in 'if' where ASSERT exists
Kirill Andreev <andreev@iitp.ru>
parents:
4947
diff
changeset
|
336 |
{ |
4985
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
337 |
NS_FATAL_ERROR ("Device does not support SendFrom: cannot be used as a mesh point interface."); |
4953
0226369989a3
Added {} in 'if' where ASSERT exists
Kirill Andreev <andreev@iitp.ru>
parents:
4947
diff
changeset
|
338 |
} |
4985
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
339 |
|
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
340 |
// Mesh point has MAC address of it's first interface |
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
341 |
if (m_ifaces.empty()) |
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
342 |
m_address = Mac48Address::ConvertFrom (iface->GetAddress ()); |
4815 | 343 |
|
4985
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
344 |
const WifiNetDevice * wifiNetDev = dynamic_cast<const WifiNetDevice *> (PeekPointer (iface)); |
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
345 |
if (wifiNetDev == 0) |
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
346 |
NS_FATAL_ERROR ("Device is not a WiFi NIC: cannot be used as a mesh point interface."); |
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
347 |
|
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
348 |
MeshWifiInterfaceMac * ifaceMac = dynamic_cast<MeshWifiInterfaceMac *> (PeekPointer (wifiNetDev->GetMac ())); |
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
349 |
if (ifaceMac == 0) |
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
350 |
NS_FATAL_ERROR ("WiFi device doesn't have correct MAC installed: cannot be used as a mesh point interface."); |
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
351 |
|
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
352 |
ifaceMac->SetMeshPointAddress (m_address); |
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
353 |
|
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
354 |
// Receive frames from this interface |
4815 | 355 |
m_node->RegisterProtocolHandler (MakeCallback (&MeshPointDevice::ReceiveFromDevice, this), |
356 |
0, iface, /*promiscuous = */true); |
|
357 |
||
358 |
m_ifaces.push_back (iface); |
|
359 |
m_channel->AddChannel (iface->GetChannel ()); |
|
360 |
} |
|
361 |
||
362 |
//----------------------------------------------------------------------------- |
|
363 |
// Protocols |
|
364 |
//----------------------------------------------------------------------------- |
|
365 |
||
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
366 |
void |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
367 |
MeshPointDevice::SetRoutingProtocol (Ptr<MeshL2RoutingProtocol> protocol) |
4815 | 368 |
{ |
369 |
NS_LOG_FUNCTION_NOARGS (); |
|
370 |
||
4985
8dbdba66f5e1
Mehs point MAC address is now known to all interfaces and included into beacons as Address3
Pavel Boyko <boyko@iitp.ru>
parents:
4967
diff
changeset
|
371 |
NS_ASSERT_MSG (PeekPointer(protocol->GetMeshPoint()) == this, "Routing protocol must be installed on mesh point to be useful."); |
4817
1257e4b82e17
L2RoutingProtocol refactored to MeshL2RoutingProtocol
Pavel Boyko <boyko@iitp.ru>
parents:
4815
diff
changeset
|
372 |
|
4928
825037c2d7ab
Make routing protocol attribute of mesh point to be accessable by Config::
Pavel Boyko <boyko@iitp.ru>
parents:
4906
diff
changeset
|
373 |
m_routingProtocol = protocol; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
374 |
m_requestRoute = MakeCallback (&MeshL2RoutingProtocol::RequestRoute, protocol); |
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5070
diff
changeset
|
375 |
m_removeRoutingStuff = MakeCallback (&MeshL2RoutingProtocol::RemoveRoutingStuff, protocol); |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
376 |
m_myResponse = MakeCallback (&MeshPointDevice::DoSend, this); |
4815 | 377 |
} |
378 |
||
4928
825037c2d7ab
Make routing protocol attribute of mesh point to be accessable by Config::
Pavel Boyko <boyko@iitp.ru>
parents:
4906
diff
changeset
|
379 |
Ptr<MeshL2RoutingProtocol> |
825037c2d7ab
Make routing protocol attribute of mesh point to be accessable by Config::
Pavel Boyko <boyko@iitp.ru>
parents:
4906
diff
changeset
|
380 |
MeshPointDevice::GetRoutingProtocol () const |
825037c2d7ab
Make routing protocol attribute of mesh point to be accessable by Config::
Pavel Boyko <boyko@iitp.ru>
parents:
4906
diff
changeset
|
381 |
{ |
825037c2d7ab
Make routing protocol attribute of mesh point to be accessable by Config::
Pavel Boyko <boyko@iitp.ru>
parents:
4906
diff
changeset
|
382 |
return m_routingProtocol; |
825037c2d7ab
Make routing protocol attribute of mesh point to be accessable by Config::
Pavel Boyko <boyko@iitp.ru>
parents:
4906
diff
changeset
|
383 |
} |
825037c2d7ab
Make routing protocol attribute of mesh point to be accessable by Config::
Pavel Boyko <boyko@iitp.ru>
parents:
4906
diff
changeset
|
384 |
|
4815 | 385 |
void |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
386 |
MeshPointDevice::DoSend (bool success, Ptr<Packet> packet, Mac48Address src, Mac48Address dst, uint16_t protocol, uint32_t outIface) |
4793 | 387 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
388 |
if (!success) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
389 |
{ |
4996
33f418524356
Fixed routing information with neighbours, fixed address3 in management
Kirill Andreev <andreev@iitp.ru>
parents:
4987
diff
changeset
|
390 |
NS_LOG_DEBUG ("Resolve failed"); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
391 |
return; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
392 |
} |
4815 | 393 |
// Ok, now I know the route, just SendFrom |
394 |
if (outIface != 0xffffffff) |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
395 |
GetInterface (outIface)->SendFrom(packet, src, dst, protocol); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
396 |
else |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
397 |
for (std::vector<Ptr<NetDevice> >::iterator i = m_ifaces.begin (); i != m_ifaces.end(); i++) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4841
diff
changeset
|
398 |
(*i) -> SendFrom (packet, src, dst, protocol); |
4793 | 399 |
} |
400 |
||
401 |
} // namespace ns3 |