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 
23 
24 #ifndef OLSR_STATE_H
25 #define OLSR_STATE_H
26 
27 #include "olsr-repositories.h"
28 
29 namespace ns3 {
30 namespace olsr {
31 
34 class OlsrState
35 {
36  // friend class Olsr;
37 
38 protected:
49 
50 public:
52  {
53  }
54 
55  // MPR selector
56 
62  {
63  return m_mprSelectorSet;
64  }
65 
72 
77  void EraseMprSelectorTuple (const MprSelectorTuple &tuple);
78 
83  void EraseMprSelectorTuples (const Ipv4Address &mainAddr);
84 
89  void InsertMprSelectorTuple (const MprSelectorTuple &tuple);
90 
95  std::string PrintMprSelectorSet () const;
96 
97  // Neighbor
98 
103  const NeighborSet & GetNeighbors () const
104  {
105  return m_neighborSet;
106  }
112  {
113  return m_neighborSet;
114  }
115 
121  NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr);
122 
128  const NeighborTuple* FindSymNeighborTuple (const Ipv4Address &mainAddr) const;
129 
136  NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr,
137  uint8_t willingness);
138 
143  void EraseNeighborTuple (const NeighborTuple &neighborTuple);
148  void EraseNeighborTuple (const Ipv4Address &mainAddr);
149 
154  void InsertNeighborTuple (const NeighborTuple &tuple);
155 
156  // Two-hop neighbor
157 
163  {
164  return m_twoHopNeighborSet;
165  }
171  {
172  return m_twoHopNeighborSet;
173  }
174 
182  const Ipv4Address &twoHopNeighbor);
183 
188  void EraseTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
193  void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor);
199  void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor,
200  const Ipv4Address &twoHopNeighbor);
206 
207  // MPR
208 
214  bool FindMprAddress (const Ipv4Address &address);
215 
220  void SetMprSet (MprSet mprSet);
221 
226  MprSet GetMprSet () const;
227 
228  // Duplicate
229 
237  uint16_t sequenceNumber);
238 
243  void EraseDuplicateTuple (const DuplicateTuple &tuple);
248  void InsertDuplicateTuple (const DuplicateTuple &tuple);
249 
250  // Link
251 
256  const LinkSet & GetLinks () const
257  {
258  return m_linkSet;
259  }
265  LinkTuple* FindLinkTuple (const Ipv4Address &ifaceAddr);
272  LinkTuple* FindSymLinkTuple (const Ipv4Address &ifaceAddr, Time time);
277  void EraseLinkTuple (const LinkTuple &tuple);
283  LinkTuple& InsertLinkTuple (const LinkTuple &tuple);
284 
285  // Topology
286 
291  const TopologySet & GetTopologySet () const
292  {
293  return m_topologySet;
294  }
301  TopologyTuple* FindTopologyTuple (const Ipv4Address &destAddr,
302  const Ipv4Address &lastAddr);
310  uint16_t ansn);
315  void EraseTopologyTuple (const TopologyTuple &tuple);
321  void EraseOlderTopologyTuples (const Ipv4Address &lastAddr,
322  uint16_t ansn);
327  void InsertTopologyTuple (const TopologyTuple &tuple);
328 
329  // Interface association
330 
336  {
337  return m_ifaceAssocSet;
338  }
344  {
345  return m_ifaceAssocSet;
346  }
347 
353  IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr);
359  const IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr) const;
364  void EraseIfaceAssocTuple (const IfaceAssocTuple &tuple);
369  void InsertIfaceAssocTuple (const IfaceAssocTuple &tuple);
370 
371  // Host-Network Association
376  const AssociationSet & GetAssociationSet () const // Associations known to the node
377  {
378  return m_associationSet;
379  }
380 
385  const Associations & GetAssociations () const // Set of associations that the node has
386  {
387  return m_associations;
388  }
389 
397  AssociationTuple* FindAssociationTuple (const Ipv4Address &gatewayAddr, \
398  const Ipv4Address &networkAddr, \
399  const Ipv4Mask &netmask);
404  void EraseAssociationTuple (const AssociationTuple &tuple);
409  void InsertAssociationTuple (const AssociationTuple &tuple);
414  void EraseAssociation (const Association &tuple);
419  void InsertAssociation (const Association &tuple);
420 
427  std::vector<Ipv4Address>
428  FindNeighborInterfaces (const Ipv4Address &neighborMainAddr) const;
429 
430 };
431 
432 }
433 } // namespace olsr,ns3
434 
435 #endif /* OLSR_STATE_H */
std::vector< TopologyTuple > TopologySet
Topology Set type.
An MPR-Selector Tuple.
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:343
AssociationSet m_associationSet
Association Set (RFC 3626, section12.2).
Definition: olsr-state.h:47
const TopologySet & GetTopologySet() const
Gets the topology set.
Definition: olsr-state.h:291
TwoHopNeighborTuple * FindTwoHopNeighborTuple(const Ipv4Address &neighbor, const Ipv4Address &twoHopNeighbor)
Finds a 2-hop neighbor tuple.
Definition: olsr-state.cc:200
const TwoHopNeighborSet & GetTwoHopNeighbors() const
Gets the 2-hop neighbor set.
Definition: olsr-state.h:162
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
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:258
void InsertNeighborTuple(const NeighborTuple &tuple)
Inserts a neighbor tuple.
Definition: olsr-state.cc:182
TwoHopNeighborSet m_twoHopNeighborSet
2-hop Neighbor Set (RFC 3626, section 4.3.2).
Definition: olsr-state.h:41
MprSet GetMprSet() const
Gets the MPR set.
Definition: olsr-state.cc:286
void SetMprSet(MprSet mprSet)
Sets the MPR set to the one specified.
Definition: olsr-state.cc:281
const IfaceAssocSet & GetIfaceAssocSet() const
Gets the interface association set.
Definition: olsr-state.h:335
bool FindMprAddress(const Ipv4Address &address)
Checks if there&#39;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
const NeighborSet & GetNeighbors() const
Gets the neighbor set.
Definition: olsr-state.h:103
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
const NeighborTuple * FindSymNeighborTuple(const Ipv4Address &mainAddr) const
Finds a symmetrical neighbor tuple.
Definition: olsr-state.cc:126
const LinkSet & GetLinks() const
Gets the Link set.
Definition: olsr-state.h:256
const MprSelectorSet & GetMprSelectors() const
Gets the MPR selectors.
Definition: olsr-state.h:61
NeighborSet m_neighborSet
Neighbor Set (RFC 3626, section 4.3.1).
Definition: olsr-state.h:40
void EraseOlderTopologyTuples(const Ipv4Address &lastAddr, uint16_t ansn)
Erases a topology tuple.
Definition: olsr-state.cc:431
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:46
An Association Tuple.
std::string PrintMprSelectorSet() const
Prints the MPR selector sets.
Definition: olsr-state.cc:89
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:39
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.
void EraseLinkTuple(const LinkTuple &tuple)
Erases a link tuple.
Definition: olsr-state.cc:365
const Associations & GetAssociations() const
Gets the association set the node has.
Definition: olsr-state.h:385
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
const AssociationSet & GetAssociationSet() const
Gets the association set known to the node.
Definition: olsr-state.h:376
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
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.
address
Definition: first.py:37
NeighborSet & GetNeighbors()
Gets the neighbor set.
Definition: olsr-state.h:111
This class encapsulates all data structures needed for maintaining internal state of an OLSR node...
Definition: olsr-state.h:34
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:45
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:170
Associations m_associations
The node&#39;s local Host Network Associations that will be advertised using HNA messages.
Definition: olsr-state.h:48
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
std::set< Ipv4Address > MprSet
MPR Set type.
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:43
std::vector< MprSelectorTuple > MprSelectorSet
MPR Selector Set type.
MprSelectorSet m_mprSelectorSet
MPR Selector Set (RFC 3626, section 4.3.4).
Definition: olsr-state.h:44
void EraseNeighborTuple(const NeighborTuple &neighborTuple)
Erases a neighbor tuple.
Definition: olsr-state.cc:154
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:42
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