A Discrete-Event Network Simulator
API
dsr-rreq-table.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 Yufei Cheng
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  * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
19  *
20  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21  * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22  * Information and Telecommunication Technology Center (ITTC)
23  * and Department of Electrical Engineering and Computer Science
24  * The University of Kansas Lawrence, KS USA.
25  *
26  * Work supported in part by NSF FIND (Future Internet Design) Program
27  * under grant CNS-0626918 (Postmodern Internet Architecture),
28  * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29  * US Department of Defense (DoD), and ITTC at The University of Kansas.
30  */
31 
32 #ifndef DSR_RREQ_TABLE_H
33 #define DSR_RREQ_TABLE_H
34 
35 #include "ns3/simulator.h"
36 #include "ns3/timer.h"
37 #include "ns3/ipv4-address.h"
38 #include "ns3/callback.h"
39 #include <list>
40 #include <vector>
41 #include <map>
42 
43 namespace ns3 {
44 namespace dsr {
45 
50 {
51  PROBABLE = 0,
53 };
55 struct BlackList
56 {
60 
68  : m_neighborAddress (ip),
69  m_expireTime (t),
70  m_linkStates (PROBABLE)
71  {
72  }
73 };
78 {
79  uint32_t m_reqNo;
81 };
87 {
88 public:
95  DsrReceivedRreqEntry (Ipv4Address d = Ipv4Address (), uint16_t i = 0)
96  : m_destination (d),
98  {
99  }
105  bool operator== (DsrReceivedRreqEntry const & o) const
106  {
108  );
109  }
110 
117  {
118  return m_destination;
119  }
126  {
127  m_destination = d;
128  }
135  {
136  return m_source;
137  }
144  {
145  m_source = s;
146  }
152  uint16_t GetIdentification () const
153  {
154  return m_identification;
155  }
161  void SetIdentification (uint16_t i)
162  {
163  m_identification = i;
164  }
172  void SetExpireTime (Time exp)
173  {
174  m_expire = exp + Simulator::Now ();
175  }
184  {
185  return m_expire - Simulator::Now ();
186  }
187  // \}
188 private:
191  uint16_t m_identification;
193 };
194 
199 class DsrRreqTable : public Object
200 {
201 public:
202 
203  static TypeId GetTypeId ();
204 
205  DsrRreqTable ();
206  virtual ~DsrRreqTable ();
207 
213  void SetInitHopLimit (uint32_t hl)
214  {
215  m_initHopLimit = hl;
216  }
222  uint32_t GetInitHopLimit () const
223  {
224  return m_initHopLimit;
225  }
232  void SetRreqTableSize (uint32_t rt)
233  {
234  m_requestTableSize = rt;
235  }
242  uint32_t GetRreqTableSize () const
243  {
244  return m_requestTableSize;
245  }
252  void SetRreqIdSize (uint32_t id)
253  {
254  m_requestIdSize = id;
255  }
262  uint32_t GetRreqIdSize () const
263  {
264  return m_requestIdSize;
265  }
272  void SetUniqueRreqIdSize (uint32_t uid)
273  {
274  m_maxRreqId = uid;
275  }
282  uint32_t GetUniqueRreqIdSize () const
283  {
284  return m_maxRreqId;
285  }
286 
288  void RemoveLeastExpire (std::map<Ipv4Address, RreqTableEntry > & rreqDstMap);
290  void FindAndUpdate (Ipv4Address dst);
292  void RemoveRreqEntry (Ipv4Address dst);
294  uint32_t GetRreqCnt (Ipv4Address dst);
295 
303  uint32_t CheckUniqueRreqId (Ipv4Address dst);
309  uint32_t GetRreqSize ();
310 
314  void Invalidate ();
327  bool MarkLinkAsUnidirectional (Ipv4Address neighbor, Time blacklistTimeout);
331  void PurgeNeighbor ();
332 
340  bool FindSourceEntry (Ipv4Address src, Ipv4Address dst, uint16_t id);
341 
342 private:
352  uint32_t m_initHopLimit;
356  uint32_t m_requestIdSize;
358  uint32_t m_maxRreqId;
362  std::list<DsrReceivedRreqEntry> m_sourceRequests;
364  std::map<Ipv4Address, uint32_t> m_rreqIdCache;
366  std::map<Ipv4Address, RreqTableEntry > m_rreqDstMap;
368  std::map<Ipv4Address, std::list<DsrReceivedRreqEntry> > m_sourceRreqMap;
369 
371  std::vector<BlackList> m_blackList;
373  struct IsExpired
374  {
381  bool operator() (const struct BlackList & b) const
382  {
383  return (b.m_expireTime < Simulator::Now ());
384  }
385  };
386 };
387 } // namespace dsr
388 } // namespace ns3
389 
390 #endif /* DSR_RREQ_TABLE_H */
void Invalidate()
set the unidirectional entry as QUESTIONABLE state
uint32_t CheckUniqueRreqId(Ipv4Address dst)
The following code generates new request id for each destination.
Ipv4Address m_neighborAddress
IPv4 address of the black-listed neighbor.
void RemoveRreqEntry(Ipv4Address dst)
Remove route request entry for dst.
uint32_t m_reqNo
Route request number.
bool operator==(DsrReceivedRreqEntry const &o) const
Compare send buffer entries (destination address and identification)
Ipv4Address m_source
IPv4 address of the source.
DsrReceivedRreqEntry(Ipv4Address d=Ipv4Address(), uint16_t i=0)
Construct a DsrReceivedRreqEntry with the given parameters.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void PurgeNeighbor()
Remove all expired black list entries.
std::list< DsrReceivedRreqEntry > m_sourceRequests
Map of entries.
Ipv4Address m_destination
IPv4 address of the destinaton.
void SetUniqueRreqIdSize(uint32_t uid)
Set the maximum number of request Ids in the request table for a single destination.
void SetRreqTableSize(uint32_t rt)
Set the maximum number of request entries in the request table.
Time m_expireTime
Expire time in the black list.
Time m_rreqEntryExpire
The source route entry expire time.
uint32_t GetRreqSize()
Get the request id size.
void SetIdentification(uint16_t i)
Set identification.
uint32_t GetRreqCnt(Ipv4Address dst)
Get the request count number for one destination address.
uint16_t GetIdentification() const
Return identification.
Time GetExpireTime() const
Return the remaining time before the RREQ entry expires.
uint32_t m_initHopLimit
The initial hop limit.
void RemoveLeastExpire(std::map< Ipv4Address, RreqTableEntry > &rreqDstMap)
Remove the least used entry.
uint32_t GetUniqueRreqIdSize() const
Return the maximum number of request Ids in the request table for a single destination.
void SetRreqIdSize(uint32_t id)
Set the maximum number of request source Ids in the request table.
uint32_t m_requestIdSize
The request source id size.
uint16_t m_identification
Route request identification.
uint32_t GetRreqTableSize() const
Return the maximum number of request entries in the request table.
std::vector< BlackList > m_blackList
The Black list.
bool operator()(const struct BlackList &b) const
Check if the entry is expired.
std::map< Ipv4Address, std::list< DsrReceivedRreqEntry > > m_sourceRreqMap
The cache to ensure all the route request from unique source.
void SetInitHopLimit(uint32_t hl)
Set the initial discovert hop limit.
maintain list of DsrRreqTable entry
BlackList * FindUnidirectional(Ipv4Address neighbor)
Verify if entry is unidirectional or not(e.g.
uint32_t GetInitHopLimit() const
Return the initial discovert hop limit.
uint32_t GetRreqIdSize() const
Return the maximum number of request source Ids in the request table.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::map< Ipv4Address, uint32_t > m_rreqIdCache
The id cache to ensure all the ids are unique, it is used when sending out route request.
Time MaxRequestPeriod
The max request period among requests.
uint32_t m_maxRreqId
The unique request id for any destination.
Time m_expire
Route request expire time.
BlackList description.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:224
void SetExpireTime(Time exp)
Set expire time for the RREQ entry.
static TypeId GetTypeId()
Time RequestPeriod
The original request period.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
Check if the entry is expired or not.
BlackList(Ipv4Address ip, Time t)
Construct a BlackList with the given parameters.
Ipv4Address GetSource() const
Return IPv4 address of the source.
bool FindSourceEntry(Ipv4Address src, Ipv4Address dst, uint16_t id)
Find the source request entry in the route request queue, return false if not found.
LinkStates
State of link.
Time m_expire
Expire time.
LinkStates m_linkStates
State of the link.
Time NonpropRequestTimeout
The non-propagaton request timeout.
uint32_t m_requestTableSize
The request table size.
std::map< Ipv4Address, RreqTableEntry > m_rreqDstMap
The cache to save route request table entries indexed with destination address.
The request entry for intermediate nodes to check if they have received this request or not This is u...
void SetSource(Ipv4Address s)
Set IPv4 address of the source.
A base class which provides memory management and object aggregation.
Definition: object.h:87
The route request table entries.
LinkStates m_linkStates
The state of the unidirectional link.
void SetDestination(Ipv4Address d)
Set IPv4 address of the destination.
a unique identifier for an interface.
Definition: type-id.h:58
bool MarkLinkAsUnidirectional(Ipv4Address neighbor, Time blacklistTimeout)
Mark entry as unidirectional (e.g.
Ipv4Address GetDestination() const
Return IPv4 address of the destination.
void FindAndUpdate(Ipv4Address dst)
Find the entry in the route request queue to see if already exists.