|
54 |
/// This section documents the API of the ns-3 OLSR module. For a generic |
54 |
/// This section documents the API of the ns-3 OLSR module. For a generic |
55 |
/// functional description, please refer to the ns-3 manual. |
55 |
/// functional description, please refer to the ns-3 manual. |
56 |
|
56 |
|
|
|
57 |
/// \ingroup olsr |
57 |
/// An %OLSR's routing table entry. |
58 |
/// An %OLSR's routing table entry. |
58 |
struct RoutingTableEntry |
59 |
struct RoutingTableEntry |
59 |
{ |
60 |
{ |
60 |
Ipv4Address destAddr; ///< Address of the destination node. |
61 |
Ipv4Address destAddr; //!< Address of the destination node. |
61 |
Ipv4Address nextAddr; ///< Address of the next hop. |
62 |
Ipv4Address nextAddr; //!< Address of the next hop. |
62 |
uint32_t interface; ///< Interface index |
63 |
uint32_t interface; //!< Interface index |
63 |
uint32_t distance; ///< Distance in hops to the destination. |
64 |
uint32_t distance; //!< Distance in hops to the destination. |
64 |
|
65 |
|
65 |
RoutingTableEntry () : // default values |
66 |
RoutingTableEntry () : // default values |
66 |
destAddr (), nextAddr (), |
67 |
destAddr (), nextAddr (), |
|
78 |
{ |
79 |
{ |
79 |
public: |
80 |
public: |
80 |
friend class ::OlsrMprTestCase; |
81 |
friend class ::OlsrMprTestCase; |
|
|
82 |
|
83 |
/** |
84 |
* \brief Get the type ID. |
85 |
* \return The object TypeId. |
86 |
*/ |
81 |
static TypeId GetTypeId (void); |
87 |
static TypeId GetTypeId (void); |
82 |
|
88 |
|
83 |
RoutingProtocol (); |
89 |
RoutingProtocol (); |
84 |
virtual ~RoutingProtocol (); |
90 |
virtual ~RoutingProtocol (); |
85 |
|
91 |
|
86 |
/// |
92 |
/** |
87 |
/// \brief Set the OLSR main address to the first address on the indicated |
93 |
* \brief Set the OLSR main address to the first address on the indicated interface. |
88 |
/// interface |
94 |
* |
89 |
/// \param interface IPv4 interface index |
95 |
* \param interface IPv4 interface index |
90 |
/// |
96 |
*/ |
91 |
void SetMainInterface (uint32_t interface); |
97 |
void SetMainInterface (uint32_t interface); |
92 |
|
98 |
|
93 |
/// |
99 |
/** |
94 |
/// Dump the neighbor table, two-hop neighbor table, and routing table |
100 |
* Dump the neighbor table, two-hop neighbor table, and routing table |
95 |
/// to logging output (NS_LOG_DEBUG log level). If logging is disabled, |
101 |
* to logging output (NS_LOG_DEBUG log level). If logging is disabled, |
96 |
/// this function does nothing. |
102 |
* this function does nothing. |
97 |
/// |
103 |
*/ |
98 |
void Dump (void); |
104 |
void Dump (void); |
99 |
|
105 |
|
100 |
/** |
106 |
/** |
101 |
* Return the list of routing table entries discovered by OLSR |
107 |
* Return the list of routing table entries discovered by OLSR |
102 |
**/ |
108 |
*/ |
103 |
std::vector<RoutingTableEntry> GetRoutingTableEntries () const; |
109 |
std::vector<RoutingTableEntry> GetRoutingTableEntries () const; |
104 |
|
110 |
|
105 |
/** |
111 |
/** |
|
129 |
typedef void (* TableChangeTracedCallback) (uint32_t size); |
135 |
typedef void (* TableChangeTracedCallback) (uint32_t size); |
130 |
|
136 |
|
131 |
private: |
137 |
private: |
132 |
std::set<uint32_t> m_interfaceExclusions; |
138 |
std::set<uint32_t> m_interfaceExclusions; //!< Set of interfaces excluded by OSLR. |
133 |
Ptr<Ipv4StaticRouting> m_routingTableAssociation; |
139 |
Ptr<Ipv4StaticRouting> m_routingTableAssociation; //!< Associations from an Ipv4StaticRouting instance |
134 |
|
140 |
|
135 |
public: |
141 |
public: |
|
|
142 |
/** |
143 |
* Get the excluded interfaces. |
144 |
* \returns Container of excluded interfaces. |
145 |
*/ |
136 |
std::set<uint32_t> GetInterfaceExclusions () const |
146 |
std::set<uint32_t> GetInterfaceExclusions () const |
137 |
{ |
147 |
{ |
138 |
return m_interfaceExclusions; |
148 |
return m_interfaceExclusions; |
139 |
} |
149 |
} |
|
|
150 |
|
151 |
/** |
152 |
* Set the interfaces to be excluded. |
153 |
* \param exceptions Container of excluded interfaces. |
154 |
*/ |
140 |
void SetInterfaceExclusions (std::set<uint32_t> exceptions); |
155 |
void SetInterfaceExclusions (std::set<uint32_t> exceptions); |
141 |
|
156 |
|
142 |
/// Inject Association to be sent in HNA message |
157 |
/** |
|
|
158 |
* \brief Injects the specified (networkAddr, netmask) tuple in the list of |
159 |
* local HNA associations to be sent by the node via HNA messages. |
160 |
* If this tuple already exists, nothing is done. |
161 |
* |
162 |
* \param networkAddr The network address. |
163 |
* \param netmask The network mask. |
164 |
*/ |
143 |
void AddHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask); |
165 |
void AddHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask); |
144 |
/// Removes Association sent in HNA message |
166 |
|
|
|
167 |
/** |
168 |
* \brief Removes the specified (networkAddr, netmask) tuple from the list of |
169 |
* local HNA associations to be sent by the node via HNA messages. |
170 |
* If this tuple does not exist, nothing is done (see "OlsrState::EraseAssociation()"). |
171 |
* |
172 |
* \param networkAddr The network address. |
173 |
* \param netmask The network mask. |
174 |
*/ |
145 |
void RemoveHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask); |
175 |
void RemoveHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask); |
146 |
|
176 |
|
147 |
/// Inject Associations from an Ipv4StaticRouting instance |
177 |
/** |
|
|
178 |
* \brief Associates the specified Ipv4StaticRouting routing table |
179 |
* to the OLSR routing protocol. Entries from this associated |
180 |
* routing table that use non-olsr outgoing interfaces are added |
181 |
* to the list of local HNA associations so that they are included |
182 |
* in HNA messages sent by the node. |
183 |
* If this method is called more than once, entries from the old |
184 |
* association are deleted before entries from the new one are added. |
185 |
* \param routingTable the Ipv4StaticRouting routing table to be associated. |
186 |
*/ |
148 |
void SetRoutingTableAssociation (Ptr<Ipv4StaticRouting> routingTable); |
187 |
void SetRoutingTableAssociation (Ptr<Ipv4StaticRouting> routingTable); |
149 |
|
188 |
|
150 |
/** |
189 |
/** |
|
156 |
protected: |
195 |
protected: |
157 |
virtual void DoInitialize (void); |
196 |
virtual void DoInitialize (void); |
158 |
private: |
197 |
private: |
159 |
std::map<Ipv4Address, RoutingTableEntry> m_table; ///< Data structure for the routing table. |
198 |
std::map<Ipv4Address, RoutingTableEntry> m_table; //!< Data structure for the routing table. |
160 |
|
199 |
|
161 |
Ptr<Ipv4StaticRouting> m_hnaRoutingTable; |
200 |
Ptr<Ipv4StaticRouting> m_hnaRoutingTable; //!< Routing table for HNA routes |
162 |
|
201 |
|
163 |
EventGarbageCollector m_events; |
202 |
EventGarbageCollector m_events; //!< Running events. |
164 |
|
203 |
|
165 |
/// Packets sequence number counter. |
204 |
uint16_t m_packetSequenceNumber; //!< Packets sequence number counter. |
166 |
uint16_t m_packetSequenceNumber; |
205 |
uint16_t m_messageSequenceNumber; //!< Messages sequence number counter. |
167 |
/// Messages sequence number counter. |
206 |
uint16_t m_ansn; //!< Advertised Neighbor Set sequence number. |
168 |
uint16_t m_messageSequenceNumber; |
|
|
169 |
/// Advertised Neighbor Set sequence number. |
170 |
uint16_t m_ansn; |
171 |
|
207 |
|
172 |
/// HELLO messages' emission interval. |
208 |
Time m_helloInterval; //!< HELLO messages' emission interval. |
173 |
Time m_helloInterval; |
209 |
Time m_tcInterval; //!< TC messages' emission interval. |
174 |
/// TC messages' emission interval. |
210 |
Time m_midInterval; //!< MID messages' emission interval. |
175 |
Time m_tcInterval; |
211 |
Time m_hnaInterval; //!< HNA messages' emission interval. |
176 |
/// MID messages' emission interval. |
212 |
uint8_t m_willingness; //!< Willingness for forwarding packets on behalf of other nodes. |
177 |
Time m_midInterval; |
|
|
178 |
/// HNA messages' emission interval. |
179 |
Time m_hnaInterval; |
180 |
/// Willingness for forwarding packets on behalf of other nodes. |
181 |
uint8_t m_willingness; |
182 |
|
213 |
|
183 |
/// Internal state with all needed data structs. |
214 |
OlsrState m_state; //!< Internal state with all needed data structs. |
184 |
OlsrState m_state; |
215 |
Ptr<Ipv4> m_ipv4; //!< IPv4 object the routing is linked to. |
185 |
|
216 |
|
186 |
Ptr<Ipv4> m_ipv4; |
217 |
/** |
|
|
218 |
* \brief Clears the routing table and frees the memory assigned to each one of its entries. |
219 |
*/ |
220 |
void Clear (); |
187 |
|
221 |
|
188 |
void Clear (); |
222 |
/** |
|
|
223 |
* Returns the routing table size. |
224 |
* \return The routing table size. |
225 |
*/ |
189 |
uint32_t GetSize () const { return m_table.size (); } |
226 |
uint32_t GetSize () const { return m_table.size (); } |
|
|
227 |
|
228 |
/** |
229 |
* \brief Deletes the entry whose destination address is given. |
230 |
* \param dest address of the destination node. |
231 |
*/ |
190 |
void RemoveEntry (const Ipv4Address &dest); |
232 |
void RemoveEntry (const Ipv4Address &dest); |
|
|
233 |
/** |
234 |
* \brief Adds a new entry into the routing table. |
235 |
* |
236 |
* If an entry for the given destination existed, it is deleted and freed. |
237 |
* |
238 |
* \param dest address of the destination node. |
239 |
* \param next address of the next hop node. |
240 |
* \param interface address of the local interface. |
241 |
* \param distance distance to the destination node. |
242 |
*/ |
191 |
void AddEntry (const Ipv4Address &dest, |
243 |
void AddEntry (const Ipv4Address &dest, |
192 |
const Ipv4Address &next, |
244 |
const Ipv4Address &next, |
193 |
uint32_t interface, |
245 |
uint32_t interface, |
194 |
uint32_t distance); |
246 |
uint32_t distance); |
|
|
247 |
/** |
248 |
* \brief Adds a new entry into the routing table. |
249 |
* |
250 |
* If an entry for the given destination existed, an error is thrown. |
251 |
* |
252 |
* \param dest address of the destination node. |
253 |
* \param next address of the next hop node. |
254 |
* \param interfaceAddress address of the local interface. |
255 |
* \param distance distance to the destination node. |
256 |
*/ |
195 |
void AddEntry (const Ipv4Address &dest, |
257 |
void AddEntry (const Ipv4Address &dest, |
196 |
const Ipv4Address &next, |
258 |
const Ipv4Address &next, |
197 |
const Ipv4Address &interfaceAddress, |
259 |
const Ipv4Address &interfaceAddress, |
198 |
uint32_t distance); |
260 |
uint32_t distance); |
|
|
261 |
|
262 |
/** |
263 |
* \brief Looks up an entry for the specified destination address. |
264 |
* \param [in] dest Destination address. |
265 |
* \param [out] outEntry Holds the routing entry result, if found. |
266 |
* \return true if found, false if not found. |
267 |
*/ |
199 |
bool Lookup (const Ipv4Address &dest, |
268 |
bool Lookup (const Ipv4Address &dest, |
200 |
RoutingTableEntry &outEntry) const; |
269 |
RoutingTableEntry &outEntry) const; |
|
|
270 |
|
271 |
/** |
272 |
* \brief Finds the appropriate entry which must be used in order to forward |
273 |
* a data packet to a next hop (given a destination). |
274 |
* |
275 |
* Imagine a routing table like this: [A,B] [B,C] [C,C]; being each pair of the |
276 |
* form [dest addr, next-hop addr]. In this case, if this function is invoked |
277 |
* with [A,B] then pair [C,C] is returned because C is the next hop that must be used |
278 |
* to forward a data packet destined to A. That is, C is a neighbor of this node, |
279 |
* but B isn't. This function finds the appropriate neighbor for forwarding a packet. |
280 |
* |
281 |
* \param[in] entry The routing table entry which indicates the destination node |
282 |
* we are interested in. |
283 |
* |
284 |
* \param[out] outEntry The appropriate routing table entry which indicates the next |
285 |
* hop which must be used for forwarding a data packet, or NULL if there is no such entry. |
286 |
* |
287 |
* \return True if an entry was found, false otherwise. |
288 |
*/ |
201 |
bool FindSendEntry (const RoutingTableEntry &entry, |
289 |
bool FindSendEntry (const RoutingTableEntry &entry, |
202 |
RoutingTableEntry &outEntry) const; |
290 |
RoutingTableEntry &outEntry) const; |
203 |
|
291 |
|
|
222 |
|
310 |
|
223 |
void DoDispose (); |
311 |
void DoDispose (); |
224 |
|
312 |
|
|
|
313 |
/** |
314 |
* Send an OLSR message. |
315 |
* \param packet The packet to be sent. |
316 |
* \param containedMessages The messages contained in the packet. |
317 |
*/ |
225 |
void SendPacket (Ptr<Packet> packet, const MessageList &containedMessages); |
318 |
void SendPacket (Ptr<Packet> packet, const MessageList &containedMessages); |
226 |
|
319 |
|
227 |
/// Increments packet sequence number and returns the new value. |
320 |
/** |
|
|
321 |
* Increments packet sequence number and returns the new value. |
322 |
* \return The packet sequence number. |
323 |
*/ |
228 |
inline uint16_t GetPacketSequenceNumber (); |
324 |
inline uint16_t GetPacketSequenceNumber (); |
229 |
/// Increments message sequence number and returns the new value. |
325 |
|
|
|
326 |
/** |
327 |
* Increments message sequence number and returns the new value. |
328 |
* \return The message sequence number. |
329 |
*/ |
230 |
inline uint16_t GetMessageSequenceNumber (); |
330 |
inline uint16_t GetMessageSequenceNumber (); |
231 |
|
331 |
|
|
|
332 |
/** |
333 |
* Receive an OLSR message. |
334 |
* \param socket The receiving socket. |
335 |
*/ |
232 |
void RecvOlsr (Ptr<Socket> socket); |
336 |
void RecvOlsr (Ptr<Socket> socket); |
233 |
|
337 |
|
|
|
338 |
/** |
339 |
* \brief Computates MPR set of a node following \RFC{3626} hints. |
340 |
*/ |
234 |
void MprComputation (); |
341 |
void MprComputation (); |
|
|
342 |
|
343 |
/** |
344 |
* \brief Creates the routing table of the node following \RFC{3626} hints. |
345 |
*/ |
235 |
void RoutingTableComputation (); |
346 |
void RoutingTableComputation (); |
|
|
347 |
|
348 |
/** |
349 |
* \brief Gets the main address associated with a given interface address. |
350 |
* \param iface_addr the interface address. |
351 |
* \return the corresponding main address. |
352 |
*/ |
236 |
Ipv4Address GetMainAddress (Ipv4Address iface_addr) const; |
353 |
Ipv4Address GetMainAddress (Ipv4Address iface_addr) const; |
|
|
354 |
|
355 |
/** |
356 |
* \brief Tests whether or not the specified route uses a non-OLSR outgoing interface. |
357 |
* \param route The route to be tested. |
358 |
* \returns True if the outgoing interface of the specified route is a non-OLSR interface, false otherwise. |
359 |
*/ |
237 |
bool UsesNonOlsrOutgoingInterface (const Ipv4RoutingTableEntry &route); |
360 |
bool UsesNonOlsrOutgoingInterface (const Ipv4RoutingTableEntry &route); |
238 |
|
361 |
|
239 |
// Timer handlers |
362 |
// Timer handlers |
240 |
Timer m_helloTimer; |
363 |
Timer m_helloTimer; //!< Timer for the HELLO message. |
|
|
364 |
/** |
365 |
* \brief Sends a HELLO message and reschedules the HELLO timer. |
366 |
*/ |
241 |
void HelloTimerExpire (); |
367 |
void HelloTimerExpire (); |
242 |
|
368 |
|
243 |
Timer m_tcTimer; |
369 |
Timer m_tcTimer; //!< Timer for the TC message. |
|
|
370 |
/** |
371 |
* \brief Sends a TC message (if there exists any MPR selector) and reschedules the TC timer. |
372 |
*/ |
244 |
void TcTimerExpire (); |
373 |
void TcTimerExpire (); |
245 |
|
374 |
|
246 |
Timer m_midTimer; |
375 |
Timer m_midTimer; //!< Timer for the MID message. |
|
|
376 |
/** |
377 |
* \brief \brief Sends a MID message (if the node has more than one interface) and resets the MID timer. |
378 |
*/ |
247 |
void MidTimerExpire (); |
379 |
void MidTimerExpire (); |
248 |
|
380 |
|
249 |
Timer m_hnaTimer; |
381 |
Timer m_hnaTimer; //!< Timer for the HNA message. |
|
|
382 |
/** |
383 |
* \brief Sends an HNA message (if the node has associated hosts/networks) and reschedules the HNA timer. |
384 |
*/ |
250 |
void HnaTimerExpire (); |
385 |
void HnaTimerExpire (); |
251 |
|
386 |
|
|
|
387 |
/** |
388 |
* \brief Removes tuple if expired. Else timer is rescheduled to expire at tuple.expirationTime. |
389 |
* |
390 |
* The task of actually removing the tuple is left to the OLSR agent. |
391 |
* |
392 |
* \param address The address of the tuple. |
393 |
* \param sequenceNumber The sequence number of the tuple. |
394 |
*/ |
252 |
void DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber); |
395 |
void DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber); |
253 |
bool m_linkTupleTimerFirstTime; |
396 |
|
|
|
397 |
bool m_linkTupleTimerFirstTime; //!< Flag to indicate if it is the first time the LinkTupleTimer fires. |
398 |
/** |
399 |
* \brief Removes tuple_ if expired. Else if symmetric time |
400 |
* has expired then it is assumed a neighbor loss and agent_->nb_loss() |
401 |
* is called. In this case the timer is rescheduled to expire at |
402 |
* tuple_->time(). Otherwise the timer is rescheduled to expire at |
403 |
* the minimum between tuple_->time() and tuple_->sym_time(). |
404 |
* |
405 |
* The task of actually removing the tuple is left to the OLSR agent. |
406 |
* |
407 |
* \param neighborIfaceAddr The tuple neighbor interface address. |
408 |
*/ |
254 |
void LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr); |
409 |
void LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr); |
|
|
410 |
|
411 |
/** |
412 |
* \brief Removes 2_hop neighbor tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time(). |
413 |
* |
414 |
* The task of actually removing the tuple is left to the OLSR agent. |
415 |
* |
416 |
* \param neighborMainAddr The neighbor main address. |
417 |
* \param twoHopNeighborAddr The 2-hop neighbor address. |
418 |
*/ |
255 |
void Nb2hopTupleTimerExpire (Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr); |
419 |
void Nb2hopTupleTimerExpire (Ipv4Address neighborMainAddr, Ipv4Address twoHopNeighborAddr); |
|
|
420 |
|
421 |
/** |
422 |
* \brief Removes MPR selector tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time(). |
423 |
* |
424 |
* The task of actually removing the tuple is left to the OLSR agent. |
425 |
* |
426 |
* \param mainAddr The tuple IPv4 address. |
427 |
*/ |
256 |
void MprSelTupleTimerExpire (Ipv4Address mainAddr); |
428 |
void MprSelTupleTimerExpire (Ipv4Address mainAddr); |
|
|
429 |
|
430 |
/** |
431 |
* \brief Removes topology tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time(). |
432 |
* |
433 |
* The task of actually removing the tuple is left to the OLSR agent. |
434 |
* |
435 |
* \param destAddr The destination address. |
436 |
* \param lastAddr The last address. |
437 |
*/ |
257 |
void TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr); |
438 |
void TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr); |
|
|
439 |
|
440 |
/** |
441 |
* \brief Removes interface association tuple_ if expired. Else the timer is rescheduled to expire at tuple_->time(). |
442 |
* |
443 |
* \param ifaceAddr The interface address. |
444 |
*/ |
258 |
void IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr); |
445 |
void IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr); |
|
|
446 |
|
447 |
/** |
448 |
* \brief Removes association tuple_ if expired. Else timer is rescheduled to expire at tuple_->time(). |
449 |
* |
450 |
* \param gatewayAddr The gateway address. |
451 |
* \param networkAddr The network address. |
452 |
* \param netmask The network mask. |
453 |
*/ |
259 |
void AssociationTupleTimerExpire (Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask); |
454 |
void AssociationTupleTimerExpire (Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask); |
260 |
|
455 |
|
|
|
456 |
/** |
457 |
* Increments the ANSN counter. |
458 |
*/ |
261 |
void IncrementAnsn (); |
459 |
void IncrementAnsn (); |
262 |
|
460 |
|
263 |
/// A list of pending messages which are buffered awaiting for being sent. |
461 |
/// A list of pending messages which are buffered awaiting for being sent. |
264 |
olsr::MessageList m_queuedMessages; |
462 |
olsr::MessageList m_queuedMessages; |
265 |
Timer m_queuedMessagesTimer; // timer for throttling outgoing messages |
463 |
Timer m_queuedMessagesTimer; //!< timer for throttling outgoing messages |
266 |
|
464 |
|
|
|
465 |
/** |
466 |
* \brief OLSR's default forwarding algorithm. |
467 |
* |
468 |
* See \RFC{3626} for details. |
469 |
* |
470 |
* \param olsrMessage The %OLSR message which must be forwarded. |
471 |
* \param duplicated NULL if the message has never been considered for forwarding, or a duplicate tuple in other case. |
472 |
* \param localIface The address of the interface where the message was received from. |
473 |
* \param senderAddress The sender IPv4 address. |
474 |
*/ |
267 |
void ForwardDefault (olsr::MessageHeader olsrMessage, |
475 |
void ForwardDefault (olsr::MessageHeader olsrMessage, |
268 |
DuplicateTuple *duplicated, |
476 |
DuplicateTuple *duplicated, |
269 |
const Ipv4Address &localIface, |
477 |
const Ipv4Address &localIface, |
270 |
const Ipv4Address &senderAddress); |
478 |
const Ipv4Address &senderAddress); |
|
|
479 |
|
480 |
/** |
481 |
* \brief Enques an %OLSR message which will be sent with a delay of (0, delay]. |
482 |
* |
483 |
* This buffering system is used in order to piggyback several %OLSR messages in |
484 |
* a same %OLSR packet. |
485 |
* |
486 |
* \param message the %OLSR message which must be sent. |
487 |
* \param delay maximum delay the %OLSR message is going to be buffered. |
488 |
*/ |
271 |
void QueueMessage (const olsr::MessageHeader &message, Time delay); |
489 |
void QueueMessage (const olsr::MessageHeader &message, Time delay); |
|
|
490 |
|
491 |
/** |
492 |
* \brief Creates as many %OLSR packets as needed in order to send all buffered |
493 |
* %OLSR messages. |
494 |
* |
495 |
* Maximum number of messages which can be contained in an %OLSR packet is |
496 |
* dictated by OLSR_MAX_MSGS constant. |
497 |
*/ |
272 |
void SendQueuedMessages (); |
498 |
void SendQueuedMessages (); |
273 |
void SendHello (); |
499 |
|
|
|
500 |
/** |
501 |
* \brief Creates a new %OLSR HELLO message which is buffered for being sent later on. |
502 |
*/ |
503 |
void SendHello (); |
504 |
|
505 |
/** |
506 |
* \brief Creates a new %OLSR TC message which is buffered for being sent later on. |
507 |
*/ |
274 |
void SendTc (); |
508 |
void SendTc (); |
|
|
509 |
|
510 |
/** |
511 |
* \brief Creates a new %OLSR MID message which is buffered for being sent later on. |
512 |
*/ |
275 |
void SendMid (); |
513 |
void SendMid (); |
|
|
514 |
|
515 |
/** |
516 |
* \brief Creates a new %OLSR HNA message which is buffered for being sent later on. |
517 |
*/ |
276 |
void SendHna (); |
518 |
void SendHna (); |
277 |
|
519 |
|
|
|
520 |
/** |
521 |
* \brief Performs all actions needed when a neighbor loss occurs. |
522 |
* |
523 |
* Neighbor Set, 2-hop Neighbor Set, MPR Set and MPR Selector Set are updated. |
524 |
* |
525 |
* \param tuple link tuple with the information of the link to the neighbor which has been lost. |
526 |
*/ |
278 |
void NeighborLoss (const LinkTuple &tuple); |
527 |
void NeighborLoss (const LinkTuple &tuple); |
|
|
528 |
|
529 |
/** |
530 |
* \brief Adds a duplicate tuple to the Duplicate Set. |
531 |
* |
532 |
* \param tuple The duplicate tuple to be added. |
533 |
*/ |
279 |
void AddDuplicateTuple (const DuplicateTuple &tuple); |
534 |
void AddDuplicateTuple (const DuplicateTuple &tuple); |
|
|
535 |
|
536 |
/** |
537 |
* \brief Removes a duplicate tuple from the Duplicate Set. |
538 |
* |
539 |
* \param tuple The duplicate tuple to be removed. |
540 |
*/ |
280 |
void RemoveDuplicateTuple (const DuplicateTuple &tuple); |
541 |
void RemoveDuplicateTuple (const DuplicateTuple &tuple); |
|
|
542 |
|
543 |
/** |
544 |
* Adds a link tuple. |
545 |
* \param tuple Thetuple to be added. |
546 |
* \param willingness The tuple willingness. |
547 |
*/ |
281 |
void LinkTupleAdded (const LinkTuple &tuple, uint8_t willingness); |
548 |
void LinkTupleAdded (const LinkTuple &tuple, uint8_t willingness); |
|
|
549 |
|
550 |
/** |
551 |
* \brief Removes a link tuple from the Link Set. |
552 |
* |
553 |
* \param tuple The link tuple to be removed. |
554 |
*/ |
282 |
void RemoveLinkTuple (const LinkTuple &tuple); |
555 |
void RemoveLinkTuple (const LinkTuple &tuple); |
|
|
556 |
|
557 |
/** |
558 |
* \brief This function is invoked when a link tuple is updated. Its aim is to |
559 |
* also update the corresponding neighbor tuple if it is needed. |
560 |
* |
561 |
* \param tuple The link tuple which has been updated. |
562 |
* \param willingness The tuple willingness. |
563 |
*/ |
283 |
void LinkTupleUpdated (const LinkTuple &tuple, uint8_t willingness); |
564 |
void LinkTupleUpdated (const LinkTuple &tuple, uint8_t willingness); |
|
|
565 |
|
566 |
/** |
567 |
* \brief Adds a neighbor tuple to the Neighbor Set. |
568 |
* |
569 |
* \param tuple The neighbor tuple to be added. |
570 |
*/ |
284 |
void AddNeighborTuple (const NeighborTuple &tuple); |
571 |
void AddNeighborTuple (const NeighborTuple &tuple); |
|
|
572 |
|
573 |
/** |
574 |
* \brief Removes a neighbor tuple from the Neighbor Set. |
575 |
* |
576 |
* \param tuple The neighbor tuple to be removed. |
577 |
*/ |
285 |
void RemoveNeighborTuple (const NeighborTuple &tuple); |
578 |
void RemoveNeighborTuple (const NeighborTuple &tuple); |
|
|
579 |
|
580 |
/** |
581 |
* \brief Adds a 2-hop neighbor tuple to the 2-hop Neighbor Set. |
582 |
* |
583 |
* \param tuple The 2-hop neighbor tuple to be added. |
584 |
*/ |
286 |
void AddTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple); |
585 |
void AddTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple); |
|
|
586 |
|
587 |
/** |
588 |
* \brief Removes a 2-hop neighbor tuple from the 2-hop Neighbor Set. |
589 |
* |
590 |
* \param tuple The 2-hop neighbor tuple to be removed. |
591 |
*/ |
287 |
void RemoveTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple); |
592 |
void RemoveTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple); |
|
|
593 |
|
594 |
/** |
595 |
* \brief Adds an MPR selector tuple to the MPR Selector Set. |
596 |
* Advertised Neighbor Sequence Number (ANSN) is also updated. |
597 |
* |
598 |
* \param tuple The MPR selector tuple to be added. |
599 |
*/ |
288 |
void AddMprSelectorTuple (const MprSelectorTuple &tuple); |
600 |
void AddMprSelectorTuple (const MprSelectorTuple &tuple); |
|
|
601 |
|
602 |
/** |
603 |
* \brief Removes an MPR selector tuple from the MPR Selector Set. |
604 |
* Advertised Neighbor Sequence Number (ANSN) is also updated. |
605 |
* |
606 |
* \param tuple The MPR selector tuple to be removed. |
607 |
*/ |
289 |
void RemoveMprSelectorTuple (const MprSelectorTuple &tuple); |
608 |
void RemoveMprSelectorTuple (const MprSelectorTuple &tuple); |
|
|
609 |
|
610 |
/** |
611 |
* \brief Adds a topology tuple to the Topology Set. |
612 |
* |
613 |
* \param tuple The topology tuple to be added. |
614 |
*/ |
290 |
void AddTopologyTuple (const TopologyTuple &tuple); |
615 |
void AddTopologyTuple (const TopologyTuple &tuple); |
|
|
616 |
|
617 |
/** |
618 |
* \brief Removes a topology tuple to the Topology Set. |
619 |
* |
620 |
* \param tuple The topology tuple to be removed. |
621 |
*/ |
291 |
void RemoveTopologyTuple (const TopologyTuple &tuple); |
622 |
void RemoveTopologyTuple (const TopologyTuple &tuple); |
|
|
623 |
|
624 |
/** |
625 |
* \brief Adds an interface association tuple to the Interface Association Set. |
626 |
* |
627 |
* \param tuple The interface association tuple to be added. |
628 |
*/ |
292 |
void AddIfaceAssocTuple (const IfaceAssocTuple &tuple); |
629 |
void AddIfaceAssocTuple (const IfaceAssocTuple &tuple); |
|
|
630 |
|
631 |
/** |
632 |
* \brief Removed an interface association tuple to the Interface Association Set. |
633 |
* |
634 |
* \param tuple The interface association tuple to be removed. |
635 |
*/ |
293 |
void RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple); |
636 |
void RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple); |
|
|
637 |
|
638 |
/** |
639 |
* \brief Adds a host network association tuple to the Association Set. |
640 |
* |
641 |
* \param tuple The host network association tuple to be added. |
642 |
*/ |
294 |
void AddAssociationTuple (const AssociationTuple &tuple); |
643 |
void AddAssociationTuple (const AssociationTuple &tuple); |
|
|
644 |
|
645 |
/** |
646 |
* \brief Removes a host network association tuple to the Association Set. |
647 |
* |
648 |
* \param tuple The host network association tuple to be removed. |
649 |
*/ |
295 |
void RemoveAssociationTuple (const AssociationTuple &tuple); |
650 |
void RemoveAssociationTuple (const AssociationTuple &tuple); |
296 |
|
651 |
|
|
|
652 |
/** |
653 |
* \brief Processes a HELLO message following \RFC{3626} specification. |
654 |
* |
655 |
* Link sensing and population of the Neighbor Set, 2-hop Neighbor Set and MPR |
656 |
* Selector Set are performed. |
657 |
* |
658 |
* \param msg the %OLSR message which contains the HELLO message. |
659 |
* \param receiverIface the address of the interface where the message was received from. |
660 |
* \param senderIface the address of the interface where the message was sent from. |
661 |
*/ |
297 |
void ProcessHello (const olsr::MessageHeader &msg, |
662 |
void ProcessHello (const olsr::MessageHeader &msg, |
298 |
const Ipv4Address &receiverIface, |
663 |
const Ipv4Address &receiverIface, |
299 |
const Ipv4Address &senderIface); |
664 |
const Ipv4Address &senderIface); |
|
|
665 |
|
666 |
/** |
667 |
* \brief Processes a TC message following \RFC{3626} specification. |
668 |
* |
669 |
* The Topology Set is updated (if needed) with the information of |
670 |
* the received TC message. |
671 |
* |
672 |
* \param msg The %OLSR message which contains the TC message. |
673 |
* \param senderIface The address of the interface where the message was sent from. |
674 |
* |
675 |
*/ |
300 |
void ProcessTc (const olsr::MessageHeader &msg, |
676 |
void ProcessTc (const olsr::MessageHeader &msg, |
301 |
const Ipv4Address &senderIface); |
677 |
const Ipv4Address &senderIface); |
|
|
678 |
|
679 |
/** |
680 |
* \brief Processes a MID message following \RFC{3626} specification. |
681 |
* |
682 |
* The Interface Association Set is updated (if needed) with the information |
683 |
* of the received MID message. |
684 |
* |
685 |
* \param msg the %OLSR message which contains the MID message. |
686 |
* \param senderIface the address of the interface where the message was sent from. |
687 |
*/ |
302 |
void ProcessMid (const olsr::MessageHeader &msg, |
688 |
void ProcessMid (const olsr::MessageHeader &msg, |
303 |
const Ipv4Address &senderIface); |
689 |
const Ipv4Address &senderIface); |
|
|
690 |
|
691 |
/** |
692 |
* |
693 |
* \brief Processes a HNA message following \RFC{3626} specification. |
694 |
* |
695 |
* The Host Network Association Set is updated (if needed) with the information |
696 |
* of the received HNA message. |
697 |
* |
698 |
* \param msg the %OLSR message which contains the HNA message. |
699 |
* \param senderIface the address of the interface where the message was sent from. |
700 |
* |
701 |
*/ |
304 |
void ProcessHna (const olsr::MessageHeader &msg, |
702 |
void ProcessHna (const olsr::MessageHeader &msg, |
305 |
const Ipv4Address &senderIface); |
703 |
const Ipv4Address &senderIface); |
306 |
|
704 |
|
|
|
705 |
/** |
706 |
* \brief Updates Link Set according to a new received HELLO message |
707 |
* (following \RFC{3626} specification). Neighbor Set is also updated if needed. |
708 |
* \param msg The received message. |
709 |
* \param hello The received HELLO sub-message. |
710 |
* \param receiverIface The interface that received the message. |
711 |
* \param senderIface The sender interface. |
712 |
*/ |
307 |
void LinkSensing (const olsr::MessageHeader &msg, |
713 |
void LinkSensing (const olsr::MessageHeader &msg, |
308 |
const olsr::MessageHeader::Hello &hello, |
714 |
const olsr::MessageHeader::Hello &hello, |
309 |
const Ipv4Address &receiverIface, |
715 |
const Ipv4Address &receiverIface, |
310 |
const Ipv4Address &sender_iface); |
716 |
const Ipv4Address &senderIface); |
|
|
717 |
|
718 |
/** |
719 |
* \brief Updates the Neighbor Set according to the information contained in |
720 |
* a new received HELLO message (following \RFC{3626}). |
721 |
* \param msg The received message. |
722 |
* \param hello The received HELLO sub-message. |
723 |
*/ |
311 |
void PopulateNeighborSet (const olsr::MessageHeader &msg, |
724 |
void PopulateNeighborSet (const olsr::MessageHeader &msg, |
312 |
const olsr::MessageHeader::Hello &hello); |
725 |
const olsr::MessageHeader::Hello &hello); |
|
|
726 |
|
727 |
/** |
728 |
* \brief Updates the 2-hop Neighbor Set according to the information contained |
729 |
* in a new received HELLO message (following \RFC{3626}). |
730 |
* \param msg The received message. |
731 |
* \param hello The received HELLO sub-message. |
732 |
*/ |
313 |
void PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg, |
733 |
void PopulateTwoHopNeighborSet (const olsr::MessageHeader &msg, |
314 |
const olsr::MessageHeader::Hello &hello); |
734 |
const olsr::MessageHeader::Hello &hello); |
|
|
735 |
|
736 |
/** |
737 |
* \brief Updates the MPR Selector Set according to the information contained in |
738 |
* a new received HELLO message (following \RFC{3626}). |
739 |
* \param msg The received message. |
740 |
* \param hello The received HELLO sub-message. |
741 |
*/ |
315 |
void PopulateMprSelectorSet (const olsr::MessageHeader &msg, |
742 |
void PopulateMprSelectorSet (const olsr::MessageHeader &msg, |
316 |
const olsr::MessageHeader::Hello &hello); |
743 |
const olsr::MessageHeader::Hello &hello); |
317 |
|
744 |
|
|
319 |
/// Check that address is one of my interfaces |
746 |
/// Check that address is one of my interfaces |
320 |
bool IsMyOwnAddress (const Ipv4Address & a) const; |
747 |
bool IsMyOwnAddress (const Ipv4Address & a) const; |
321 |
|
748 |
|
322 |
Ipv4Address m_mainAddress; |
749 |
Ipv4Address m_mainAddress; //!< the node main address. |
323 |
|
750 |
|
324 |
// One socket per interface, each bound to that interface's address |
751 |
// One socket per interface, each bound to that interface's address |
325 |
// (reason: for OLSR Link Sensing we need to know on which interface |
752 |
// (reason: for OLSR Link Sensing we need to know on which interface |
326 |
// HELLO messages arrive) |
753 |
// HELLO messages arrive) |
327 |
std::map< Ptr<Socket>, Ipv4InterfaceAddress > m_socketAddresses; |
754 |
std::map< Ptr<Socket>, Ipv4InterfaceAddress > m_socketAddresses; //!< Container of sockets and the interfaces they are opened onto. |
328 |
|
755 |
|
329 |
TracedCallback <const PacketHeader &, |
756 |
/// Rx packet trace. |
330 |
const MessageList &> m_rxPacketTrace; |
757 |
TracedCallback <const PacketHeader &, const MessageList &> m_rxPacketTrace; |
331 |
TracedCallback <const PacketHeader &, |
758 |
|
332 |
const MessageList &> m_txPacketTrace; |
759 |
/// Tx packet trace. |
|
|
760 |
TracedCallback <const PacketHeader &, const MessageList &> m_txPacketTrace; |
761 |
|
762 |
/// Routing table chanes challback |
333 |
TracedCallback <uint32_t> m_routingTableChanged; |
763 |
TracedCallback <uint32_t> m_routingTableChanged; |
334 |
|
764 |
|
335 |
/// Provides uniform random variables. |
765 |
/// Provides uniform random variables. |