author | Kirill Andreev <andreev@iitp.ru> |
Sun, 22 Mar 2009 12:34:24 +0300 | |
changeset 4865 | e331ed5d3662 |
parent 4852 | 123dc54d734e |
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> |
|
19 |
*/ |
|
20 |
||
21 |
||
22 |
#include "ns3/object.h" |
|
23 |
#include "ns3/assert.h" |
|
24 |
#include "ns3/simulator.h" |
|
25 |
#include "ns3/ptr.h" |
|
26 |
#include "ns3/log.h" |
|
27 |
#include "ns3/node.h" |
|
4813
e4e2c44d27cd
All mesh related filed moved to devices/mesh. Let the refactoring begins!
Pavel Boyko <boyko@iitp.ru>
parents:
4812
diff
changeset
|
28 |
#include "ns3/hwmp-rtable.h" |
4793 | 29 |
|
30 |
NS_LOG_COMPONENT_DEFINE ("HwmpRtable"); |
|
31 |
||
32 |
namespace ns3 { |
|
33 |
||
34 |
NS_OBJECT_ENSURE_REGISTERED (HwmpRtable); |
|
35 |
||
36 |
TypeId |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
37 |
HwmpRtable::GetTypeId () |
4793 | 38 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
39 |
static TypeId tid = TypeId ("ns3::HwmpRtable") |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
40 |
.SetParent<Object> () |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
41 |
.AddConstructor<HwmpRtable> (); |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
42 |
return tid; |
4793 | 43 |
|
44 |
} |
|
45 |
||
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
46 |
HwmpRtable::HwmpRtable () |
4793 | 47 |
{ |
48 |
} |
|
49 |
||
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
50 |
HwmpRtable::~HwmpRtable () |
4793 | 51 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
52 |
DoDispose (); |
4793 | 53 |
} |
54 |
||
55 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
56 |
HwmpRtable::DoDispose () |
4793 | 57 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
58 |
NS_LOG_UNCOND ("RTABLE DISPOSE STARTED"); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
59 |
m_routes.clear (); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
60 |
m_roots.clear (); |
4793 | 61 |
} |
62 |
||
63 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
64 |
HwmpRtable::AddReactivePath ( |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
65 |
Mac48Address destination, |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
66 |
Mac48Address retransmitter, |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
67 |
uint32_t port, |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
68 |
uint32_t metric, |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
69 |
Time lifetime, |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
70 |
uint32_t seqnum |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
71 |
) |
4793 | 72 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
73 |
std::map<Mac48Address, ReactiveRoute>::iterator i = m_routes.find (destination); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
74 |
if (i == m_routes.end ()) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
75 |
{ |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
76 |
ReactiveRoute newroute; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
77 |
m_routes[destination] = newroute; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
78 |
} |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
79 |
else |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
80 |
{ |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
81 |
/** |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
82 |
* if outport differs from stored, routing info is |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
83 |
* actual and metric is worse - we ignore this |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
84 |
* information |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
85 |
*/ |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
86 |
if ( |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
87 |
(i->second.port != port) && |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
88 |
(i->second.metric < metric) && |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
89 |
/** |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
90 |
* The routing info is actual or it |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
91 |
* was received from peer |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
92 |
*/ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
93 |
((i->second.whenExpire > Simulator::Now ())||(i->second.whenExpire == Seconds(0))) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
94 |
) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
95 |
return; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
96 |
} |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
97 |
i = m_routes.find (destination); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
98 |
NS_ASSERT (i != m_routes.end()); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
99 |
i->second.retransmitter = retransmitter; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
100 |
i->second.port = port; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
101 |
i->second.metric = metric; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
102 |
if (lifetime != Seconds (0)) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
103 |
i->second.whenExpire = MilliSeconds (Simulator::Now().GetMilliSeconds() + lifetime.GetMilliSeconds()); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
104 |
else |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
105 |
/** |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
106 |
* Information about peer does not have lifetime |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
107 |
*/ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
108 |
i->second.whenExpire = Seconds (0); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
109 |
i->second.seqnum = seqnum; |
4793 | 110 |
} |
111 |
||
112 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
113 |
HwmpRtable::AddProactivePath ( |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
114 |
uint32_t metric, |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
115 |
Mac48Address root, |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
116 |
Mac48Address retransmitter, |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
117 |
uint32_t port, |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
118 |
Time lifetime, |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
119 |
uint32_t seqnum |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
120 |
) |
4793 | 121 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
122 |
ProactiveRoute newroute; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
123 |
m_roots[port] = newroute; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
124 |
std::map<uint32_t,ProactiveRoute>::iterator i = m_roots.find (port); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
125 |
NS_ASSERT (i != m_roots.end()); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
126 |
i->second.root = root; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
127 |
i->second.retransmitter = retransmitter; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
128 |
i->second.metric = metric; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
129 |
i->second.whenExpire = MilliSeconds (Simulator::Now().GetMilliSeconds() + lifetime.GetMilliSeconds()); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
130 |
i->second.seqnum = seqnum; |
4793 | 131 |
|
132 |
} |
|
133 |
||
134 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
135 |
HwmpRtable::AddPrecursor (Mac48Address destination, uint32_t port, Mac48Address precursor) |
4793 | 136 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
137 |
bool should_add = true; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
138 |
std::map<Mac48Address, ReactiveRoute>::iterator i = m_routes.find (destination); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
139 |
if ((i != m_routes.end ()) && (i->second.port == port)) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
140 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
141 |
for (unsigned int j = 0 ; j < i->second.precursors.size (); j ++) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
142 |
if (i->second.precursors[j] == precursor) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
143 |
{ |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
144 |
should_add = false; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
145 |
break; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
146 |
} |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
147 |
if (should_add) |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
148 |
i->second.precursors.push_back (precursor); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
149 |
} |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
150 |
std::map<uint32_t,ProactiveRoute>::iterator k = m_roots.find (port); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
151 |
if (k != m_roots.end ()) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
152 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
153 |
for (unsigned int j = 0 ; j < k->second.precursors.size (); j ++) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
154 |
if (k->second.precursors[j] == precursor) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
155 |
return; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
156 |
k->second.precursors.push_back (precursor); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
157 |
return; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
158 |
} |
4793 | 159 |
} |
160 |
||
161 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
162 |
HwmpRtable::DeleteProactivePath (uint32_t port) |
4793 | 163 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
164 |
std::map<uint32_t,ProactiveRoute>::iterator j = m_roots.find (port); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
165 |
if (j != m_roots.end ()) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
166 |
m_roots.erase (j); |
4793 | 167 |
|
168 |
} |
|
169 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
170 |
HwmpRtable::DeleteProactivePath (Mac48Address root, uint32_t port) |
4793 | 171 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
172 |
std::map<uint32_t,ProactiveRoute>::iterator j = m_roots.find (port); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
173 |
if ((j != m_roots.end ())&&(j->second.root == root)) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
174 |
m_roots.erase (j); |
4793 | 175 |
|
176 |
} |
|
177 |
||
178 |
void |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
179 |
HwmpRtable::DeleteReactivePath (Mac48Address destination, uint32_t port) |
4793 | 180 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
181 |
std::map<Mac48Address, ReactiveRoute>::iterator i = m_routes.find (destination); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
182 |
if (i != m_routes.end ()) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
183 |
if (i->second.port == port) |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
184 |
m_routes.erase (i); |
4793 | 185 |
} |
186 |
||
4797
9902003078aa
Removed unneeded word "struct", fixed mobility model, fixed random variable
Kirill Andreev <andreev@iitp.ru>
parents:
4793
diff
changeset
|
187 |
HwmpRtable::LookupResult |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
188 |
HwmpRtable::LookupReactive (Mac48Address destination) |
4793 | 189 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
190 |
LookupResult result; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
191 |
result.retransmitter = Mac48Address::GetBroadcast (); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
192 |
result.metric = MAX_METRIC; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
193 |
result.ifIndex = PORT_ANY; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
194 |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
195 |
std::map<Mac48Address, ReactiveRoute>::iterator i = m_routes.find (destination); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
196 |
if (i == m_routes.end ()) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
197 |
return result; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
198 |
result.ifIndex = i->second.port; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
199 |
//Seconds (0) means that this is routing |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
200 |
if (i->second.whenExpire < Simulator::Now ()) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
201 |
if (i->second.retransmitter != destination) |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
202 |
return result; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
203 |
result.retransmitter = i->second.retransmitter; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
204 |
result.metric = i->second.metric; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
205 |
result.seqnum = i->second.seqnum; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
206 |
return result; |
4793 | 207 |
} |
208 |
||
4797
9902003078aa
Removed unneeded word "struct", fixed mobility model, fixed random variable
Kirill Andreev <andreev@iitp.ru>
parents:
4793
diff
changeset
|
209 |
HwmpRtable::LookupResult |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
210 |
HwmpRtable::LookupProactive (uint32_t port) |
4793 | 211 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
212 |
LookupResult result; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
213 |
result.retransmitter = Mac48Address::GetBroadcast (); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
214 |
result.metric = MAX_METRIC; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
215 |
result.ifIndex = PORT_ANY; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
216 |
std::map<uint32_t, ProactiveRoute>::iterator i = m_roots.find (port); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
217 |
if (i == m_roots.end ()) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
218 |
return result; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
219 |
result.ifIndex = i->first; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
220 |
if (i->second.whenExpire < Simulator::Now ()) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
221 |
return result; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
222 |
result.retransmitter = i->second.retransmitter; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
223 |
result.metric = i->second.metric; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
224 |
result.seqnum = i->second.seqnum; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
225 |
return result; |
4793 | 226 |
} |
227 |
||
4797
9902003078aa
Removed unneeded word "struct", fixed mobility model, fixed random variable
Kirill Andreev <andreev@iitp.ru>
parents:
4793
diff
changeset
|
228 |
std::vector<HwmpRtable::FailedDestination> |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
229 |
HwmpRtable::GetUnreachableDestinations (Mac48Address peerAddress, uint32_t port) |
4793 | 230 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
231 |
std::vector<FailedDestination> retval; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
232 |
for (std::map<Mac48Address, ReactiveRoute>::iterator i = m_routes.begin (); i != m_routes.end(); i++) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
233 |
if ((i->second.retransmitter == peerAddress)&& (i->second.port == port)) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
234 |
{ |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
235 |
FailedDestination dst; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
236 |
dst.destination = i->first; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
237 |
i->second.seqnum ++; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
238 |
dst.seqnum = i->second.seqnum; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
239 |
retval.push_back (dst); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
240 |
} |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
241 |
/** |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
242 |
* Lookup a path to root |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
243 |
*/ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
244 |
std::map<uint32_t, ProactiveRoute>::iterator i = m_roots.find (port); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
245 |
if ((i != m_roots.end ())&&(i->second.retransmitter == peerAddress)) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
246 |
{ |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
247 |
FailedDestination dst; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
248 |
dst.destination = i->second.root; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
249 |
dst.seqnum = i->second.seqnum; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
250 |
retval.push_back (dst); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
251 |
} |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
252 |
return retval; |
4793 | 253 |
} |
254 |
uint32_t |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
255 |
HwmpRtable::RequestSeqnum (Mac48Address destination) |
4793 | 256 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
257 |
std::map<Mac48Address, ReactiveRoute>::iterator i = m_routes.find (destination); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
258 |
if (i == m_routes.end ()) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
259 |
return 0; |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
260 |
return i->second.seqnum; |
4793 | 261 |
} |
262 |
||
263 |
std::vector<Mac48Address> |
|
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
264 |
HwmpRtable::GetPrecursors (Mac48Address destination, uint32_t port) |
4793 | 265 |
{ |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
266 |
std::vector<Mac48Address> retval; |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
267 |
std::map<uint32_t, ProactiveRoute>::iterator root = m_roots.find (port); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
268 |
if ((root != m_roots.end ()) &&(root->second.root == destination)) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
269 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
270 |
for (unsigned int i = 0; i < root->second.precursors.size (); i ++) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
271 |
retval.push_back (root->second.precursors[i]); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
272 |
} |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
273 |
std::map<Mac48Address, ReactiveRoute>::iterator route = m_routes.find (destination); |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
274 |
if ( (route != m_routes.end ()) && (route->second.port == port) ) |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
275 |
{ |
4852
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
276 |
for (unsigned int i = 0; i < route->second.precursors.size (); i ++) |
123dc54d734e
Coding style changes: indentation (some fixes), spaces in operators, function
Andrey Mazo <mazo@iitp.ru>
parents:
4837
diff
changeset
|
277 |
retval.push_back (route->second.precursors[i]); |
4812
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
278 |
} |
adcb26652e1d
Coding style changes: indentation, spaces.
Andrey Mazo <mazo@iitp.ru>
parents:
4809
diff
changeset
|
279 |
return retval; |
4793 | 280 |
} |
281 |
||
282 |
}//namespace ns3 |