author | Kirill Andreev <andreev@iitp.ru> |
Mon, 03 Aug 2009 19:13:46 +0400 | |
changeset 5145 | 7f50ab7ce59d |
parent 5132 | aee541a30256 |
child 5147 | 546c5d9a7e64 |
permissions | -rw-r--r-- |
5079
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
2 |
/* |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
3 |
* Copyright (c) 2009 IITP RAS |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
4 |
* |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
8 |
* |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
13 |
* |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
17 |
* |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
18 |
* Author: Kirill Andreev <andreev@iitp.ru> |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
19 |
*/ |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
20 |
|
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
21 |
#include "flame-protocol.h" |
5082 | 22 |
#include "flame-header.h" |
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
23 |
#include "ns3/llc-snap-header.h" |
5082 | 24 |
#include "ns3/log.h" |
25 |
#include "ns3/simulator.h" |
|
26 |
#include "ns3/packet.h" |
|
27 |
#include "ns3/mesh-point-device.h" |
|
28 |
#include "ns3/wifi-net-device.h" |
|
29 |
#include "ns3/mesh-point-device.h" |
|
30 |
#include "ns3/mesh-wifi-interface-mac.h" |
|
31 |
#include "ns3/random-variable.h" |
|
32 |
||
5095 | 33 |
NS_LOG_COMPONENT_DEFINE ("FlameProtocol"); |
34 |
||
5132
aee541a30256
Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents:
5129
diff
changeset
|
35 |
namespace ns3 { |
aee541a30256
Restored newline at namespace
Kirill Andreev <andreev@iitp.ru>
parents:
5129
diff
changeset
|
36 |
namespace flame { |
5080 | 37 |
//----------------------------------------------------------------------------- |
38 |
// FlameTag |
|
39 |
//----------------------------------------------------------------------------- |
|
40 |
NS_OBJECT_ENSURE_REGISTERED (FlameTag); |
|
41 |
||
42 |
TypeId |
|
43 |
FlameTag::GetTypeId () |
|
44 |
{ |
|
5129 | 45 |
static TypeId tid = TypeId ("ns3::flame::FlameTag") .SetParent<Tag> () .AddConstructor<FlameTag> (); |
46 |
return tid; |
|
5080 | 47 |
} |
48 |
||
49 |
TypeId |
|
50 |
FlameTag::GetInstanceTypeId () const |
|
51 |
{ |
|
52 |
return GetTypeId (); |
|
53 |
} |
|
54 |
||
55 |
uint32_t |
|
56 |
FlameTag::GetSerializedSize () const |
|
57 |
{ |
|
5092 | 58 |
return 12; |
5080 | 59 |
} |
60 |
||
61 |
void |
|
62 |
FlameTag::Serialize (TagBuffer i) const |
|
63 |
{ |
|
64 |
uint8_t buf[6]; |
|
5092 | 65 |
receiver.CopyTo (buf); |
5129 | 66 |
for (int j = 0; j < 6; j++) |
67 |
{ |
|
68 |
i.WriteU8 (buf[j]); |
|
69 |
} |
|
5092 | 70 |
transmitter.CopyTo (buf); |
5129 | 71 |
for (int j = 0; j < 6; j++) |
72 |
{ |
|
73 |
i.WriteU8 (buf[j]); |
|
74 |
} |
|
5092 | 75 |
|
5080 | 76 |
} |
77 |
||
78 |
void |
|
79 |
FlameTag::Deserialize (TagBuffer i) |
|
80 |
{ |
|
81 |
uint8_t buf[6]; |
|
5129 | 82 |
for (int j = 0; j < 6; j++) |
83 |
{ |
|
84 |
buf[j] = i.ReadU8 (); |
|
85 |
} |
|
5092 | 86 |
receiver.CopyFrom (buf); |
5129 | 87 |
for (int j = 0; j < 6; j++) |
88 |
{ |
|
89 |
buf[j] = i.ReadU8 (); |
|
90 |
} |
|
5092 | 91 |
transmitter.CopyFrom (buf); |
92 |
||
5080 | 93 |
} |
94 |
||
95 |
void |
|
96 |
FlameTag::Print (std::ostream &os) const |
|
97 |
{ |
|
5092 | 98 |
os << "receiver = " << receiver << ", transmitter = " << transmitter; |
5080 | 99 |
} |
100 |
||
5082 | 101 |
//----------------------------------------------------------------------------- |
5095 | 102 |
// FlameProtocol |
5082 | 103 |
//----------------------------------------------------------------------------- |
104 |
TypeId |
|
105 |
FlameProtocol::GetTypeId () |
|
106 |
{ |
|
107 |
static TypeId tid = TypeId ("ns3::flame::FlameProtocol") |
|
108 |
.SetParent<MeshL2RoutingProtocol> () |
|
109 |
.AddConstructor<FlameProtocol> () |
|
5129 | 110 |
.AddAttribute ( "BroadcastInterval", |
111 |
"How often we must send broadcast packets", |
|
112 |
TimeValue (Seconds (5)), |
|
113 |
MakeTimeAccessor ( |
|
114 |
&FlameProtocol::m_broadcastInterval), |
|
115 |
MakeTimeChecker () |
|
116 |
) |
|
117 |
.AddAttribute ( "MaxCost", |
|
118 |
"Cost threshold after which packet will be dropeed", |
|
119 |
UintegerValue (32), |
|
120 |
MakeUintegerAccessor ( |
|
121 |
&FlameProtocol::m_maxCost), |
|
122 |
MakeUintegerChecker<uint8_t> (3) |
|
123 |
) |
|
124 |
; |
|
5082 | 125 |
return tid; |
126 |
} |
|
127 |
FlameProtocol::FlameProtocol () : |
|
5129 | 128 |
m_address (Mac48Address ()), m_broadcastInterval (Seconds (5)), m_lastBroadcast (Simulator::Now ()), |
129 |
m_maxCost (32), m_myLastSeqno (0), m_rtable (CreateObject<FlameRtable> ()) |
|
5082 | 130 |
{ |
131 |
} |
|
132 |
FlameProtocol::~FlameProtocol () |
|
133 |
{ |
|
134 |
} |
|
135 |
void |
|
136 |
FlameProtocol::DoDispose () |
|
137 |
{ |
|
138 |
} |
|
139 |
bool |
|
5129 | 140 |
FlameProtocol::RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination, |
141 |
Ptr<const Packet> const_packet, uint16_t protocolType, RouteReplyCallback routeReply) |
|
5082 | 142 |
{ |
143 |
Ptr<Packet> packet = const_packet->Copy (); |
|
5092 | 144 |
if (sourceIface == m_mp->GetIfIndex ()) |
5082 | 145 |
{ |
5129 | 146 |
//Packet from upper layer! |
147 |
FlameTag tag; |
|
148 |
if (packet->PeekPacketTag (tag)) |
|
149 |
{ |
|
150 |
NS_FATAL_ERROR ("FLAME tag is not supposed to be received from upper layers"); |
|
151 |
} |
|
152 |
FlameRtable::LookupResult result = m_rtable->Lookup (destination); |
|
153 |
if (result.retransmitter == Mac48Address::GetBroadcast ()) |
|
154 |
{ |
|
155 |
m_lastBroadcast = Simulator::Now (); |
|
156 |
} |
|
157 |
if (m_lastBroadcast + m_broadcastInterval < Simulator::Now ()) |
|
158 |
{ |
|
159 |
result.retransmitter = Mac48Address::GetBroadcast (); |
|
160 |
result.ifIndex = FlameRtable::INTERFACE_ANY; |
|
161 |
m_lastBroadcast = Simulator::Now (); |
|
162 |
} |
|
163 |
FlameHeader flameHdr; |
|
164 |
flameHdr.AddCost (0); |
|
165 |
flameHdr.SetSeqno (m_myLastSeqno++); |
|
166 |
flameHdr.SetProtocol (protocolType); |
|
167 |
flameHdr.SetOrigDst (destination); |
|
168 |
flameHdr.SetOrigSrc (source); |
|
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
169 |
m_stats.txBytes += packet->GetSize (); |
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
170 |
packet->AddHeader (flameHdr); |
5129 | 171 |
tag.receiver = result.retransmitter; |
172 |
if (result.retransmitter == Mac48Address::GetBroadcast ()) |
|
173 |
{ |
|
174 |
m_stats.txBroadcast++; |
|
175 |
} |
|
176 |
else |
|
177 |
{ |
|
178 |
m_stats.txUnicast++; |
|
179 |
} |
|
180 |
NS_LOG_DEBUG ("Source: send packet with RA = " << tag.receiver); |
|
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
181 |
packet->AddPacketTag (tag); |
5129 | 182 |
routeReply (true, packet, source, destination, FLAME_PROTOCOL, result.ifIndex); |
183 |
} |
|
184 |
else |
|
185 |
{ |
|
186 |
FlameHeader flameHdr; |
|
187 |
packet->RemoveHeader (flameHdr); |
|
188 |
FlameTag tag; |
|
5145
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
189 |
|
5129 | 190 |
if (!packet->RemovePacketTag (tag)) |
191 |
{ |
|
5145
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
192 |
NS_FATAL_ERROR ("FLAME tag must exist here"); |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
193 |
} |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
194 |
if (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, sourceIface)) |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
195 |
{ |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
196 |
return false; |
5129 | 197 |
} |
198 |
if (source == GetAddress ()) |
|
199 |
{ |
|
200 |
if (tag.receiver != Mac48Address::GetBroadcast ()) |
|
201 |
{ |
|
202 |
NS_LOG_DEBUG ("received packet with SA = GetAddress (), RA = " << tag.receiver << ", TA = " |
|
203 |
<< tag.transmitter << ", I am " << GetAddress ()); |
|
204 |
} |
|
205 |
m_stats.totalDropped++; |
|
206 |
return false; |
|
207 |
} |
|
208 |
if (destination == Mac48Address::GetBroadcast ()) |
|
209 |
{ |
|
210 |
//Broadcast always is forwarded as broadcast! |
|
211 |
NS_ASSERT (HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, sourceIface)); |
|
212 |
FlameTag tag (Mac48Address::GetBroadcast ()); |
|
213 |
flameHdr.AddCost (1); |
|
214 |
m_stats.txBytes += packet->GetSize (); |
|
215 |
packet->AddHeader (flameHdr); |
|
216 |
packet->AddPacketTag (tag); |
|
217 |
routeReply (true, packet, source, destination, FLAME_PROTOCOL, FlameRtable::INTERFACE_ANY); |
|
218 |
m_stats.txBroadcast++; |
|
219 |
return true; |
|
220 |
} |
|
221 |
else |
|
222 |
{ |
|
5145
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
223 |
|
5129 | 224 |
FlameRtable::LookupResult result = m_rtable->Lookup (destination); |
225 |
if (tag.receiver != Mac48Address::GetBroadcast ()) |
|
226 |
{ |
|
227 |
if (result.retransmitter == Mac48Address::GetBroadcast ()) |
|
228 |
{ |
|
229 |
NS_LOG_DEBUG ("unicast packet dropped, because no route! I am " << GetAddress () |
|
230 |
<< ", RA = " << tag.receiver << ", TA = " << tag.transmitter); |
|
231 |
m_stats.totalDropped++; |
|
232 |
return false; |
|
233 |
} |
|
234 |
} |
|
235 |
tag.receiver = result.retransmitter; |
|
236 |
if (result.retransmitter == Mac48Address::GetBroadcast ()) |
|
237 |
{ |
|
238 |
m_stats.txBroadcast++; |
|
239 |
} |
|
240 |
else |
|
241 |
{ |
|
242 |
m_stats.txUnicast++; |
|
243 |
} |
|
244 |
m_stats.txBytes += packet->GetSize (); |
|
245 |
flameHdr.AddCost (1); |
|
246 |
packet->AddHeader (flameHdr); |
|
247 |
packet->AddPacketTag (tag); |
|
248 |
routeReply (true, packet, source, destination, FLAME_PROTOCOL, result.ifIndex); |
|
249 |
return true; |
|
250 |
} |
|
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
251 |
return true; |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
252 |
} |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
253 |
return false; |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
254 |
} |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
255 |
bool |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
256 |
FlameProtocol::RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source, |
5129 | 257 |
const Mac48Address destination, Ptr<Packet> packet, uint16_t& protocolType) |
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
258 |
{ |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
259 |
//Filter seqno: |
5129 | 260 |
if (source == GetAddress ()) |
261 |
{ |
|
262 |
NS_LOG_DEBUG ("Dropped my own frame!"); |
|
263 |
return false; |
|
264 |
} |
|
5084
ddf23699f0b7
Initial flame implementation
Kirill Andreev <andreev@iitp.ru>
parents:
5083
diff
changeset
|
265 |
FlameTag tag; |
5129 | 266 |
if (!packet->RemovePacketTag (tag)) |
267 |
{ |
|
268 |
NS_FATAL_ERROR ("FLAME tag must exist when packet is coming to protocol"); |
|
269 |
} |
|
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
270 |
FlameHeader flameHdr; |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
271 |
packet->RemoveHeader (flameHdr); |
5145
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
272 |
if ((destination == GetAddress ()) && (m_lastBroadcast + m_broadcastInterval < Simulator::Now ())) |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
273 |
{ |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
274 |
Ptr<Packet> packet = Create<Packet> (); |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
275 |
m_mp->Send(packet, Mac48Address::GetBroadcast (), 0); |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
276 |
m_lastBroadcast = Simulator::Now (); |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
277 |
} |
5129 | 278 |
NS_ASSERT (protocolType == FLAME_PROTOCOL); |
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
279 |
protocolType = flameHdr.GetProtocol (); |
5145
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
280 |
if ((HandleDataFrame (flameHdr.GetSeqno (), source, flameHdr, tag.transmitter, fromIface)) |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
281 |
|| packet->GetSize () == 0) |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
282 |
{ |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
283 |
return false; |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
284 |
} |
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
285 |
return true; |
5082 | 286 |
} |
287 |
bool |
|
288 |
FlameProtocol::Install (Ptr<MeshPointDevice> mp) |
|
289 |
{ |
|
290 |
m_mp = mp; |
|
291 |
std::vector<Ptr<NetDevice> > interfaces = mp->GetInterfaces (); |
|
5129 | 292 |
for (std::vector<Ptr<NetDevice> >::const_iterator i = interfaces.begin (); i != interfaces.end (); i++) |
5082 | 293 |
{ |
294 |
// Checking for compatible net device |
|
295 |
Ptr<WifiNetDevice> wifiNetDev = (*i)->GetObject<WifiNetDevice> (); |
|
296 |
if (wifiNetDev == 0) |
|
5129 | 297 |
{ |
298 |
return false; |
|
299 |
} |
|
300 |
Ptr<MeshWifiInterfaceMac> mac = wifiNetDev->GetMac ()->GetObject<MeshWifiInterfaceMac> (); |
|
5082 | 301 |
if (mac == 0) |
5129 | 302 |
{ |
303 |
return false; |
|
304 |
} |
|
5082 | 305 |
// Installing plugins: |
5086
fccfd0073ea3
Fixed names: now protocols are called *-protocol.[h,cc], plugin is called
Kirill Andreev <andreev@iitp.ru>
parents:
5084
diff
changeset
|
306 |
Ptr<FlameProtocolMac> flameMac = Create<FlameProtocolMac> (wifiNetDev->GetIfIndex (), this); |
5082 | 307 |
m_interfaces[wifiNetDev->GetIfIndex ()] = flameMac; |
5092 | 308 |
mac->SetBeaconGeneration (false); |
5082 | 309 |
mac->InstallPlugin (flameMac); |
310 |
} |
|
311 |
mp->SetRoutingProtocol (this); |
|
312 |
// Mesh point aggregates all installed protocols |
|
313 |
mp->AggregateObject (this); |
|
314 |
m_address = Mac48Address::ConvertFrom (mp->GetAddress ());//* address; |
|
315 |
return true; |
|
316 |
} |
|
317 |
Mac48Address |
|
318 |
FlameProtocol::GetAddress () |
|
319 |
{ |
|
320 |
return m_address; |
|
321 |
} |
|
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
322 |
bool |
5129 | 323 |
FlameProtocol::HandleDataFrame (uint16_t seqno, Mac48Address source, const FlameHeader flameHdr, |
324 |
Mac48Address receiver, uint32_t fromInterface) |
|
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
325 |
{ |
5129 | 326 |
if (source == GetAddress ()) |
327 |
{ |
|
328 |
return true; |
|
329 |
} |
|
5084
ddf23699f0b7
Initial flame implementation
Kirill Andreev <andreev@iitp.ru>
parents:
5083
diff
changeset
|
330 |
FlameRtable::LookupResult result = m_rtable->Lookup (source); |
5145
7f50ab7ce59d
Added path update to FLAME
Kirill Andreev <andreev@iitp.ru>
parents:
5132
diff
changeset
|
331 |
if ((result.retransmitter != Mac48Address::GetBroadcast ()) && (result.seqnum >= seqno)) |
5129 | 332 |
{ |
333 |
return true; |
|
334 |
} |
|
5090
0facd23819b6
Fixed seqno and ttl filter: changed order
Kirill Andreev <andreev@iitp.ru>
parents:
5089
diff
changeset
|
335 |
if (flameHdr.GetCost () > m_maxCost) |
5129 | 336 |
{ |
337 |
m_stats.droppedTtl++; |
|
338 |
return true; |
|
339 |
} |
|
5088
fe6fcf14f2a1
Flame: added correct seqno filtering, added broadcast timers
Kirill Andreev <andreev@iitp.ru>
parents:
5086
diff
changeset
|
340 |
m_rtable->AddPath (source, receiver, fromInterface, flameHdr.GetCost (), flameHdr.GetSeqno ()); |
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
341 |
return false; |
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
342 |
} |
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
343 |
//Statistics: |
5126
8e06088a785d
Statistics removed from headers
Kirill Andreev <andreev@iitp.ru>
parents:
5106
diff
changeset
|
344 |
FlameProtocol::Statistics::Statistics () : |
5129 | 345 |
txUnicast (0), txBroadcast (0), txBytes (0), droppedTtl (0), totalDropped (0) |
346 |
{ |
|
347 |
} |
|
348 |
void |
|
349 |
FlameProtocol::Statistics::Print (std::ostream & os) const |
|
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
350 |
{ |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
351 |
os << "<Statistics " |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
352 |
"txUnicast=\"" << txUnicast << "\" " |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
353 |
"txBroadcast=\"" << txBroadcast << "\" " |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
354 |
"txBytes=\"" << txBytes << "\" " |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
355 |
"droppedTtl=\"" << droppedTtl << "\" " |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
356 |
"totalDropped=\"" << totalDropped << "\"/>\n"; |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
357 |
} |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
358 |
void |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
359 |
FlameProtocol::Report (std::ostream & os) const |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
360 |
{ |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
361 |
os << "<Flame " |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
362 |
"address=\"" << m_address << "\"\n" |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
363 |
"broadcastInterval=\"" << m_broadcastInterval.GetSeconds () << "\"\n" |
5129 | 364 |
"maxCost=\"" << (uint16_t) m_maxCost << "\">\n"; |
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
365 |
m_stats.Print (os); |
5129 | 366 |
for (FlamePluginMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin++) |
367 |
{ |
|
368 |
plugin->second->Report (os); |
|
369 |
} |
|
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
370 |
os << "</Flame>\n"; |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
371 |
} |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
372 |
void |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
373 |
FlameProtocol::ResetStats () |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
374 |
{ |
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
375 |
m_stats = Statistics (); |
5129 | 376 |
for (FlamePluginMap::const_iterator plugin = m_interfaces.begin (); plugin != m_interfaces.end (); plugin++) |
377 |
{ |
|
378 |
plugin->second->ResetStats (); |
|
379 |
} |
|
5106
de6fe90556c8
Added comments and statistics to flame
Kirill Andreev <andreev@iitp.ru>
parents:
5095
diff
changeset
|
380 |
} |
5083
5b154b30a8a1
Restructured L2RoutingProtocol: added cleanup function, which deletes all tags
Kirill Andreev <andreev@iitp.ru>
parents:
5082
diff
changeset
|
381 |
|
5079
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
382 |
} //namespace flame |
245215e5e6ed
Added flame rtable, fixed DoDispose in HwmpRtable
Kirill Andreev <andreev@iitp.ru>
parents:
diff
changeset
|
383 |
} //namespace ns3 |