A Discrete-Event Network Simulator
API
olsr-state.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2004 Francisco J. Ros
4  * Copyright (c) 2007 INESC Porto
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Authors: Francisco J. Ros <fjrm@dif.um.es>
20  * Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
21  */
22 
24 
25 #ifndef OLSR_STATE_H
26 #define OLSR_STATE_H
27 
28 #include "olsr-repositories.h"
29 
30 namespace ns3 {
31 namespace olsr {
32 
35 class OlsrState
36 {
37  // friend class Olsr;
38 
39 protected:
50 
51 public:
53  {
54  }
55 
56  // MPR selector
57 
63  {
64  return m_mprSelectorSet;
65  }
66 
73 
78  void EraseMprSelectorTuple (const MprSelectorTuple &tuple);
79 
84  void EraseMprSelectorTuples (const Ipv4Address &mainAddr);
85 
90  void InsertMprSelectorTuple (const MprSelectorTuple &tuple);
91 
96  std::string PrintMprSelectorSet () const;
97 
98  // Neighbor
99 
104  const NeighborSet & GetNeighbors () const
105  {
106  return m_neighborSet;
107  }
113  {
114  return m_neighborSet;
115  }
116 
122  NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr);
123 
129  const NeighborTuple* FindSymNeighborTuple (const Ipv4Address &mainAddr) const;
130 
137  NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr,
138  uint8_t willingness);
139 
144  void EraseNeighborTuple (const NeighborTuple &neighborTuple);
149  void EraseNeighborTuple (const Ipv4Address &mainAddr);
150 
155  void InsertNeighborTuple (const NeighborTuple &tuple);
156 
157  // Two-hop neighbor
158 
164  {
165  return m_twoHopNeighborSet;
166  }
172  {
173  return m_twoHopNeighborSet;
174  }
175 
183  const Ipv4Address &twoHopNeighbor);
184 
189  void EraseTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
194  void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor);
200  void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor,
201  const Ipv4Address &twoHopNeighbor);
207 
208  // MPR
209 
215  bool FindMprAddress (const Ipv4Address &address);
216 
221  void SetMprSet (MprSet mprSet);
222 
227  MprSet GetMprSet () const;
228 
229  // Duplicate
230 
238  uint16_t sequenceNumber);
239 
244  void EraseDuplicateTuple (const DuplicateTuple &tuple);
249  void InsertDuplicateTuple (const DuplicateTuple &tuple);
250 
251  // Link
252 
257  const LinkSet & GetLinks () const
258  {
259  return m_linkSet;
260  }
266  LinkTuple* FindLinkTuple (const Ipv4Address &ifaceAddr);
273  LinkTuple* FindSymLinkTuple (const Ipv4Address &ifaceAddr, Time time);
278  void EraseLinkTuple (const LinkTuple &tuple);
284  LinkTuple& InsertLinkTuple (const LinkTuple &tuple);
285 
286  // Topology
287 
292  const TopologySet & GetTopologySet () const
293  {
294  return m_topologySet;
295  }
302  TopologyTuple* FindTopologyTuple (const Ipv4Address &destAddr,
303  const Ipv4Address &lastAddr);
311  uint16_t ansn);
316  void EraseTopologyTuple (const TopologyTuple &tuple);
322  void EraseOlderTopologyTuples (const Ipv4Address &lastAddr,
323  uint16_t ansn);
328  void InsertTopologyTuple (const TopologyTuple &tuple);
329 
330  // Interface association
331 
337  {
338  return m_ifaceAssocSet;
339  }
345  {
346  return m_ifaceAssocSet;
347  }
348 
354  IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr);
360  const IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr) const;
365  void EraseIfaceAssocTuple (const IfaceAssocTuple &tuple);
370  void InsertIfaceAssocTuple (const IfaceAssocTuple &tuple);
371 
372  // Host-Network Association
377  const AssociationSet & GetAssociationSet () const // Associations known to the node
378  {
379  return m_associationSet;
380  }
381 
386  const Associations & GetAssociations () const // Set of associations that the node has
387  {
388  return m_associations;
389  }
390 
398  AssociationTuple* FindAssociationTuple (const Ipv4Address &gatewayAddr, \
399  const Ipv4Address &networkAddr, \
400  const Ipv4Mask &netmask);
405  void EraseAssociationTuple (const AssociationTuple &tuple);
410  void InsertAssociationTuple (const AssociationTuple &tuple);
415  void EraseAssociation (const Association &tuple);
420  void InsertAssociation (const Association &tuple);
421 
428  std::vector<Ipv4Address>
429  FindNeighborInterfaces (const Ipv4Address &neighborMainAddr) const;
430 
431 };
432 
433 }
434 } // namespace olsr,ns3
435 
436 #endif /* OLSR_STATE_H */
std::vector< TopologyTuple > TopologySet
Topology Set type.
An MPR-Selector Tuple.
const MprSelectorSet & GetMprSelectors() const
Gets the MPR selectors.
Definition: olsr-state.h:62
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
IfaceAssocSet & GetIfaceAssocSetMutable()
Gets a mutable reference to the interface association set.
Definition: olsr-state.h:344
AssociationSet m_associationSet
Association Set (RFC 3626, section12.2).
Definition: olsr-state.h:48
TwoHopNeighborTuple * FindTwoHopNeighborTuple(const Ipv4Address &neighbor, const Ipv4Address &twoHopNeighbor)
Finds a 2-hop neighbor tuple.
Definition: olsr-state.cc:200
std::vector< Association > Associations
Association Set type.
void EraseMprSelectorTuples(const Ipv4Address &mainAddr)
Erases all MPR selector tuples belonging to the same address.
Definition: olsr-state.cc:66
void InsertAssociationTuple(const AssociationTuple &tuple)
Inserts a known association tuple.
Definition: olsr-state.cc:549
const Associations & GetAssociations() const
Gets the association set the node has.
Definition: olsr-state.h:386
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
const NeighborTuple * FindSymNeighborTuple(const Ipv4Address &mainAddr) const
Finds a symmetrical neighbor tuple.
Definition: olsr-state.cc:126
std::string PrintMprSelectorSet() const
Prints the MPR selector sets.
Definition: olsr-state.cc:89
void InsertNeighborTuple(const NeighborTuple &tuple)
Inserts a neighbor tuple.
Definition: olsr-state.cc:182
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:504
TwoHopNeighborSet m_twoHopNeighborSet
2-hop Neighbor Set (RFC 3626, section 4.3.2).
Definition: olsr-state.h:42
void SetMprSet(MprSet mprSet)
Sets the MPR set to the one specified.
Definition: olsr-state.cc:281
bool FindMprAddress(const Ipv4Address &address)
Checks if there's an MPR with a specific address.
Definition: olsr-state.cc:274
void InsertMprSelectorTuple(const MprSelectorTuple &tuple)
Inserts a MPR selector tuple.
Definition: olsr-state.cc:83
NeighborTuple * FindNeighborTuple(const Ipv4Address &mainAddr)
Finds a neighbor tuple.
Definition: olsr-state.cc:112
void EraseIfaceAssocTuple(const IfaceAssocTuple &tuple)
Erases a interface association tuple.
Definition: olsr-state.cc:484
LinkTuple * FindSymLinkTuple(const Ipv4Address &ifaceAddr, Time time)
Finds a symmetrical link tuple.
Definition: olsr-state.cc:344
LinkTuple * FindLinkTuple(const Ipv4Address &ifaceAddr)
Finds a link tuple.
Definition: olsr-state.cc:330
void EraseDuplicateTuple(const DuplicateTuple &tuple)
Erases a duplicate tuple.
Definition: olsr-state.cc:308
void EraseTopologyTuple(const TopologyTuple &tuple)
Erases a topology tuple.
Definition: olsr-state.cc:417
NeighborSet m_neighborSet
Neighbor Set (RFC 3626, section 4.3.1).
Definition: olsr-state.h:41
void EraseOlderTopologyTuples(const Ipv4Address &lastAddr, uint16_t ansn)
Erases a topology tuple.
Definition: olsr-state.cc:431
const TopologySet & GetTopologySet() const
Gets the topology set.
Definition: olsr-state.h:292
TopologyTuple * FindTopologyTuple(const Ipv4Address &destAddr, const Ipv4Address &lastAddr)
Finds a topology tuple.
Definition: olsr-state.cc:388
IfaceAssocSet m_ifaceAssocSet
Interface Association Set (RFC 3626, section 4.1).
Definition: olsr-state.h:47
const AssociationSet & GetAssociationSet() const
Gets the association set known to the node.
Definition: olsr-state.h:377
An Association Tuple.
IfaceAssocTuple * FindIfaceAssocTuple(const Ipv4Address &ifaceAddr)
Finds a interface association tuple.
Definition: olsr-state.cc:456
LinkSet m_linkSet
Link Set (RFC 3626, section 4.2.1).
Definition: olsr-state.h:40
void InsertDuplicateTuple(const DuplicateTuple &tuple)
Inserts a duplicate tuple.
Definition: olsr-state.cc:322
std::vector< LinkTuple > LinkSet
Link Set type.
std::vector< DuplicateTuple > DuplicateSet
Duplicate Set type.
MprSet GetMprSet() const
Gets the MPR set.
Definition: olsr-state.cc:286
void EraseLinkTuple(const LinkTuple &tuple)
Erases a link tuple.
Definition: olsr-state.cc:365
std::vector< IfaceAssocTuple > IfaceAssocSet
Interface Association Set type.
AssociationTuple * FindAssociationTuple(const Ipv4Address &gatewayAddr, const Ipv4Address &networkAddr, const Ipv4Mask &netmask)
Finds an association tuple.
Definition: olsr-state.cc:521
void InsertIfaceAssocTuple(const IfaceAssocTuple &tuple)
Inserts a interface association tuple.
Definition: olsr-state.cc:498
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const NeighborSet & GetNeighbors() const
Gets the neighbor set.
Definition: olsr-state.h:104
NeighborSet & GetNeighbors()
Gets the neighbor set.
Definition: olsr-state.h:112
This class encapsulates all data structures needed for maintaining internal state of an OLSR node...
Definition: olsr-state.h:35
MprSelectorTuple * FindMprSelectorTuple(const Ipv4Address &mainAddr)
Finds a MPR selector tuple.
Definition: olsr-state.cc:38
DuplicateSet m_duplicateSet
Duplicate Set (RFC 3626, section 3.4).
Definition: olsr-state.h:46
Definition: olsr.py:1
void EraseAssociationTuple(const AssociationTuple &tuple)
Erases a known association tuple.
Definition: olsr-state.cc:535
TwoHopNeighborSet & GetTwoHopNeighbors()
Gets the 2-hop neighbor set.
Definition: olsr-state.h:171
Associations m_associations
The node's local Host Network Associations that will be advertised using HNA messages.
Definition: olsr-state.h:49
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
std::vector< NeighborTuple > NeighborSet
Neighbor Set type.
void EraseAssociation(const Association &tuple)
Erases an association.
Definition: olsr-state.cc:555
DuplicateTuple * FindDuplicateTuple(const Ipv4Address &address, uint16_t sequenceNumber)
Finds a duplicate tuple.
Definition: olsr-state.cc:294
void InsertTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Inserts a 2-hop neighbor tuple.
Definition: olsr-state.cc:266
const IfaceAssocSet & GetIfaceAssocSet() const
Gets the interface association set.
Definition: olsr-state.h:336
std::set< Ipv4Address > MprSet
MPR Set type.
const LinkSet & GetLinks() const
Gets the Link set.
Definition: olsr-state.h:257
std::vector< TwoHopNeighborTuple > TwoHopNeighborSet
2-hop Neighbor Set type.
void EraseTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Erases a 2-hop neighbor tuple.
Definition: olsr-state.cc:216
LinkTuple & InsertLinkTuple(const LinkTuple &tuple)
Inserts a link tuple.
Definition: olsr-state.cc:379
MprSet m_mprSet
MPR Set (RFC 3626, section 4.3.3).
Definition: olsr-state.h:44
std::vector< MprSelectorTuple > MprSelectorSet
MPR Selector Set type.
MprSelectorSet m_mprSelectorSet
MPR Selector Set (RFC 3626, section 4.3.4).
Definition: olsr-state.h:45
void EraseNeighborTuple(const NeighborTuple &neighborTuple)
Erases a neighbor tuple.
Definition: olsr-state.cc:154
tuple address
Definition: first.py:37
const TwoHopNeighborSet & GetTwoHopNeighbors() const
Gets the 2-hop neighbor set.
Definition: olsr-state.h:163
TopologyTuple * FindNewerTopologyTuple(const Ipv4Address &lastAddr, uint16_t ansn)
Finds a topology tuple.
Definition: olsr-state.cc:403
TopologySet m_topologySet
Topology Set (RFC 3626, section 4.4).
Definition: olsr-state.h:43
An Interface Association Tuple.
void EraseMprSelectorTuple(const MprSelectorTuple &tuple)
Erases a MPR selector tuple.
Definition: olsr-state.cc:52
void InsertAssociation(const Association &tuple)
Inserts an association tuple.
Definition: olsr-state.cc:569
std::vector< AssociationTuple > AssociationSet
Association Set type.
void EraseTwoHopNeighborTuples(const Ipv4Address &neighbor)
Erases the 2-hop neighbor tuples with the same 1-hop neighbor.
Definition: olsr-state.cc:249
void InsertTopologyTuple(const TopologyTuple &tuple)
Inserts a topology tuple.
Definition: olsr-state.cc:448