A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
aodv-neighbor.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 IITP RAS
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Based on
7 * NS-2 AODV model developed by the CMU/MONARCH group and optimized and
8 * tuned by Samir Das and Mahesh Marina, University of Cincinnati;
9 *
10 * AODV-UU implementation by Erik Nordström of Uppsala University
11 * https://web.archive.org/web/20100527072022/http://core.it.uu.se/core/index.php/AODV-UU
12 *
13 * Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
14 * Pavel Boyko <boyko@iitp.ru>
15 */
16
17#ifndef AODVNEIGHBOR_H
18#define AODVNEIGHBOR_H
19
20#include "ns3/arp-cache.h"
21#include "ns3/callback.h"
22#include "ns3/ipv4-address.h"
23#include "ns3/simulator.h"
24#include "ns3/timer.h"
25
26#include <vector>
27
28namespace ns3
29{
30
31class WifiMacHeader;
32
33namespace aodv
34{
35
36class RoutingProtocol;
37
38/**
39 * \ingroup aodv
40 * \brief maintain list of active neighbors
41 */
43{
44 public:
45 /**
46 * constructor
47 * \param delay the delay time for purging the list of neighbors
48 */
49 Neighbors(Time delay);
50
51 /// Neighbor description
52 struct Neighbor
53 {
54 /// Neighbor IPv4 address
56 /// Neighbor MAC address
58 /// Neighbor expire time
60 /// Neighbor close indicator
61 bool close;
62
63 /**
64 * \brief Neighbor structure constructor
65 *
66 * \param ip Ipv4Address entry
67 * \param mac Mac48Address entry
68 * \param t Time expire time
69 */
73 m_expireTime(t),
74 close(false)
75 {
76 }
77 };
78
79 /**
80 * Return expire time for neighbor node with address addr, if exists, else return 0.
81 * \param addr the IP address of the neighbor node
82 * \returns the expire time for the neighbor node
83 */
85 /**
86 * Check that node with address addr is neighbor
87 * \param addr the IP address to check
88 * \returns true if the node with IP address is a neighbor
89 */
90 bool IsNeighbor(Ipv4Address addr);
91 /**
92 * Update expire time for entry with address addr, if it exists, else add new entry
93 * \param addr the IP address to check
94 * \param expire the expire time for the address
95 */
96 void Update(Ipv4Address addr, Time expire);
97 /// Remove all expired entries
98 void Purge();
99 /// Schedule m_ntimer.
100 void ScheduleTimer();
101
102 /// Remove all entries
103 void Clear()
104 {
105 m_nb.clear();
106 }
107
108 /**
109 * Add ARP cache to be used to allow layer 2 notifications processing
110 * \param a pointer to the ARP cache to add
111 */
113 /**
114 * Don't use given ARP cache any more (interface is down)
115 * \param a pointer to the ARP cache to delete
116 */
118
119 /**
120 * Get callback to ProcessTxError
121 * \returns the callback function
122 */
127
128 /**
129 * Set link failure callback
130 * \param cb the callback function
131 */
136
137 /**
138 * Get link failure callback
139 * \returns the link failure callback
140 */
145
146 private:
147 /// link failure callback
149 /// TX error callback
151 /// Timer for neighbor's list. Schedule Purge().
153 /// vector of entries
154 std::vector<Neighbor> m_nb;
155 /// list of ARP cached to be used for layer 2 notifications processing
156 std::vector<Ptr<ArpCache>> m_arp;
157
158 /**
159 * Find MAC address by IP using list of ARP caches
160 *
161 * \param addr the IP address to lookup
162 * \returns the MAC address for the IP address
163 */
165 /**
166 * Process layer 2 TX error notification
167 * \param hdr header of the packet
168 */
169 void ProcessTxError(const WifiMacHeader& hdr);
170};
171
172} // namespace aodv
173} // namespace ns3
174
175#endif /* AODVNEIGHBOR_H */
Callback template class.
Definition callback.h:422
Ipv4 addresses are stored in host order in this class.
an EUI-48 address
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
A simple virtual Timer class.
Definition timer.h:67
Implements the IEEE 802.11 MAC header.
maintain list of active neighbors
Time GetExpireTime(Ipv4Address addr)
Return expire time for neighbor node with address addr, if exists, else return 0.
void ScheduleTimer()
Schedule m_ntimer.
Neighbors(Time delay)
constructor
void Clear()
Remove all entries.
Callback< void, const WifiMacHeader & > m_txErrorCallback
TX error callback.
void Purge()
Remove all expired entries.
std::vector< Ptr< ArpCache > > m_arp
list of ARP cached to be used for layer 2 notifications processing
Mac48Address LookupMacAddress(Ipv4Address addr)
Find MAC address by IP using list of ARP caches.
Callback< void, Ipv4Address > GetCallback() const
Get link failure callback.
void Update(Ipv4Address addr, Time expire)
Update expire time for entry with address addr, if it exists, else add new entry.
std::vector< Neighbor > m_nb
vector of entries
Timer m_ntimer
Timer for neighbor's list. Schedule Purge().
Callback< void, const WifiMacHeader & > GetTxErrorCallback() const
Get callback to ProcessTxError.
Callback< void, Ipv4Address > m_handleLinkFailure
link failure callback
void SetCallback(Callback< void, Ipv4Address > cb)
Set link failure callback.
void ProcessTxError(const WifiMacHeader &hdr)
Process layer 2 TX error notification.
void DelArpCache(Ptr< ArpCache > a)
Don't use given ARP cache any more (interface is down)
bool IsNeighbor(Ipv4Address addr)
Check that node with address addr is neighbor.
void AddArpCache(Ptr< ArpCache > a)
Add ARP cache to be used to allow layer 2 notifications processing.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Neighbor description.
bool close
Neighbor close indicator.
Neighbor(Ipv4Address ip, Mac48Address mac, Time t)
Neighbor structure constructor.
Mac48Address m_hardwareAddress
Neighbor MAC address.
Ipv4Address m_neighborAddress
Neighbor IPv4 address.
Time m_expireTime
Neighbor expire time.