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 
26 
27 #ifndef OLSR_REPOSITORIES_H
28 #define OLSR_REPOSITORIES_H
29 
30 #include <set>
31 #include <vector>
32 
33 #include "ns3/ipv4-address.h"
34 #include "ns3/nstime.h"
35 
36 namespace ns3 {
37 namespace olsr {
38 
39 
43 {
50 };
51 
52 static inline bool
54 {
55  return (a.ifaceAddr == b.ifaceAddr
56  && a.mainAddr == b.mainAddr);
57 }
58 
59 static inline std::ostream&
60 operator << (std::ostream &os, const IfaceAssocTuple &tuple)
61 {
62  os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr
63  << ", mainAddr=" << tuple.mainAddr
64  << ", time=" << tuple.time << ")";
65  return os;
66 }
67 
70 struct LinkTuple
71 {
82 };
83 
84 static inline bool
85 operator == (const LinkTuple &a, const LinkTuple &b)
86 {
87  return (a.localIfaceAddr == b.localIfaceAddr
89 }
90 
91 static inline std::ostream&
92 operator << (std::ostream &os, const LinkTuple &tuple)
93 {
94  os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr
95  << ", neighborIfaceAddr=" << tuple.neighborIfaceAddr
96  << ", symTime=" << tuple.symTime
97  << ", asymTime=" << tuple.asymTime
98  << ", expTime=" << tuple.time
99  << ")";
100  return os;
101 }
102 
106 {
110  enum Status
111  {
112  STATUS_NOT_SYM = 0, // "not symmetric"
113  STATUS_SYM = 1, // "symmetric"
114  } status;
115  uint8_t willingness;
117 };
118 
119 static inline bool
121 {
122  return (a.neighborMainAddr == b.neighborMainAddr
123  && a.status == b.status
124  && a.willingness == b.willingness);
125 }
126 
127 static inline std::ostream&
128 operator << (std::ostream &os, const NeighborTuple &tuple)
129 {
130  os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
131  << ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM")
132  << ", willingness=" << (int) tuple.willingness << ")";
133  return os;
134 }
135 
139 {
145  Time expirationTime; // previously called 'time_'
146 };
147 
148 static inline std::ostream&
149 operator << (std::ostream &os, const TwoHopNeighborTuple &tuple)
150 {
151  os << "TwoHopNeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
152  << ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr
153  << ", expirationTime=" << tuple.expirationTime
154  << ")";
155  return os;
156 }
157 
158 static inline bool
160 {
161  return (a.neighborMainAddr == b.neighborMainAddr
163 }
164 
168 {
172  Time expirationTime; // previously called 'time_'
173 };
174 
175 static inline bool
177 {
178  return (a.mainAddr == b.mainAddr);
179 }
180 
181 
182 // The type "list of interface addresses"
183 //typedef std::vector<nsaddr_t> addr_list_t;
184 
188 {
192  uint16_t sequenceNumber;
196  std::vector<Ipv4Address> ifaceList;
199 };
200 
201 static inline bool
203 {
204  return (a.address == b.address
205  && a.sequenceNumber == b.sequenceNumber);
206 }
207 
211 {
217  uint16_t sequenceNumber;
220 };
221 
222 static inline bool
224 {
225  return (a.destAddr == b.destAddr
226  && a.lastAddr == b.lastAddr
227  && a.sequenceNumber == b.sequenceNumber);
228 }
229 
230 static inline std::ostream&
231 operator << (std::ostream &os, const TopologyTuple &tuple)
232 {
233  os << "TopologyTuple(destAddr=" << tuple.destAddr
234  << ", lastAddr=" << tuple.lastAddr
235  << ", sequenceNumber=" << (int) tuple.sequenceNumber
236  << ", expirationTime=" << tuple.expirationTime
237  << ")";
238  return os;
239 }
240 
244 {
247 };
248 
249 static inline bool
251 {
252  return (a.networkAddr == b.networkAddr
253  && a.netmask == b.netmask);
254 }
255 
256 static inline std::ostream&
257 operator << (std::ostream &os, const Association &tuple)
258 {
259  os << "Association(networkAddr=" << tuple.networkAddr
260  << ", netmask=" << tuple.netmask
261  << ")";
262  return os;
263 }
264 
268 {
277 };
278 
279 static inline bool
281 {
282  return (a.gatewayAddr == b.gatewayAddr
283  && a.networkAddr == b.networkAddr
284  && a.netmask == b.netmask);
285 }
286 
287 static inline std::ostream&
288 operator << (std::ostream &os, const AssociationTuple &tuple)
289 {
290  os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr
291  << ", networkAddr=" << tuple.networkAddr
292  << ", netmask=" << tuple.netmask
293  << ", expirationTime=" << tuple.expirationTime
294  << ")";
295  return os;
296 }
297 
298 
299 typedef std::set<Ipv4Address> MprSet;
300 typedef std::vector<MprSelectorTuple> MprSelectorSet;
301 typedef std::vector<LinkTuple> LinkSet;
302 typedef std::vector<NeighborTuple> NeighborSet;
303 typedef std::vector<TwoHopNeighborTuple> TwoHopNeighborSet;
304 typedef std::vector<TopologyTuple> TopologySet;
305 typedef std::vector<DuplicateTuple> DuplicateSet;
306 typedef std::vector<IfaceAssocTuple> IfaceAssocSet;
307 typedef std::vector<AssociationTuple> AssociationSet;
308 typedef std::vector<Association> Associations;
309 
310 
311 }
312 } // namespace ns3, olsr
313 
314 #endif /* OLSR_REPOSITORIES_H */
std::vector< TopologyTuple > TopologySet
Topology Set type.
An MPR-Selector Tuple.
Ipv4Address networkAddr
Network Address of network reachable through gatewayAddr.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
uint16_t sequenceNumber
Sequence number.
std::vector< Association > Associations
Association Set type.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
static std::ostream & operator<<(std::ostream &os, const PacketHeader &packet)
Definition: olsr-header.h:683
enum ns3::olsr::NeighborTuple::Status status
Status of the link.
Time expirationTime
Time at which this tuple expires and must be removed.
static bool operator==(const IfaceAssocTuple &a, const IfaceAssocTuple &b)
Ipv4Mask netmask
IPv4 Network mask.
Ipv4Mask netmask
Netmask of network reachable through gatewayAddr.
Status
Status of the link (Symmetric or not Symmetric).
Ipv4Address lastAddr
Main address of a node which is a neighbor of the destination.
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address mainAddr
Main address of the node.
Ipv4Address mainAddr
Main address of a node which have selected this node as a MPR.
An Association Tuple.
Time expirationTime
Time at which this tuple expires and must be removed.
std::vector< LinkTuple > LinkSet
Link Set type.
std::vector< DuplicateTuple > DuplicateSet
Duplicate Set type.
Ipv4Address destAddr
Main address of the destination.
std::vector< IfaceAssocTuple > IfaceAssocSet
Interface Association Set type.
uint8_t willingness
A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes...
Time expirationTime
Time at which this tuple expires and must be removed.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ipv4Address neighborMainAddr
Main address of a neighbor node.
Ipv4Address twoHopNeighborAddr
Main address of a 2-hop neighbor with a symmetric link to nb_main_addr.
Definition: olsr.py:1
Time time
Time at which this tuple expires and must be removed.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
std::vector< NeighborTuple > NeighborSet
Neighbor Set type.
Ipv4Address ifaceAddr
Interface address of a node.
std::set< Ipv4Address > MprSet
MPR Set type.
std::vector< TwoHopNeighborTuple > TwoHopNeighborSet
2-hop Neighbor Set type.
Ipv4Address neighborMainAddr
Main address of a neighbor.
std::vector< MprSelectorTuple > MprSelectorSet
MPR Selector Set type.
Ipv4Address address
Originator address of the message.
Ipv4Address gatewayAddr
Main address of the gateway.
Ipv4Address networkAddr
IPv4 Network address.
An Interface Association Tuple.
bool retransmitted
Indicates whether the message has been retransmitted or not.
uint16_t sequenceNumber
Message sequence number.
std::vector< AssociationTuple > AssociationSet
Association Set type.
Time expirationTime
Time at which this tuple expires and must be removed.
std::vector< Ipv4Address > ifaceList
List of interfaces which the message has been received on.