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;
113  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 */
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:256
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
static 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::vector< DuplicateTuple > DuplicateSet
Duplicate Set type.
std::vector< NeighborTuple > NeighborSet
Neighbor Set type.
std::vector< IfaceAssocTuple > IfaceAssocSet
Interface Association Set type.
static std::ostream & operator<<(std::ostream &os, const PacketHeader &packet)
Definition: olsr-header.h:683
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.
enum ns3::olsr::NeighborTuple::Status status
Status of the link.
uint8_t willingness
A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes.
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.