A Discrete-Event Network Simulator
API
olsr-repositories.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_REPOSITORIES_H
25 #define OLSR_REPOSITORIES_H
26 
27 #include <set>
28 #include <vector>
29 
30 #include "ns3/ipv4-address.h"
31 #include "ns3/nstime.h"
32 
33 namespace ns3 {
34 namespace olsr {
35 
36 
40 {
47 };
48 
49 static inline bool
51 {
52  return (a.ifaceAddr == b.ifaceAddr
53  && a.mainAddr == b.mainAddr);
54 }
55 
56 static inline std::ostream&
57 operator << (std::ostream &os, const IfaceAssocTuple &tuple)
58 {
59  os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr
60  << ", mainAddr=" << tuple.mainAddr
61  << ", time=" << tuple.time << ")";
62  return os;
63 }
64 
67 struct LinkTuple
68 {
79 };
80 
81 static inline bool
82 operator == (const LinkTuple &a, const LinkTuple &b)
83 {
84  return (a.localIfaceAddr == b.localIfaceAddr
86 }
87 
88 static inline std::ostream&
89 operator << (std::ostream &os, const LinkTuple &tuple)
90 {
91  os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr
92  << ", neighborIfaceAddr=" << tuple.neighborIfaceAddr
93  << ", symTime=" << tuple.symTime
94  << ", asymTime=" << tuple.asymTime
95  << ", expTime=" << tuple.time
96  << ")";
97  return os;
98 }
99 
103 {
107  enum Status
108  {
109  STATUS_NOT_SYM = 0, // "not symmetric"
110  STATUS_SYM = 1, // "symmetric"
111  } status;
112  uint8_t willingness;
114 };
115 
116 static inline bool
118 {
119  return (a.neighborMainAddr == b.neighborMainAddr
120  && a.status == b.status
121  && a.willingness == b.willingness);
122 }
123 
124 static inline std::ostream&
125 operator << (std::ostream &os, const NeighborTuple &tuple)
126 {
127  os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
128  << ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM")
129  << ", willingness=" << (int) tuple.willingness << ")";
130  return os;
131 }
132 
136 {
142  Time expirationTime; // previously called 'time_'
143 };
144 
145 static inline std::ostream&
146 operator << (std::ostream &os, const TwoHopNeighborTuple &tuple)
147 {
148  os << "TwoHopNeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
149  << ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr
150  << ", expirationTime=" << tuple.expirationTime
151  << ")";
152  return os;
153 }
154 
155 static inline bool
157 {
158  return (a.neighborMainAddr == b.neighborMainAddr
160 }
161 
165 {
169  Time expirationTime; // previously called 'time_'
170 };
171 
172 static inline bool
174 {
175  return (a.mainAddr == b.mainAddr);
176 }
177 
178 
179 // The type "list of interface addresses"
180 //typedef std::vector<nsaddr_t> addr_list_t;
181 
185 {
189  uint16_t sequenceNumber;
193  std::vector<Ipv4Address> ifaceList;
196 };
197 
198 static inline bool
200 {
201  return (a.address == b.address
202  && a.sequenceNumber == b.sequenceNumber);
203 }
204 
208 {
214  uint16_t sequenceNumber;
217 };
218 
219 static inline bool
221 {
222  return (a.destAddr == b.destAddr
223  && a.lastAddr == b.lastAddr
224  && a.sequenceNumber == b.sequenceNumber);
225 }
226 
227 static inline std::ostream&
228 operator << (std::ostream &os, const TopologyTuple &tuple)
229 {
230  os << "TopologyTuple(destAddr=" << tuple.destAddr
231  << ", lastAddr=" << tuple.lastAddr
232  << ", sequenceNumber=" << (int) tuple.sequenceNumber
233  << ", expirationTime=" << tuple.expirationTime
234  << ")";
235  return os;
236 }
237 
241 {
244 };
245 
246 static inline bool
248 {
249  return (a.networkAddr == b.networkAddr
250  && a.netmask == b.netmask);
251 }
252 
253 static inline std::ostream&
254 operator << (std::ostream &os, const Association &tuple)
255 {
256  os << "Association(networkAddr=" << tuple.networkAddr
257  << ", netmask=" << tuple.netmask
258  << ")";
259  return os;
260 }
261 
265 {
274 };
275 
276 static inline bool
278 {
279  return (a.gatewayAddr == b.gatewayAddr
280  && a.networkAddr == b.networkAddr
281  && a.netmask == b.netmask);
282 }
283 
284 static inline std::ostream&
285 operator << (std::ostream &os, const AssociationTuple &tuple)
286 {
287  os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr
288  << ", networkAddr=" << tuple.networkAddr
289  << ", netmask=" << tuple.netmask
290  << ", expirationTime=" << tuple.expirationTime
291  << ")";
292  return os;
293 }
294 
295 
296 typedef std::set<Ipv4Address> MprSet;
297 typedef std::vector<MprSelectorTuple> MprSelectorSet;
298 typedef std::vector<LinkTuple> LinkSet;
299 typedef std::vector<NeighborTuple> NeighborSet;
300 typedef std::vector<TwoHopNeighborTuple> TwoHopNeighborSet;
301 typedef std::vector<TopologyTuple> TopologySet;
302 typedef std::vector<DuplicateTuple> DuplicateSet;
303 typedef std::vector<IfaceAssocTuple> IfaceAssocSet;
304 typedef std::vector<AssociationTuple> AssociationSet;
305 typedef std::vector<Association> Associations;
306 
307 
308 }
309 } // namespace ns3, olsr
310 
311 #endif /* OLSR_REPOSITORIES_H */
ns3::olsr::DuplicateTuple::address
Ipv4Address address
Originator address of the message.
Definition: olsr-repositories.h:187
ns3::olsr::TopologyTuple::expirationTime
Time expirationTime
Time at which this tuple expires and must be removed.
Definition: olsr-repositories.h:216
ns3::olsr::DuplicateTuple::retransmitted
bool retransmitted
Indicates whether the message has been retransmitted or not.
Definition: olsr-repositories.h:191
ns3::olsr::Association::networkAddr
Ipv4Address networkAddr
IPv4 Network address.
Definition: olsr-repositories.h:242
ns3::olsr::DuplicateTuple::sequenceNumber
uint16_t sequenceNumber
Message sequence number.
Definition: olsr-repositories.h:189
ns3::olsr::IfaceAssocTuple::mainAddr
Ipv4Address mainAddr
Main address of the node.
Definition: olsr-repositories.h:44
ns3::olsr::IfaceAssocTuple
An Interface Association Tuple.
Definition: olsr-repositories.h:40
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::olsr::operator<<
static std::ostream & operator<<(std::ostream &os, const PacketHeader &packet)
Definition: olsr-header.h:683
ns3::olsr::Association::netmask
Ipv4Mask netmask
IPv4 Network mask.
Definition: olsr-repositories.h:243
ns3::olsr::TwoHopNeighborTuple::neighborMainAddr
Ipv4Address neighborMainAddr
Main address of a neighbor.
Definition: olsr-repositories.h:138
ns3::olsr::TwoHopNeighborTuple::expirationTime
Time expirationTime
Time at which this tuple expires and must be removed.
Definition: olsr-repositories.h:142
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::olsr::MprSet
std::set< Ipv4Address > MprSet
MPR Set type.
Definition: olsr-repositories.h:296
ns3::olsr::TwoHopNeighborSet
std::vector< TwoHopNeighborTuple > TwoHopNeighborSet
2-hop Neighbor Set type.
Definition: olsr-repositories.h:300
ns3::olsr::IfaceAssocTuple::time
Time time
Time at which this tuple expires and must be removed.
Definition: olsr-repositories.h:46
ns3::olsr::LinkSet
std::vector< LinkTuple > LinkSet
Link Set type.
Definition: olsr-repositories.h:298
ns3::olsr::AssociationTuple::netmask
Ipv4Mask netmask
Netmask of network reachable through gatewayAddr.
Definition: olsr-repositories.h:271
ns3::olsr::IfaceAssocTuple::ifaceAddr
Ipv4Address ifaceAddr
Interface address of a node.
Definition: olsr-repositories.h:42
ns3::olsr::AssociationTuple::expirationTime
Time expirationTime
Time at which this tuple expires and must be removed.
Definition: olsr-repositories.h:273
ns3::olsr::IfaceAssocSet
std::vector< IfaceAssocTuple > IfaceAssocSet
Interface Association Set type.
Definition: olsr-repositories.h:303
ns3::olsr::MprSelectorTuple::expirationTime
Time expirationTime
Time at which this tuple expires and must be removed.
Definition: olsr-repositories.h:169
ns3::olsr::NeighborTuple::neighborMainAddr
Ipv4Address neighborMainAddr
Main address of a neighbor node.
Definition: olsr-repositories.h:105
ns3::olsr::NeighborSet
std::vector< NeighborTuple > NeighborSet
Neighbor Set type.
Definition: olsr-repositories.h:299
ns3::olsr::MprSelectorTuple::mainAddr
Ipv4Address mainAddr
Main address of a node which have selected this node as a MPR.
Definition: olsr-repositories.h:167
ns3::olsr::TopologyTuple
A Topology Tuple.
Definition: olsr-repositories.h:208
ns3::olsr::TopologyTuple::lastAddr
Ipv4Address lastAddr
Main address of a node which is a neighbor of the destination.
Definition: olsr-repositories.h:212
ns3::olsr::operator==
static bool operator==(const IfaceAssocTuple &a, const IfaceAssocTuple &b)
Definition: olsr-repositories.h:50
ns3::olsr::NeighborTuple::STATUS_NOT_SYM
@ STATUS_NOT_SYM
Definition: olsr-repositories.h:109
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::olsr::NeighborTuple::Status
Status
Status of the link (Symmetric or not Symmetric).
Definition: olsr-repositories.h:108
ns3::olsr::DuplicateTuple::ifaceList
std::vector< Ipv4Address > ifaceList
List of interfaces which the message has been received on.
Definition: olsr-repositories.h:193
ns3::olsr::Associations
std::vector< Association > Associations
Association Set type.
Definition: olsr-repositories.h:305
ns3::olsr::TopologyTuple::sequenceNumber
uint16_t sequenceNumber
Sequence number.
Definition: olsr-repositories.h:214
ns3::olsr::TopologySet
std::vector< TopologyTuple > TopologySet
Topology Set type.
Definition: olsr-repositories.h:301
ns3::olsr::TwoHopNeighborTuple::twoHopNeighborAddr
Ipv4Address twoHopNeighborAddr
Main address of a 2-hop neighbor with a symmetric link to nb_main_addr.
Definition: olsr-repositories.h:140
ns3::olsr::NeighborTuple
A Neighbor Tuple.
Definition: olsr-repositories.h:103
ns3::olsr::Association
Association.
Definition: olsr-repositories.h:241
ns3::olsr::AssociationSet
std::vector< AssociationTuple > AssociationSet
Association Set type.
Definition: olsr-repositories.h:304
ns3::olsr::DuplicateTuple::expirationTime
Time expirationTime
Time at which this tuple expires and must be removed.
Definition: olsr-repositories.h:195
ns3::olsr::MprSelectorTuple
An MPR-Selector Tuple.
Definition: olsr-repositories.h:165
ns3::olsr::AssociationTuple
An Association Tuple.
Definition: olsr-repositories.h:265
ns3::Ipv4Mask
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:256
ns3::olsr::TwoHopNeighborTuple
A 2-hop Tuple.
Definition: olsr-repositories.h:136
ns3::olsr::NeighborTuple::willingness
uint8_t willingness
A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes.
Definition: olsr-repositories.h:113
olsr
Definition: olsr.py:1
ns3::olsr::MprSelectorSet
std::vector< MprSelectorTuple > MprSelectorSet
MPR Selector Set type.
Definition: olsr-repositories.h:297
ns3::olsr::AssociationTuple::networkAddr
Ipv4Address networkAddr
Network Address of network reachable through gatewayAddr.
Definition: olsr-repositories.h:269
ns3::olsr::NeighborTuple::STATUS_SYM
@ STATUS_SYM
Definition: olsr-repositories.h:110
ns3::olsr::DuplicateTuple
A Duplicate Tuple.
Definition: olsr-repositories.h:185
ns3::olsr::NeighborTuple::status
enum ns3::olsr::NeighborTuple::Status status
Status of the link.
ns3::olsr::AssociationTuple::gatewayAddr
Ipv4Address gatewayAddr
Main address of the gateway.
Definition: olsr-repositories.h:267
ns3::olsr::DuplicateSet
std::vector< DuplicateTuple > DuplicateSet
Duplicate Set type.
Definition: olsr-repositories.h:302
ns3::olsr::TopologyTuple::destAddr
Ipv4Address destAddr
Main address of the destination.
Definition: olsr-repositories.h:210