A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
olsr-state.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2004 Francisco J. Ros
3 * Copyright (c) 2007 INESC Porto
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
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 * Authors: Francisco J. Ros <fjrm@dif.um.es>
19 * Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
20 */
21
22#ifndef OLSR_STATE_H
23#define OLSR_STATE_H
24
25#include "olsr-repositories.h"
26
27namespace ns3
28{
29namespace olsr
30{
31
32/// \ingroup olsr
33/// This class encapsulates all data structures needed for maintaining internal state of an OLSR
34/// node.
36{
37 // friend class Olsr;
38
39 protected:
40 LinkSet m_linkSet; //!< Link Set (\RFC{3626}, section 4.2.1).
41 NeighborSet m_neighborSet; //!< Neighbor Set (\RFC{3626}, section 4.3.1).
42 TwoHopNeighborSet m_twoHopNeighborSet; //!< 2-hop Neighbor Set (\RFC{3626}, section 4.3.2).
43 TopologySet m_topologySet; //!< Topology Set (\RFC{3626}, section 4.4).
44 MprSet m_mprSet; //!< MPR Set (\RFC{3626}, section 4.3.3).
45 MprSelectorSet m_mprSelectorSet; //!< MPR Selector Set (\RFC{3626}, section 4.3.4).
46 DuplicateSet m_duplicateSet; //!< Duplicate Set (\RFC{3626}, section 3.4).
47 IfaceAssocSet m_ifaceAssocSet; //!< Interface Association Set (\RFC{3626}, section 4.1).
48 AssociationSet m_associationSet; //!< Association Set (\RFC{3626}, section12.2). Associations
49 //!< obtained from HNA messages generated by other nodes.
50 Associations m_associations; //!< The node's local Host Network Associations that will be
51 //!< advertised using HNA messages.
52
53 public:
55 {
56 }
57
58 // MPR selector
59
60 /**
61 * Gets the MPR selectors.
62 * \returns The MPR selectors.
63 */
65 {
66 return m_mprSelectorSet;
67 }
68
69 /**
70 * Finds a MPR selector tuple.
71 * \param mainAddr The MPR selector main address.
72 * \returns The MPR selector, if found. Else it returns a null pointer.
73 */
75
76 /**
77 * Erases a MPR selector tuple.
78 * \param tuple The MPR selector tuple.
79 */
80 void EraseMprSelectorTuple(const MprSelectorTuple& tuple);
81
82 /**
83 * Erases all MPR selector tuples belonging to the same address.
84 * \param mainAddr The MPR selector main address.
85 */
86 void EraseMprSelectorTuples(const Ipv4Address& mainAddr);
87
88 /**
89 * Inserts a MPR selector tuple
90 * \param tuple The MPR selector tuple.
91 */
93
94 /**
95 * Prints the MPR selector sets.
96 * \return a string with the output data.
97 */
98 std::string PrintMprSelectorSet() const;
99
100 // Neighbor
101
102 /**
103 * Gets the neighbor set.
104 * \returns The neighbor set.
105 */
107 {
108 return m_neighborSet;
109 }
110
111 /**
112 * Gets the neighbor set.
113 * \returns The neighbor set.
114 */
116 {
117 return m_neighborSet;
118 }
119
120 /**
121 * Finds a neighbor tuple.
122 * \param mainAddr The neighbor tuple main address.
123 * \returns The neighbor tuple, if found. Else it returns a null pointer.
124 */
126
127 /**
128 * Finds a symmetrical neighbor tuple.
129 * \param mainAddr The neighbor tuple main address.
130 * \returns The neighbor tuple, if found. Else it returns a null pointer.
131 */
132 const NeighborTuple* FindSymNeighborTuple(const Ipv4Address& mainAddr) const;
133
134 /**
135 * Finds a neighbor tuple.
136 * \param mainAddr The neighbor tuple main address.
137 * \param willingness The neighbor willingness.
138 * \returns The neighbor tuple, if found. Else it returns a null pointer.
139 */
140 NeighborTuple* FindNeighborTuple(const Ipv4Address& mainAddr, Willingness willingness);
141
142 /**
143 * Erases a neighbor tuple.
144 * \param neighborTuple The neighbor tuple.
145 */
146 void EraseNeighborTuple(const NeighborTuple& neighborTuple);
147 /**
148 * Erases a neighbor tuple.
149 * \param mainAddr The neighbor tuple main address.
150 */
151 void EraseNeighborTuple(const Ipv4Address& mainAddr);
152
153 /**
154 * Inserts a neighbor tuple.
155 * \param tuple The neighbor tuple.
156 */
157 void InsertNeighborTuple(const NeighborTuple& tuple);
158
159 // Two-hop neighbor
160
161 /**
162 * Gets the 2-hop neighbor set.
163 * \returns The 2-hop neighbor set.
164 */
166 {
167 return m_twoHopNeighborSet;
168 }
169
170 /**
171 * Gets the 2-hop neighbor set.
172 * \returns The 2-hop neighbor set.
173 */
175 {
176 return m_twoHopNeighborSet;
177 }
178
179 /**
180 * Finds a 2-hop neighbor tuple.
181 * \param neighbor The neighbor main address.
182 * \param twoHopNeighbor The 2-hop neighbor main address.
183 * \returns The 2-hop neighbor tuple, if found. Else it returns a null pointer.
184 */
186 const Ipv4Address& twoHopNeighbor);
187
188 /**
189 * Erases a 2-hop neighbor tuple.
190 * \param tuple The 2-hop neighbor tuple.
191 */
193 /**
194 * Erases the 2-hop neighbor tuples with the same 1-hop neighbor.
195 * \param neighbor The neighbor address.
196 */
197 void EraseTwoHopNeighborTuples(const Ipv4Address& neighbor);
198 /**
199 * Erases the 2-hop neighbor tuples with matching predicates.
200 * \param neighbor The neighbor address.
201 * \param twoHopNeighbor The 2-hop neighbor main address.
202 */
203 void EraseTwoHopNeighborTuples(const Ipv4Address& neighbor, const Ipv4Address& twoHopNeighbor);
204 /**
205 * Inserts a 2-hop neighbor tuple.
206 * \param tuple The 2-hop neighbor tuple.
207 */
209
210 // MPR
211
212 /**
213 * Checks if there's an MPR with a specific address.
214 * \param address The address to test.
215 * \return True if a MPR with the specified address exists.
216 */
217 bool FindMprAddress(const Ipv4Address& address);
218
219 /**
220 * Sets the MPR set to the one specified.
221 * \param mprSet The new MPR set.
222 */
223 void SetMprSet(MprSet mprSet);
224
225 /**
226 * Gets the MPR set.
227 * \return The MPR set.
228 */
229 MprSet GetMprSet() const;
230
231 // Duplicate
232
233 /**
234 * Finds a duplicate tuple.
235 * \param address The duplicate tuple address.
236 * \param sequenceNumber The duplicate tuple sequence number.
237 * \returns The duplicate tuple, or a null pointer if no match.
238 */
239 DuplicateTuple* FindDuplicateTuple(const Ipv4Address& address, uint16_t sequenceNumber);
240
241 /**
242 * Erases a duplicate tuple.
243 * \param tuple The tuple to erase.
244 */
245 void EraseDuplicateTuple(const DuplicateTuple& tuple);
246 /**
247 * Inserts a duplicate tuple.
248 * \param tuple The tuple to insert.
249 */
250 void InsertDuplicateTuple(const DuplicateTuple& tuple);
251
252 // Link
253
254 /**
255 * Gets the Link set.
256 * \return The Link set.
257 */
258 const LinkSet& GetLinks() const
259 {
260 return m_linkSet;
261 }
262
263 /**
264 * Finds a link tuple.
265 * \param ifaceAddr The interface address of the link.
266 * \returns The link tuple, or a null pointer if no match.
267 */
268 LinkTuple* FindLinkTuple(const Ipv4Address& ifaceAddr);
269 /**
270 * Finds a symmetrical link tuple.
271 * \param ifaceAddr The interface address of the link.
272 * \param time The time at which the link should be considered symmetrical.
273 * \returns The link tuple, or a null pointer if no match.
274 */
275 LinkTuple* FindSymLinkTuple(const Ipv4Address& ifaceAddr, Time time);
276 /**
277 * Erases a link tuple.
278 * \param tuple The tuple to erase.
279 */
280 void EraseLinkTuple(const LinkTuple& tuple);
281 /**
282 * Inserts a link tuple.
283 * \param tuple The tuple to insert.
284 * \returns A reference to the inserted tuple.
285 */
286 LinkTuple& InsertLinkTuple(const LinkTuple& tuple);
287
288 // Topology
289
290 /**
291 * Gets the topology set.
292 * \returns The topology set.
293 */
295 {
296 return m_topologySet;
297 }
298
299 /**
300 * Finds a topology tuple.
301 * \param destAddr The destination address.
302 * \param lastAddr The address of the node previous to the destination.
303 * \returns The topology tuple, or a null pointer if no match.
304 */
305 TopologyTuple* FindTopologyTuple(const Ipv4Address& destAddr, const Ipv4Address& lastAddr);
306 /**
307 * Finds a topology tuple.
308 * \param lastAddr The address of the node previous to the destination.
309 * \param ansn The Advertised Neighbor Sequence Number.
310 * \returns The topology tuple, or a null pointer if no match.
311 */
312 TopologyTuple* FindNewerTopologyTuple(const Ipv4Address& lastAddr, uint16_t ansn);
313 /**
314 * Erases a topology tuple.
315 * \param tuple The tuple to erase.
316 */
317 void EraseTopologyTuple(const TopologyTuple& tuple);
318 /**
319 * Erases a topology tuple.
320 * \param lastAddr The address of the node previous to the destination.
321 * \param ansn The Advertised Neighbor Sequence Number.
322 */
323 void EraseOlderTopologyTuples(const Ipv4Address& lastAddr, uint16_t ansn);
324 /**
325 * Inserts a topology tuple.
326 * \param tuple The tuple to insert.
327 */
328 void InsertTopologyTuple(const TopologyTuple& tuple);
329
330 // Interface association
331
332 /**
333 * Gets the interface association set.
334 * \returns The interface association set.
335 */
337 {
338 return m_ifaceAssocSet;
339 }
340
341 /**
342 * Gets a mutable reference to the interface association set.
343 * \returns The interface association set.
344 */
346 {
347 return m_ifaceAssocSet;
348 }
349
350 /**
351 * Finds a interface association tuple.
352 * \param ifaceAddr The interface address.
353 * \returns The interface association tuple, or a null pointer if no match.
354 */
356 /**
357 * Finds a interface association tuple.
358 * \param ifaceAddr The interface address.
359 * \returns The interface association tuple, or a null pointer if no match.
360 */
361 const IfaceAssocTuple* FindIfaceAssocTuple(const Ipv4Address& ifaceAddr) const;
362 /**
363 * Erases a interface association tuple.
364 * \param tuple The tuple to erase.
365 */
366 void EraseIfaceAssocTuple(const IfaceAssocTuple& tuple);
367 /**
368 * Inserts a interface association tuple.
369 * \param tuple The tuple to insert.
370 */
371 void InsertIfaceAssocTuple(const IfaceAssocTuple& tuple);
372
373 // Host-Network Association
374 /**
375 * Gets the association set known to the node.
376 * \returns The association set known to the node.
377 */
378 const AssociationSet& GetAssociationSet() const // Associations known to the node
379 {
380 return m_associationSet;
381 }
382
383 /**
384 * Gets the association set the node has.
385 * \returns The association set the node has.
386 */
387 const Associations& GetAssociations() const // Set of associations that the node has
388 {
389 return m_associations;
390 }
391
392 /**
393 * Finds an association tuple.
394 * \param gatewayAddr The gateway address.
395 * \param networkAddr The network address.
396 * \param netmask The network mask.
397 * \returns The association tuple, or a null pointer if no match.
398 */
400 const Ipv4Address& networkAddr,
401 const Ipv4Mask& netmask);
402 /**
403 * Erases a known association tuple.
404 * \param tuple The tuple to erase.
405 */
406 void EraseAssociationTuple(const AssociationTuple& tuple);
407 /**
408 * Inserts a known association tuple.
409 * \param tuple The tuple to insert.
410 */
411 void InsertAssociationTuple(const AssociationTuple& tuple);
412 /**
413 * Erases an association.
414 * \param tuple The tuple to erase.
415 */
416 void EraseAssociation(const Association& tuple);
417 /**
418 * Inserts an association tuple.
419 * \param tuple The tuple to insert.
420 */
421 void InsertAssociation(const Association& tuple);
422
423 /**
424 * Returns a vector of all interfaces of a given neighbor, with the
425 * exception of the "main" one.
426 * \param neighborMainAddr The neighbor main address
427 * \returns A container of the neighbor addresses (excluding the main one).
428 */
429 std::vector<Ipv4Address> FindNeighborInterfaces(const Ipv4Address& neighborMainAddr) const;
430};
431
432} // namespace olsr
433} // namespace ns3
434
435#endif /* OLSR_STATE_H */
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
This class encapsulates all data structures needed for maintaining internal state of an OLSR node.
Definition: olsr-state.h:36
MprSet GetMprSet() const
Gets the MPR set.
Definition: olsr-state.cc:272
TwoHopNeighborSet & GetTwoHopNeighbors()
Gets the 2-hop neighbor set.
Definition: olsr-state.h:174
void EraseAssociation(const Association &tuple)
Erases an association.
Definition: olsr-state.cc:528
const NeighborSet & GetNeighbors() const
Gets the neighbor set.
Definition: olsr-state.h:106
AssociationSet m_associationSet
Association Set (RFC 3626, section12.2).
Definition: olsr-state.h:48
void EraseIfaceAssocTuple(const IfaceAssocTuple &tuple)
Erases a interface association tuple.
Definition: olsr-state.cc:458
void InsertTopologyTuple(const TopologyTuple &tuple)
Inserts a topology tuple.
Definition: olsr-state.cc:424
IfaceAssocTuple * FindIfaceAssocTuple(const Ipv4Address &ifaceAddr)
Finds a interface association tuple.
Definition: olsr-state.cc:432
std::string PrintMprSelectorSet() const
Prints the MPR selector sets.
Definition: olsr-state.cc:86
LinkSet m_linkSet
Link Set (RFC 3626, section 4.2.1).
Definition: olsr-state.h:40
TwoHopNeighborTuple * FindTwoHopNeighborTuple(const Ipv4Address &neighbor, const Ipv4Address &twoHopNeighbor)
Finds a 2-hop neighbor tuple.
Definition: olsr-state.cc:189
void EraseTwoHopNeighborTuples(const Ipv4Address &neighbor)
Erases the 2-hop neighbor tuples with the same 1-hop neighbor.
Definition: olsr-state.cc:235
void InsertAssociation(const Association &tuple)
Inserts an association tuple.
Definition: olsr-state.cc:541
LinkTuple * FindSymLinkTuple(const Ipv4Address &ifaceAddr, Time time)
Finds a symmetrical link tuple.
Definition: olsr-state.cc:327
const NeighborTuple * FindSymNeighborTuple(const Ipv4Address &mainAddr) const
Finds a symmetrical neighbor tuple.
Definition: olsr-state.cc:120
IfaceAssocSet & GetIfaceAssocSetMutable()
Gets a mutable reference to the interface association set.
Definition: olsr-state.h:345
DuplicateSet m_duplicateSet
Duplicate Set (RFC 3626, section 3.4).
Definition: olsr-state.h:46
IfaceAssocSet m_ifaceAssocSet
Interface Association Set (RFC 3626, section 4.1).
Definition: olsr-state.h:47
void EraseNeighborTuple(const NeighborTuple &neighborTuple)
Erases a neighbor tuple.
Definition: olsr-state.cc:146
TopologyTuple * FindNewerTopologyTuple(const Ipv4Address &lastAddr, uint16_t ansn)
Finds a topology tuple.
Definition: olsr-state.cc:382
void InsertDuplicateTuple(const DuplicateTuple &tuple)
Inserts a duplicate tuple.
Definition: olsr-state.cc:306
const TopologySet & GetTopologySet() const
Gets the topology set.
Definition: olsr-state.h:294
const LinkSet & GetLinks() const
Gets the Link set.
Definition: olsr-state.h:258
Associations m_associations
The node's local Host Network Associations that will be advertised using HNA messages.
Definition: olsr-state.h:50
void EraseMprSelectorTuples(const Ipv4Address &mainAddr)
Erases all MPR selector tuples belonging to the same address.
Definition: olsr-state.cc:64
const TwoHopNeighborSet & GetTwoHopNeighbors() const
Gets the 2-hop neighbor set.
Definition: olsr-state.h:165
MprSelectorTuple * FindMprSelectorTuple(const Ipv4Address &mainAddr)
Finds a MPR selector tuple.
Definition: olsr-state.cc:38
void SetMprSet(MprSet mprSet)
Sets the MPR set to the one specified.
Definition: olsr-state.cc:266
void EraseAssociationTuple(const AssociationTuple &tuple)
Erases a known association tuple.
Definition: olsr-state.cc:509
void InsertNeighborTuple(const NeighborTuple &tuple)
Inserts a neighbor tuple.
Definition: olsr-state.cc:172
NeighborSet m_neighborSet
Neighbor Set (RFC 3626, section 4.3.1).
Definition: olsr-state.h:41
TopologyTuple * FindTopologyTuple(const Ipv4Address &destAddr, const Ipv4Address &lastAddr)
Finds a topology tuple.
Definition: olsr-state.cc:369
TwoHopNeighborSet m_twoHopNeighborSet
2-hop Neighbor Set (RFC 3626, section 4.3.2).
Definition: olsr-state.h:42
NeighborSet & GetNeighbors()
Gets the neighbor set.
Definition: olsr-state.h:115
AssociationTuple * FindAssociationTuple(const Ipv4Address &gatewayAddr, const Ipv4Address &networkAddr, const Ipv4Mask &netmask)
Finds an association tuple.
Definition: olsr-state.cc:493
std::vector< Ipv4Address > FindNeighborInterfaces(const Ipv4Address &neighborMainAddr) const
Returns a vector of all interfaces of a given neighbor, with the exception of the "main" one.
Definition: olsr-state.cc:477
bool FindMprAddress(const Ipv4Address &address)
Checks if there's an MPR with a specific address.
Definition: olsr-state.cc:259
void EraseLinkTuple(const LinkTuple &tuple)
Erases a link tuple.
Definition: olsr-state.cc:347
DuplicateTuple * FindDuplicateTuple(const Ipv4Address &address, uint16_t sequenceNumber)
Finds a duplicate tuple.
Definition: olsr-state.cc:280
void InsertTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Inserts a 2-hop neighbor tuple.
Definition: olsr-state.cc:251
const AssociationSet & GetAssociationSet() const
Gets the association set known to the node.
Definition: olsr-state.h:378
LinkTuple * FindLinkTuple(const Ipv4Address &ifaceAddr)
Finds a link tuple.
Definition: olsr-state.cc:314
const IfaceAssocSet & GetIfaceAssocSet() const
Gets the interface association set.
Definition: olsr-state.h:336
const Associations & GetAssociations() const
Gets the association set the node has.
Definition: olsr-state.h:387
void InsertAssociationTuple(const AssociationTuple &tuple)
Inserts a known association tuple.
Definition: olsr-state.cc:522
MprSet m_mprSet
MPR Set (RFC 3626, section 4.3.3).
Definition: olsr-state.h:44
void InsertMprSelectorTuple(const MprSelectorTuple &tuple)
Inserts a MPR selector tuple.
Definition: olsr-state.cc:80
LinkTuple & InsertLinkTuple(const LinkTuple &tuple)
Inserts a link tuple.
Definition: olsr-state.cc:360
MprSelectorSet m_mprSelectorSet
MPR Selector Set (RFC 3626, section 4.3.4).
Definition: olsr-state.h:45
void EraseTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Erases a 2-hop neighbor tuple.
Definition: olsr-state.cc:204
void InsertIfaceAssocTuple(const IfaceAssocTuple &tuple)
Inserts a interface association tuple.
Definition: olsr-state.cc:471
void EraseTopologyTuple(const TopologyTuple &tuple)
Erases a topology tuple.
Definition: olsr-state.cc:395
NeighborTuple * FindNeighborTuple(const Ipv4Address &mainAddr)
Finds a neighbor tuple.
Definition: olsr-state.cc:107
void EraseOlderTopologyTuples(const Ipv4Address &lastAddr, uint16_t ansn)
Erases a topology tuple.
Definition: olsr-state.cc:408
void EraseDuplicateTuple(const DuplicateTuple &tuple)
Erases a duplicate tuple.
Definition: olsr-state.cc:293
TopologySet m_topologySet
Topology Set (RFC 3626, section 4.4).
Definition: olsr-state.h:43
const MprSelectorSet & GetMprSelectors() const
Gets the MPR selectors.
Definition: olsr-state.h:64
void EraseMprSelectorTuple(const MprSelectorTuple &tuple)
Erases a MPR selector tuple.
Definition: olsr-state.cc:51
Willingness
Willingness for forwarding packets from other nodes.
std::vector< MprSelectorTuple > MprSelectorSet
MPR Selector Set type.
std::vector< AssociationTuple > AssociationSet
Association Set type.
std::vector< TwoHopNeighborTuple > TwoHopNeighborSet
2-hop Neighbor Set type.
std::vector< LinkTuple > LinkSet
Link Set type.
std::vector< Association > Associations
Association Set type.
std::vector< TopologyTuple > TopologySet
Topology Set type.
std::set< Ipv4Address > MprSet
MPR Set type.
std::vector< DuplicateTuple > DuplicateSet
Duplicate Set type.
std::vector< NeighborTuple > NeighborSet
Neighbor Set type.
std::vector< IfaceAssocTuple > IfaceAssocSet
Interface Association Set type.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Definition: olsr.py:1
An Interface Association Tuple.
An MPR-Selector Tuple.