A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
dsr-gratuitous-reply-table.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Yufei Cheng
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 * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
18 *
19 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
20 * ResiliNets Research Group https://resilinets.org/
21 * Information and Telecommunication Technology Center (ITTC)
22 * and Department of Electrical Engineering and Computer Science
23 * The University of Kansas Lawrence, KS USA.
24 *
25 * Work supported in part by NSF FIND (Future Internet Design) Program
26 * under grant CNS-0626918 (Postmodern Internet Architecture),
27 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
28 * US Department of Defense (DoD), and ITTC at The University of Kansas.
29 */
30
31#ifndef DSR_GRATUITOUS_REPLY_TABLE_H
32#define DSR_GRATUITOUS_REPLY_TABLE_H
33
34#include "ns3/callback.h"
35#include "ns3/ipv4-address.h"
36#include "ns3/simulator.h"
37#include "ns3/timer.h"
38
39#include <vector>
40
41namespace ns3
42{
43namespace dsr
44{
51{
55
64 : m_replyTo(t),
65 m_hearFrom(f),
67 {
68 }
69};
70
75class DsrGraReply : public Object
76{
77 public:
82 static TypeId GetTypeId();
83
85 ~DsrGraReply() override;
86
90 {
92 }
93
97 {
98 return GraReplyTableSize;
99 }
100
104 bool AddEntry(GraReplyEntry& graTableEntry);
110 bool FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff);
112 void Purge();
113
115 void Clear()
116 {
117 m_graReply.clear();
118 }
119
120 private:
122 std::vector<GraReplyEntry> m_graReply;
125
128 {
135 bool operator()(const GraReplyEntry& b) const
136 {
137 return (b.m_gratReplyHoldoff < Simulator::Now());
138 }
139 };
140};
141} // namespace dsr
142} // namespace ns3
143
144#endif /* DSR_GRATUITOUS_REPLY_TABLE_H */
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
A base class which provides memory management and object aggregation.
Definition: object.h:89
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
maintain the gratuitous reply
bool AddEntry(GraReplyEntry &graTableEntry)
Add a new gratuitous reply entry.
static TypeId GetTypeId()
Get the type ID.
std::vector< GraReplyEntry > m_graReply
Vector of entries.
uint32_t GraReplyTableSize
The max # of gratuitous reply entries to hold.
void SetGraTableSize(uint32_t g)
Set the gratuitous reply table size.
void Purge()
Remove all expired entries.
uint32_t GetGraTableSize() const
Get the gratuitous reply table size.
bool FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff)
Update the route entry if found.
void Clear()
Remove all entries.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Check if the entry is expired or not.
bool operator()(const GraReplyEntry &b) const
Check if the entry is expired.
The gratuitous table entries, it maintains the already sent gratuitous route reply entries.
GraReplyEntry(Ipv4Address t, Ipv4Address f, Time h)
Constructor.
Time m_gratReplyHoldoff
gratuitous reply holdoff time
Ipv4Address m_replyTo
reply to address
Ipv4Address m_hearFrom
heard from address