A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
41
namespace
ns3
42
{
43
namespace
dsr
44
{
45
/**
46
* The gratuitous table entries, it maintains the already sent gratuitous route reply entries.
47
* When the node "promiscuously" received a packet destined for other nodes, and inferred a shorter
48
* route for the data packet, it will construct a route reply and send back to the source
49
*/
50
struct
GraReplyEntry
51
{
52
Ipv4Address
m_replyTo
;
///< reply to address
53
Ipv4Address
m_hearFrom
;
///< heard from address
54
Time
m_gratReplyHoldoff
;
///< gratuitous reply holdoff time
55
56
/**
57
* Constructor
58
*
59
* \param t IPv4 address to reply to
60
* \param f IPv4 address to hear from
61
* \param h gratuitous hold off time
62
*/
63
GraReplyEntry
(
Ipv4Address
t,
Ipv4Address
f,
Time
h)
64
:
m_replyTo
(t),
65
m_hearFrom
(f),
66
m_gratReplyHoldoff
(h)
67
{
68
}
69
};
70
71
/**
72
* \ingroup dsr
73
* \brief maintain the gratuitous reply
74
*/
75
class
DsrGraReply
:
public
Object
76
{
77
public
:
78
/**
79
* \brief Get the type ID.
80
* \return the object TypeId
81
*/
82
static
TypeId
GetTypeId
();
83
84
DsrGraReply
();
85
~DsrGraReply
()
override
;
86
87
/// Set the gratuitous reply table size
88
/// \param g The gratuitous reply table size
89
void
SetGraTableSize
(
uint32_t
g)
90
{
91
GraReplyTableSize
= g;
92
}
93
94
/// Get the gratuitous reply table size
95
/// \returns The gratuitous reply table size
96
uint32_t
GetGraTableSize
()
const
97
{
98
return
GraReplyTableSize
;
99
}
100
101
/// Add a new gratuitous reply entry
102
/// \param graTableEntry The gratuitous reply entry
103
/// \return true on success
104
bool
AddEntry
(
GraReplyEntry
& graTableEntry);
105
/// Update the route entry if found
106
/// \param replyTo Entry directed to
107
/// \param replyFrom Entry heard from
108
/// \param gratReplyHoldoff New gratuitous reply holdoff time
109
/// \return true on success
110
bool
FindAndUpdate
(
Ipv4Address
replyTo,
Ipv4Address
replyFrom,
Time
gratReplyHoldoff);
111
/// Remove all expired entries
112
void
Purge
();
113
114
/// Remove all entries
115
void
Clear
()
116
{
117
m_graReply
.clear();
118
}
119
120
private
:
121
/// Vector of entries
122
std::vector<GraReplyEntry>
m_graReply
;
123
/// The max # of gratuitous reply entries to hold
124
uint32_t
GraReplyTableSize
;
125
126
/// Check if the entry is expired or not
127
struct
IsExpired
128
{
129
/**
130
* Check if the entry is expired
131
*
132
* \param b GraReplyEntry entry
133
* \return true if expired, false otherwise
134
*/
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 */
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:42
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:89
ns3::Simulator::Now
static Time Now()
Return the current simulation virtual time.
Definition:
simulator.cc:208
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::dsr::DsrGraReply
maintain the gratuitous reply
Definition:
dsr-gratuitous-reply-table.h:76
ns3::dsr::DsrGraReply::AddEntry
bool AddEntry(GraReplyEntry &graTableEntry)
Add a new gratuitous reply entry.
Definition:
dsr-gratuitous-reply-table.cc:84
ns3::dsr::DsrGraReply::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
dsr-gratuitous-reply-table.cc:48
ns3::dsr::DsrGraReply::m_graReply
std::vector< GraReplyEntry > m_graReply
Vector of entries.
Definition:
dsr-gratuitous-reply-table.h:122
ns3::dsr::DsrGraReply::GraReplyTableSize
uint32_t GraReplyTableSize
The max # of gratuitous reply entries to hold.
Definition:
dsr-gratuitous-reply-table.h:124
ns3::dsr::DsrGraReply::DsrGraReply
DsrGraReply()
Definition:
dsr-gratuitous-reply-table.cc:57
ns3::dsr::DsrGraReply::SetGraTableSize
void SetGraTableSize(uint32_t g)
Set the gratuitous reply table size.
Definition:
dsr-gratuitous-reply-table.h:89
ns3::dsr::DsrGraReply::~DsrGraReply
~DsrGraReply() override
Definition:
dsr-gratuitous-reply-table.cc:61
ns3::dsr::DsrGraReply::Purge
void Purge()
Remove all expired entries.
Definition:
dsr-gratuitous-reply-table.cc:91
ns3::dsr::DsrGraReply::GetGraTableSize
uint32_t GetGraTableSize() const
Get the gratuitous reply table size.
Definition:
dsr-gratuitous-reply-table.h:96
ns3::dsr::DsrGraReply::FindAndUpdate
bool FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff)
Update the route entry if found.
Definition:
dsr-gratuitous-reply-table.cc:67
ns3::dsr::DsrGraReply::Clear
void Clear()
Remove all entries.
Definition:
dsr-gratuitous-reply-table.h:115
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::dsr::DsrGraReply::IsExpired
Check if the entry is expired or not.
Definition:
dsr-gratuitous-reply-table.h:128
ns3::dsr::DsrGraReply::IsExpired::operator()
bool operator()(const GraReplyEntry &b) const
Check if the entry is expired.
Definition:
dsr-gratuitous-reply-table.h:135
ns3::dsr::GraReplyEntry
The gratuitous table entries, it maintains the already sent gratuitous route reply entries.
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:63
ns3::dsr::GraReplyEntry::m_gratReplyHoldoff
Time m_gratReplyHoldoff
gratuitous reply holdoff time
Definition:
dsr-gratuitous-reply-table.h:54
ns3::dsr::GraReplyEntry::m_replyTo
Ipv4Address m_replyTo
reply to address
Definition:
dsr-gratuitous-reply-table.h:52
ns3::dsr::GraReplyEntry::m_hearFrom
Ipv4Address m_hearFrom
heard from address
Definition:
dsr-gratuitous-reply-table.h:53
src
dsr
model
dsr-gratuitous-reply-table.h
Generated on Tue May 28 2024 23:35:02 for ns-3 by
1.9.6