A Discrete-Event Network Simulator
API
olsr-repositories.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_REPOSITORIES_H
23 #define OLSR_REPOSITORIES_H
24 
25 #include "ns3/ipv4-address.h"
26 #include "ns3/nstime.h"
27 
28 #include <iostream>
29 #include <set>
30 #include <vector>
31 
32 namespace ns3
33 {
34 namespace olsr
35 {
36 
46 enum Willingness : uint8_t
47 {
48  NEVER = 0,
49  LOW = 1,
50  DEFAULT = 3, // medium
51  HIGH = 6,
52  ALWAYS = 7,
53 };
54 
62 inline std::ostream&
63 operator<<(std::ostream& os, Willingness willingness)
64 {
65  switch (willingness)
66  {
67  case Willingness::NEVER:
68  return (os << "NEVER");
69  case Willingness::LOW:
70  return (os << "LOW");
72  return (os << "DEFAULT");
73  case Willingness::HIGH:
74  return (os << "HIGH");
76  return (os << "ALWAYS");
77  default:
78  return (os << static_cast<uint32_t>(willingness)); // Cast to uint32_t to print correctly
79  }
80  return os;
81 }
82 
86 {
93 };
94 
95 inline bool
97 {
98  return (a.ifaceAddr == b.ifaceAddr && a.mainAddr == b.mainAddr);
99 }
100 
101 inline std::ostream&
102 operator<<(std::ostream& os, const IfaceAssocTuple& tuple)
103 {
104  os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr << ", mainAddr=" << tuple.mainAddr
105  << ", time=" << tuple.time << ")";
106  return os;
107 }
108 
111 struct LinkTuple
112 {
123 };
124 
125 inline bool
126 operator==(const LinkTuple& a, const LinkTuple& b)
127 {
129 }
130 
131 inline std::ostream&
132 operator<<(std::ostream& os, const LinkTuple& tuple)
133 {
134  os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr
135  << ", neighborIfaceAddr=" << tuple.neighborIfaceAddr << ", symTime=" << tuple.symTime
136  << ", asymTime=" << tuple.asymTime << ", expTime=" << tuple.time << ")";
137  return os;
138 }
139 
143 {
146 
148  enum Status
149  {
150  STATUS_NOT_SYM = 0, // "not symmetric"
151  STATUS_SYM = 1, // "symmetric"
152  };
153 
156 
160 };
161 
162 inline bool
164 {
165  return (a.neighborMainAddr == b.neighborMainAddr && a.status == b.status &&
166  a.willingness == b.willingness);
167 }
168 
169 inline std::ostream&
170 operator<<(std::ostream& os, const NeighborTuple& tuple)
171 {
172  os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
173  << ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM")
174  << ", willingness=" << tuple.willingness << ")";
175  return os;
176 }
177 
181 {
187  Time expirationTime; // previously called 'time_'
188 };
189 
190 inline std::ostream&
191 operator<<(std::ostream& os, const TwoHopNeighborTuple& tuple)
192 {
193  os << "TwoHopNeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
194  << ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr
195  << ", expirationTime=" << tuple.expirationTime << ")";
196  return os;
197 }
198 
199 inline bool
201 {
202  return (a.neighborMainAddr == b.neighborMainAddr &&
204 }
205 
209 {
213  Time expirationTime; // previously called 'time_'
214 };
215 
216 inline bool
218 {
219  return (a.mainAddr == b.mainAddr);
220 }
221 
222 // The type "list of interface addresses"
223 // typedef std::vector<nsaddr_t> addr_list_t;
224 
228 {
232  uint16_t sequenceNumber;
236  std::vector<Ipv4Address> ifaceList;
239 };
240 
241 inline bool
243 {
244  return (a.address == b.address && a.sequenceNumber == b.sequenceNumber);
245 }
246 
250 {
256  uint16_t sequenceNumber;
259 };
260 
261 inline bool
263 {
264  return (a.destAddr == b.destAddr && a.lastAddr == b.lastAddr &&
266 }
267 
268 inline std::ostream&
269 operator<<(std::ostream& os, const TopologyTuple& tuple)
270 {
271  os << "TopologyTuple(destAddr=" << tuple.destAddr << ", lastAddr=" << tuple.lastAddr
272  << ", sequenceNumber=" << (int)tuple.sequenceNumber
273  << ", expirationTime=" << tuple.expirationTime << ")";
274  return os;
275 }
276 
280 {
283 };
284 
285 inline bool
286 operator==(const Association& a, const Association& b)
287 {
288  return (a.networkAddr == b.networkAddr && a.netmask == b.netmask);
289 }
290 
291 inline std::ostream&
292 operator<<(std::ostream& os, const Association& tuple)
293 {
294  os << "Association(networkAddr=" << tuple.networkAddr << ", netmask=" << tuple.netmask << ")";
295  return os;
296 }
297 
301 {
310 };
311 
312 inline bool
314 {
315  return (a.gatewayAddr == b.gatewayAddr && a.networkAddr == b.networkAddr &&
316  a.netmask == b.netmask);
317 }
318 
319 inline std::ostream&
320 operator<<(std::ostream& os, const AssociationTuple& tuple)
321 {
322  os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr
323  << ", networkAddr=" << tuple.networkAddr << ", netmask=" << tuple.netmask
324  << ", expirationTime=" << tuple.expirationTime << ")";
325  return os;
326 }
327 
328 typedef std::set<Ipv4Address> MprSet;
329 typedef std::vector<MprSelectorTuple> MprSelectorSet;
330 typedef std::vector<LinkTuple> LinkSet;
331 typedef std::vector<NeighborTuple> NeighborSet;
332 typedef std::vector<TwoHopNeighborTuple> TwoHopNeighborSet;
333 typedef std::vector<TopologyTuple> TopologySet;
334 typedef std::vector<DuplicateTuple> DuplicateSet;
335 typedef std::vector<IfaceAssocTuple> IfaceAssocSet;
336 typedef std::vector<AssociationTuple> AssociationSet;
337 typedef std::vector<Association> Associations;
338 
339 } // namespace olsr
340 } // namespace ns3
341 
342 #endif /* OLSR_REPOSITORIES_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
Willingness
Willingness for forwarding packets from other nodes.
bool operator==(const IfaceAssocTuple &a, const IfaceAssocTuple &b)
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::ostream & operator<<(std::ostream &os, const PacketHeader &packet)
Definition: olsr-header.h:690
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
Ipv4Address networkAddr
IPv4 Network address.
Ipv4Mask netmask
IPv4 Network mask.
Ipv4Address networkAddr
Network Address of network reachable through gatewayAddr.
Ipv4Mask netmask
Netmask of network reachable through gatewayAddr.
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address gatewayAddr
Main address of the gateway.
std::vector< Ipv4Address > ifaceList
List of interfaces which the message has been received on.
Ipv4Address address
Originator address of the message.
uint16_t sequenceNumber
Message sequence number.
bool retransmitted
Indicates whether the message has been retransmitted or not.
Time expirationTime
Time at which this tuple expires and must be removed.
An Interface Association Tuple.
Ipv4Address ifaceAddr
Interface address of a node.
Time time
Time at which this tuple expires and must be removed.
Ipv4Address mainAddr
Main address of the node.
An MPR-Selector Tuple.
Ipv4Address mainAddr
Main address of a node which have selected this node as a MPR.
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address neighborMainAddr
Main address of a neighbor node.
Willingness willingness
A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes.
Status status
Status of the link.
Status
Status of the link (Symmetric or not Symmetric).
Ipv4Address destAddr
Main address of the destination.
Ipv4Address lastAddr
Main address of a node which is a neighbor of the destination.
uint16_t sequenceNumber
Sequence number.
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address twoHopNeighborAddr
Main address of a 2-hop neighbor with a symmetric link to nb_main_addr.
Ipv4Address neighborMainAddr
Main address of a neighbor.
Time expirationTime
Time at which this tuple expires and must be removed.