A Discrete-Event Network Simulator
API
dsr-gratuitous-reply-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_GRATUITOUS_REPLY_TABLE_H
33 #define DSR_GRATUITOUS_REPLY_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 <vector>
40 
41 namespace ns3 {
42 namespace dsr {
49 {
53 
62  : m_replyTo (t),
63  m_hearFrom (f),
65  {
66  }
67 };
72 class DsrGraReply : public Object
73 {
74 public:
79  static TypeId GetTypeId ();
80 
81  DsrGraReply ();
82  virtual ~DsrGraReply ();
83 
86  void SetGraTableSize (uint32_t g)
87  {
89  }
92  uint32_t GetGraTableSize () const
93  {
94  return GraReplyTableSize;
95  }
99  bool AddEntry (GraReplyEntry & graTableEntry);
105  bool FindAndUpdate (Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff);
107  void Purge ();
109  void Clear ()
110  {
111  m_graReply.clear ();
112  }
113 
114 private:
116  std::vector<GraReplyEntry> m_graReply;
119 
121  struct IsExpired
122  {
129  bool operator() (const struct GraReplyEntry & b) const
130  {
131  return (b.m_gratReplyHoldoff < Simulator::Now ());
132  }
133  };
134 };
135 } // namespace dsr
136 } // namespace ns3
137 
138 #endif /* DSR_GRATUITOUS_REPLY_TABLE_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::dsr::DsrGraReply::Purge
void Purge()
Remove all expired entries.
Definition: dsr-gratuitous-reply-table.cc:88
ns3::dsr::DsrGraReply::GetGraTableSize
uint32_t GetGraTableSize() const
Get the gratuitous reply table size.
Definition: dsr-gratuitous-reply-table.h:92
ns3::dsr::GraReplyEntry
The gratuitous table entries, it maintains the already sent gratuitous route reply entries.
Definition: dsr-gratuitous-reply-table.h:49
ns3::Simulator::Now
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
ns3::dsr::DsrGraReply::DsrGraReply
DsrGraReply()
Definition: dsr-gratuitous-reply-table.cc:54
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::dsr::DsrGraReply::IsExpired::operator()
bool operator()(const struct GraReplyEntry &b) const
Check if the entry is expired.
Definition: dsr-gratuitous-reply-table.h:129
ns3::dsr::DsrGraReply::AddEntry
bool AddEntry(GraReplyEntry &graTableEntry)
Add a new gratuitous reply entry.
Definition: dsr-gratuitous-reply-table.cc:81
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::dsr::DsrGraReply::IsExpired
Check if the entry is expired or not.
Definition: dsr-gratuitous-reply-table.h:122
ns3::dsr::DsrGraReply
maintain the gratuitous reply
Definition: dsr-gratuitous-reply-table.h:73
ns3::dsr::DsrGraReply::GraReplyTableSize
uint32_t GraReplyTableSize
The max # of gratuitous reply entries to hold.
Definition: dsr-gratuitous-reply-table.h:118
ns3::dsr::GraReplyEntry::m_replyTo
Ipv4Address m_replyTo
reply to address
Definition: dsr-gratuitous-reply-table.h:50
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::dsr::DsrGraReply::SetGraTableSize
void SetGraTableSize(uint32_t g)
Set the gratuitous reply table size.
Definition: dsr-gratuitous-reply-table.h:86
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::dsr::DsrGraReply::FindAndUpdate
bool FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff)
Update the route entry if found.
Definition: dsr-gratuitous-reply-table.cc:64
ns3::dsr::DsrGraReply::Clear
void Clear()
Remove all entries.
Definition: dsr-gratuitous-reply-table.h:109
f
double f(double x, void *params)
Definition: 80211b.c:70
ns3::dsr::GraReplyEntry::m_gratReplyHoldoff
Time m_gratReplyHoldoff
gratuitous reply holdoff time
Definition: dsr-gratuitous-reply-table.h:52
ns3::dsr::DsrGraReply::m_graReply
std::vector< GraReplyEntry > m_graReply
Vector of entries.
Definition: dsr-gratuitous-reply-table.h:116
ns3::dsr::GraReplyEntry::m_hearFrom
Ipv4Address m_hearFrom
heard from address
Definition: dsr-gratuitous-reply-table.h:51
ns3::dsr::GraReplyEntry::GraReplyEntry
GraReplyEntry(Ipv4Address t, Ipv4Address f, Time h)
Constructor.
Definition: dsr-gratuitous-reply-table.h:61
ns3::dsr::DsrGraReply::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition: dsr-gratuitous-reply-table.cc:44
ns3::dsr::DsrGraReply::~DsrGraReply
virtual ~DsrGraReply()
Definition: dsr-gratuitous-reply-table.cc:58