A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Authors: Francisco J. Ros <fjrm@dif.um.es>
8 * Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
9 */
10
11#ifndef OLSR_REPOSITORIES_H
12#define OLSR_REPOSITORIES_H
13
14#include "ns3/ipv4-address.h"
15#include "ns3/nstime.h"
16
17#include <iostream>
18#include <set>
19#include <vector>
20
21namespace ns3
22{
23namespace olsr
24{
25
26/**
27 * \ingroup olsr
28 *
29 * Willingness for forwarding packets from other nodes.
30 * The standard defines the following set of values.
31 * Values 0 - 7 are allowed by the standard, but this is not enforced in the code.
32 *
33 * See \RFC{3626} section 18.8
34 */
35enum Willingness : uint8_t
36{
37 NEVER = 0,
38 LOW = 1,
39 DEFAULT = 3, // medium
40 HIGH = 6,
41 ALWAYS = 7,
42};
43
44/**
45 * Stream insertion operator for OLSR willingness.
46 *
47 * \param os Output stream.
48 * \param willingness Willingness.
49 * \return A reference to the output stream.
50 */
51inline std::ostream&
52operator<<(std::ostream& os, Willingness willingness)
53{
54 switch (willingness)
55 {
57 return (os << "NEVER");
59 return (os << "LOW");
61 return (os << "DEFAULT");
63 return (os << "HIGH");
65 return (os << "ALWAYS");
66 default:
67 return (os << static_cast<uint32_t>(willingness)); // Cast to uint32_t to print correctly
68 }
69 return os;
70}
71
72/// \ingroup olsr
73/// An Interface Association Tuple.
75{
76 /// Interface address of a node.
78 /// Main address of the node.
80 /// Time at which this tuple expires and must be removed.
82};
83
84inline bool
86{
87 return (a.ifaceAddr == b.ifaceAddr && a.mainAddr == b.mainAddr);
88}
89
90inline std::ostream&
91operator<<(std::ostream& os, const IfaceAssocTuple& tuple)
92{
93 os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr << ", mainAddr=" << tuple.mainAddr
94 << ", time=" << tuple.time << ")";
95 return os;
96}
97
98/// \ingroup olsr
99/// A Link Tuple.
101{
102 /// Interface address of the local node.
104 /// Interface address of the neighbor node.
106 /// The link is considered bidirectional until this time.
108 /// The link is considered unidirectional until this time.
110 /// Time at which this tuple expires and must be removed.
112};
113
114inline bool
115operator==(const LinkTuple& a, const LinkTuple& b)
116{
118}
119
120inline std::ostream&
121operator<<(std::ostream& os, const LinkTuple& tuple)
122{
123 os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr
124 << ", neighborIfaceAddr=" << tuple.neighborIfaceAddr << ", symTime=" << tuple.symTime
125 << ", asymTime=" << tuple.asymTime << ", expTime=" << tuple.time << ")";
126 return os;
127}
128
129/// \ingroup olsr
130/// A Neighbor Tuple.
132{
133 /// Main address of a neighbor node.
135
136 /// Status of the link (Symmetric or not Symmetric).
138 {
139 STATUS_NOT_SYM = 0, // "not symmetric"
140 STATUS_SYM = 1, // "symmetric"
141 };
142
143 /// Status of the link.
145
146 /// A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of
147 /// other nodes.
149};
150
151inline bool
153{
154 return (a.neighborMainAddr == b.neighborMainAddr && a.status == b.status &&
155 a.willingness == b.willingness);
156}
157
158inline std::ostream&
159operator<<(std::ostream& os, const NeighborTuple& tuple)
160{
161 os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
162 << ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM")
163 << ", willingness=" << tuple.willingness << ")";
164 return os;
165}
166
167/// \ingroup olsr
168/// A 2-hop Tuple.
170{
171 /// Main address of a neighbor.
173 /// Main address of a 2-hop neighbor with a symmetric link to nb_main_addr.
175 /// Time at which this tuple expires and must be removed.
176 Time expirationTime; // previously called 'time_'
177};
178
179inline std::ostream&
180operator<<(std::ostream& os, const TwoHopNeighborTuple& tuple)
181{
182 os << "TwoHopNeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
183 << ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr
184 << ", expirationTime=" << tuple.expirationTime << ")";
185 return os;
186}
187
188inline bool
194
195/// \ingroup olsr
196/// An MPR-Selector Tuple.
198{
199 /// Main address of a node which have selected this node as a MPR.
201 /// Time at which this tuple expires and must be removed.
202 Time expirationTime; // previously called 'time_'
203};
204
205inline bool
207{
208 return (a.mainAddr == b.mainAddr);
209}
210
211// The type "list of interface addresses"
212// typedef std::vector<nsaddr_t> addr_list_t;
213
214/// \ingroup olsr
215/// A Duplicate Tuple
217{
218 /// Originator address of the message.
220 /// Message sequence number.
222 /// Indicates whether the message has been retransmitted or not.
224 /// List of interfaces which the message has been received on.
225 std::vector<Ipv4Address> ifaceList;
226 /// Time at which this tuple expires and must be removed.
228};
229
230inline bool
232{
233 return (a.address == b.address && a.sequenceNumber == b.sequenceNumber);
234}
235
236/// \ingroup olsr
237/// A Topology Tuple
239{
240 /// Main address of the destination.
242 /// Main address of a node which is a neighbor of the destination.
244 /// Sequence number.
246 /// Time at which this tuple expires and must be removed.
248};
249
250inline bool
252{
253 return (a.destAddr == b.destAddr && a.lastAddr == b.lastAddr &&
255}
256
257inline std::ostream&
258operator<<(std::ostream& os, const TopologyTuple& tuple)
259{
260 os << "TopologyTuple(destAddr=" << tuple.destAddr << ", lastAddr=" << tuple.lastAddr
261 << ", sequenceNumber=" << (int)tuple.sequenceNumber
262 << ", expirationTime=" << tuple.expirationTime << ")";
263 return os;
264}
265
266/// \ingroup olsr
267/// Association
269{
270 Ipv4Address networkAddr; //!< IPv4 Network address.
271 Ipv4Mask netmask; //!< IPv4 Network mask.
272};
273
274inline bool
276{
277 return (a.networkAddr == b.networkAddr && a.netmask == b.netmask);
278}
279
280inline std::ostream&
281operator<<(std::ostream& os, const Association& tuple)
282{
283 os << "Association(networkAddr=" << tuple.networkAddr << ", netmask=" << tuple.netmask << ")";
284 return os;
285}
286
287/// \ingroup olsr
288/// An Association Tuple
290{
291 /// Main address of the gateway.
293 /// Network Address of network reachable through gatewayAddr
295 /// Netmask of network reachable through gatewayAddr
297 /// Time at which this tuple expires and must be removed
299};
300
301inline bool
303{
304 return (a.gatewayAddr == b.gatewayAddr && a.networkAddr == b.networkAddr &&
305 a.netmask == b.netmask);
306}
307
308inline std::ostream&
309operator<<(std::ostream& os, const AssociationTuple& tuple)
310{
311 os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr
312 << ", networkAddr=" << tuple.networkAddr << ", netmask=" << tuple.netmask
313 << ", expirationTime=" << tuple.expirationTime << ")";
314 return os;
315}
316
317typedef std::set<Ipv4Address> MprSet; //!< MPR Set type.
318typedef std::vector<MprSelectorTuple> MprSelectorSet; //!< MPR Selector Set type.
319typedef std::vector<LinkTuple> LinkSet; //!< Link Set type.
320typedef std::vector<NeighborTuple> NeighborSet; //!< Neighbor Set type.
321typedef std::vector<TwoHopNeighborTuple> TwoHopNeighborSet; //!< 2-hop Neighbor Set type.
322typedef std::vector<TopologyTuple> TopologySet; //!< Topology Set type.
323typedef std::vector<DuplicateTuple> DuplicateSet; //!< Duplicate Set type.
324typedef std::vector<IfaceAssocTuple> IfaceAssocSet; //!< Interface Association Set type.
325typedef std::vector<AssociationTuple> AssociationSet; //!< Association Set type.
326typedef std::vector<Association> Associations; //!< Association Set type.
327
328} // namespace olsr
329} // namespace ns3
330
331#endif /* OLSR_REPOSITORIES_H */
Ipv4 addresses are stored in host order in this class.
a class to represent an Ipv4 address mask
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Willingness
Willingness for forwarding packets from other nodes.
std::ostream & operator<<(std::ostream &os, const PacketHeader &packet)
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.
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.
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.