A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
dsr-gratuitous-reply-table.cc
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
#include "
dsr-gratuitous-reply-table.h
"
32
33
#include "ns3/log.h"
34
35
#include <algorithm>
36
37
namespace
ns3
38
{
39
40
NS_LOG_COMPONENT_DEFINE
(
"DsrGraReplyTable"
);
41
42
namespace
dsr
43
{
44
45
NS_OBJECT_ENSURE_REGISTERED
(DsrGraReply);
46
47
TypeId
48
DsrGraReply::GetTypeId
()
49
{
50
static
TypeId
tid =
TypeId
(
"ns3::dsr::DsrGraReply"
)
51
.
SetParent
<
Object
>()
52
.SetGroupName(
"Dsr"
)
53
.AddConstructor<
DsrGraReply
>();
54
return
tid;
55
}
56
57
DsrGraReply::DsrGraReply
()
58
{
59
}
60
61
DsrGraReply::~DsrGraReply
()
62
{
63
NS_LOG_FUNCTION_NOARGS
();
64
}
65
66
bool
67
DsrGraReply::FindAndUpdate
(
Ipv4Address
replyTo,
Ipv4Address
replyFrom,
Time
gratReplyHoldoff)
68
{
69
Purge
();
// purge the gratuitous reply table
70
for
(
auto
i =
m_graReply
.begin(); i !=
m_graReply
.end(); ++i)
71
{
72
if
((i->m_replyTo == replyTo) && (i->m_hearFrom == replyFrom))
73
{
74
NS_LOG_DEBUG
(
"Update the reply to ip address if found the gratuitous reply entry"
);
75
i->m_gratReplyHoldoff =
76
std::max
(gratReplyHoldoff +
Simulator::Now
(), i->m_gratReplyHoldoff);
77
return
true
;
78
}
79
}
80
return
false
;
81
}
82
83
bool
84
DsrGraReply::AddEntry
(
GraReplyEntry
& graTableEntry)
85
{
86
m_graReply
.push_back(graTableEntry);
87
return
true
;
88
}
89
90
void
91
DsrGraReply::Purge
()
92
{
93
/*
94
* Purge the expired gratuitous reply entries
95
*/
96
m_graReply
.erase(remove_if(
m_graReply
.begin(),
m_graReply
.end(),
IsExpired
()),
97
m_graReply
.end());
98
}
99
100
}
// namespace dsr
101
}
// namespace ns3
max
#define max(a, b)
Definition:
80211b.c:42
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::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
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::DsrGraReply
DsrGraReply()
Definition:
dsr-gratuitous-reply-table.cc:57
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::FindAndUpdate
bool FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff)
Update the route entry if found.
Definition:
dsr-gratuitous-reply-table.cc:67
dsr-gratuitous-reply-table.h
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition:
log.h:268
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log-macros-enabled.h:206
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
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::GraReplyEntry
The gratuitous table entries, it maintains the already sent gratuitous route reply entries.
Definition:
dsr-gratuitous-reply-table.h:51
src
dsr
model
dsr-gratuitous-reply-table.cc
Generated on Sun Mar 3 2024 17:10:56 for ns-3 by
1.9.1