A Discrete-Event Network Simulator
API
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 
39 namespace ns3
40 {
41 
42 class WifiMacHeader;
43 
44 namespace aodv
45 {
46 
47 class RoutingProtocol;
48 
53 class Neighbors
54 {
55  public:
60  Neighbors(Time delay);
61 
63  struct Neighbor
64  {
72  bool close;
73 
82  : m_neighborAddress(ip),
84  m_expireTime(t),
85  close(false)
86  {
87  }
88  };
89 
101  bool IsNeighbor(Ipv4Address addr);
107  void Update(Ipv4Address addr, Time expire);
109  void Purge();
111  void ScheduleTimer();
112 
114  void Clear()
115  {
116  m_nb.clear();
117  }
118 
123  void AddArpCache(Ptr<ArpCache> a);
128  void DelArpCache(Ptr<ArpCache> a);
129 
135  {
136  return m_txErrorCallback;
137  }
138 
144  {
145  m_handleLinkFailure = cb;
146  }
147 
153  {
154  return m_handleLinkFailure;
155  }
156 
157  private:
165  std::vector<Neighbor> m_nb;
167  std::vector<Ptr<ArpCache>> m_arp;
168 
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
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
A simple virtual Timer class.
Definition: timer.h:74
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.
Callback< void, const WifiMacHeader & > GetTxErrorCallback() const
Get callback to ProcessTxError.
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.
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
Callback< void, Ipv4Address > GetCallback() const
Get link failure callback.
Timer m_ntimer
Timer for neighbor's list. Schedule Purge().
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.
mac
Definition: third.py:92
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