A Discrete-Event Network Simulator
API
aodv-neighbor.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 IITP RAS
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Based on
19  * NS-2 AODV model developed by the CMU/MONARCH group and optimized and
20  * tuned by Samir Das and Mahesh Marina, University of Cincinnati;
21  *
22  * AODV-UU implementation by Erik Nordström of Uppsala University
23  * http://core.it.uu.se/core/index.php/AODV-UU
24  *
25  * Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
26  * Pavel Boyko <boyko@iitp.ru>
27  */
28 
29 #ifndef AODVNEIGHBOR_H
30 #define AODVNEIGHBOR_H
31 
32 #include "ns3/simulator.h"
33 #include "ns3/timer.h"
34 #include "ns3/ipv4-address.h"
35 #include "ns3/callback.h"
36 #include "ns3/wifi-mac-header.h"
37 #include "ns3/arp-cache.h"
38 #include <vector>
39 
40 namespace ns3 {
41 namespace aodv {
42 class RoutingProtocol;
47 class Neighbors
48 {
49 public:
54  Neighbors (Time delay);
56  struct Neighbor
57  {
65  bool close;
66 
75  : m_neighborAddress (ip),
76  m_hardwareAddress (mac),
77  m_expireTime (t),
78  close (false)
79  {
80  }
81  };
93  bool IsNeighbor (Ipv4Address addr);
99  void Update (Ipv4Address addr, Time expire);
101  void Purge ();
103  void ScheduleTimer ();
105  void Clear ()
106  {
107  m_nb.clear ();
108  }
109 
114  void AddArpCache (Ptr<ArpCache> a);
119  void DelArpCache (Ptr<ArpCache> a);
125  {
126  return m_txErrorCallback;
127  }
128 
134  {
135  m_handleLinkFailure = cb;
136  }
142  {
143  return m_handleLinkFailure;
144  }
145 
146 private:
154  std::vector<Neighbor> m_nb;
156  std::vector<Ptr<ArpCache> > m_arp;
157 
166  void ProcessTxError (WifiMacHeader const &);
167 };
168 
169 } // namespace aodv
170 } // namespace ns3
171 
172 #endif /* AODVNEIGHBOR_H */
maintain list of active neighbors
Definition: aodv-neighbor.h:47
Callback< void, WifiMacHeader const & > m_txErrorCallback
TX error callback.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Mac48Address m_hardwareAddress
Neighbor MAC address.
Definition: aodv-neighbor.h:61
Timer m_ntimer
Timer for neighbor's list. Schedule Purge().
Callback template class.
Definition: callback.h:1176
A simple Timer class.
Definition: timer.h:73
Callback< void, Ipv4Address > GetCallback() const
Get link failure callback.
Neighbors(Time delay)
constructor
void Purge()
Remove all expired entries.
std::vector< Ptr< ArpCache > > m_arp
list of ARP cached to be used for layer 2 notifications processing
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.
bool close
Neighbor close indicator.
Definition: aodv-neighbor.h:65
tuple mac
Definition: third.py:92
Callback< void, WifiMacHeader const & > GetTxErrorCallback() const
Get callback to ProcessTxError.
void Clear()
Remove all entries.
Mac48Address LookupMacAddress(Ipv4Address addr)
Find MAC address by IP using list of ARP caches.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::vector< Neighbor > m_nb
vector of entries
an EUI-48 address
Definition: mac48-address.h:43
Neighbor description.
Definition: aodv-neighbor.h:56
void Update(Ipv4Address addr, Time expire)
Update expire time for entry with address addr, if it exists, else add new entry. ...
Callback< void, Ipv4Address > m_handleLinkFailure
link failure callback
Time GetExpireTime(Ipv4Address addr)
Return expire time for neighbor node with address addr, if exists, else return 0. ...
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
void ProcessTxError(WifiMacHeader const &)
Process layer 2 TX error notification.
Neighbor(Ipv4Address ip, Mac48Address mac, Time t)
Neighbor structure constructor.
Definition: aodv-neighbor.h:74
void SetCallback(Callback< void, Ipv4Address > cb)
Set link failure callback.
Time m_expireTime
Neighbor expire time.
Definition: aodv-neighbor.h:63
void AddArpCache(Ptr< ArpCache > a)
Add ARP cache to be used to allow layer 2 notifications processing.
Ipv4Address m_neighborAddress
Neighbor IPv4 address.
Definition: aodv-neighbor.h:59
Implements the IEEE 802.11 MAC header.
void ScheduleTimer()
Schedule m_ntimer.