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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Based on
18 * NS-2 AODV model developed by the CMU/MONARCH group and optimized and
19 * tuned by Samir Das and Mahesh Marina, University of Cincinnati;
20 *
21 * AODV-UU implementation by Erik Nordström of Uppsala University
22 * https://web.archive.org/web/20100527072022/http://core.it.uu.se/core/index.php/AODV-UU
23 *
24 * Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
25 * Pavel Boyko <boyko@iitp.ru>
26 */
27
28#ifndef AODVNEIGHBOR_H
29#define AODVNEIGHBOR_H
30
31#include "ns3/arp-cache.h"
32#include "ns3/callback.h"
33#include "ns3/ipv4-address.h"
34#include "ns3/simulator.h"
35#include "ns3/timer.h"
36
37#include <vector>
38
39namespace ns3
40{
41
42class WifiMacHeader;
43
44namespace aodv
45{
46
47class RoutingProtocol;
48
49/**
50 * \ingroup aodv
51 * \brief maintain list of active neighbors
52 */
54{
55 public:
56 /**
57 * constructor
58 * \param delay the delay time for purging the list of neighbors
59 */
60 Neighbors(Time delay);
61
62 /// Neighbor description
63 struct Neighbor
64 {
65 /// Neighbor IPv4 address
67 /// Neighbor MAC address
69 /// Neighbor expire time
71 /// Neighbor close indicator
72 bool close;
73
74 /**
75 * \brief Neighbor structure constructor
76 *
77 * \param ip Ipv4Address entry
78 * \param mac Mac48Address entry
79 * \param t Time expire time
80 */
84 m_expireTime(t),
85 close(false)
86 {
87 }
88 };
89
90 /**
91 * Return expire time for neighbor node with address addr, if exists, else return 0.
92 * \param addr the IP address of the neighbor node
93 * \returns the expire time for the neighbor node
94 */
96 /**
97 * Check that node with address addr is neighbor
98 * \param addr the IP address to check
99 * \returns true if the node with IP address is a neighbor
100 */
101 bool IsNeighbor(Ipv4Address addr);
102 /**
103 * Update expire time for entry with address addr, if it exists, else add new entry
104 * \param addr the IP address to check
105 * \param expire the expire time for the address
106 */
107 void Update(Ipv4Address addr, Time expire);
108 /// Remove all expired entries
109 void Purge();
110 /// Schedule m_ntimer.
111 void ScheduleTimer();
112
113 /// Remove all entries
114 void Clear()
115 {
116 m_nb.clear();
117 }
118
119 /**
120 * Add ARP cache to be used to allow layer 2 notifications processing
121 * \param a pointer to the ARP cache to add
122 */
124 /**
125 * Don't use given ARP cache any more (interface is down)
126 * \param a pointer to the ARP cache to delete
127 */
129
130 /**
131 * Get callback to ProcessTxError
132 * \returns the callback function
133 */
135 {
136 return m_txErrorCallback;
137 }
138
139 /**
140 * Set link failure callback
141 * \param cb the callback function
142 */
144 {
146 }
147
148 /**
149 * Get link failure callback
150 * \returns the link failure callback
151 */
153 {
154 return m_handleLinkFailure;
155 }
156
157 private:
158 /// link failure callback
160 /// TX error callback
162 /// Timer for neighbor's list. Schedule Purge().
164 /// vector of entries
165 std::vector<Neighbor> m_nb;
166 /// list of ARP cached to be used for layer 2 notifications processing
167 std::vector<Ptr<ArpCache>> m_arp;
168
169 /**
170 * Find MAC address by IP using list of ARP caches
171 *
172 * \param addr the IP address to lookup
173 * \returns the MAC address for the IP address
174 */
176 /**
177 * Process layer 2 TX error notification
178 * \param hdr header of the packet
179 */
180 void ProcessTxError(const WifiMacHeader& hdr);
181};
182
183} // namespace aodv
184} // namespace ns3
185
186#endif /* AODVNEIGHBOR_H */
Callback template class.
Definition: callback.h:438
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
an EUI-48 address
Definition: mac48-address.h:46
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
A simple virtual Timer class.
Definition: timer.h:78
Implements the IEEE 802.11 MAC header.
maintain list of active neighbors
Definition: aodv-neighbor.h:54
Time GetExpireTime(Ipv4Address addr)
Return expire time for neighbor node with address addr, if exists, else return 0.
void ScheduleTimer()
Schedule m_ntimer.
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.
Definition: aodv-neighbor.h:64
bool close
Neighbor close indicator.
Definition: aodv-neighbor.h:72
Neighbor(Ipv4Address ip, Mac48Address mac, Time t)
Neighbor structure constructor.
Definition: aodv-neighbor.h:81
Mac48Address m_hardwareAddress
Neighbor MAC address.
Definition: aodv-neighbor.h:68
Ipv4Address m_neighborAddress
Neighbor IPv4 address.
Definition: aodv-neighbor.h:66
Time m_expireTime
Neighbor expire time.
Definition: aodv-neighbor.h:70