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