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.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 Yufei Cheng
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Yufei Cheng <yfcheng@ittc.ku.edu>
7
*
8
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
9
* ResiliNets Research Group https://resilinets.org/
10
* Information and Telecommunication Technology Center (ITTC)
11
* and Department of Electrical Engineering and Computer Science
12
* The University of Kansas Lawrence, KS USA.
13
*
14
* Work supported in part by NSF FIND (Future Internet Design) Program
15
* under grant CNS-0626918 (Postmodern Internet Architecture),
16
* NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
17
* US Department of Defense (DoD), and ITTC at The University of Kansas.
18
*/
19
20
#include "
dsr-gratuitous-reply-table.h
"
21
22
#include "ns3/log.h"
23
24
#include <algorithm>
25
26
namespace
ns3
27
{
28
29
NS_LOG_COMPONENT_DEFINE
(
"DsrGraReplyTable"
);
30
31
namespace
dsr
32
{
33
34
NS_OBJECT_ENSURE_REGISTERED
(DsrGraReply);
35
36
TypeId
37
DsrGraReply::GetTypeId
()
38
{
39
static
TypeId
tid =
TypeId
(
"ns3::dsr::DsrGraReply"
)
40
.
SetParent
<
Object
>()
41
.SetGroupName(
"Dsr"
)
42
.AddConstructor<
DsrGraReply
>();
43
return
tid;
44
}
45
46
DsrGraReply::DsrGraReply
()
47
{
48
}
49
50
DsrGraReply::~DsrGraReply
()
51
{
52
NS_LOG_FUNCTION_NOARGS
();
53
}
54
55
bool
56
DsrGraReply::FindAndUpdate
(
Ipv4Address
replyTo,
Ipv4Address
replyFrom,
Time
gratReplyHoldoff)
57
{
58
Purge
();
// purge the gratuitous reply table
59
for
(
auto
i =
m_graReply
.begin(); i !=
m_graReply
.end(); ++i)
60
{
61
if
((i->m_replyTo == replyTo) && (i->m_hearFrom == replyFrom))
62
{
63
NS_LOG_DEBUG
(
"Update the reply to ip address if found the gratuitous reply entry"
);
64
i->m_gratReplyHoldoff =
65
std::max(gratReplyHoldoff +
Simulator::Now
(), i->m_gratReplyHoldoff);
66
return
true
;
67
}
68
}
69
return
false
;
70
}
71
72
bool
73
DsrGraReply::AddEntry
(
GraReplyEntry
& graTableEntry)
74
{
75
m_graReply
.push_back(graTableEntry);
76
return
true
;
77
}
78
79
void
80
DsrGraReply::Purge
()
81
{
82
/*
83
* Purge the expired gratuitous reply entries
84
*/
85
m_graReply
.erase(remove_if(
m_graReply
.begin(),
m_graReply
.end(),
IsExpired
()),
86
m_graReply
.end());
87
}
88
89
}
// namespace dsr
90
}
// namespace ns3
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::Simulator::Now
static Time Now()
Return the current simulation virtual time.
Definition
simulator.cc:197
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::dsr::DsrGraReply
maintain the gratuitous reply
Definition
dsr-gratuitous-reply-table.h:65
ns3::dsr::DsrGraReply::AddEntry
bool AddEntry(GraReplyEntry &graTableEntry)
Add a new gratuitous reply entry.
Definition
dsr-gratuitous-reply-table.cc:73
ns3::dsr::DsrGraReply::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
dsr-gratuitous-reply-table.cc:37
ns3::dsr::DsrGraReply::m_graReply
std::vector< GraReplyEntry > m_graReply
Vector of entries.
Definition
dsr-gratuitous-reply-table.h:111
ns3::dsr::DsrGraReply::DsrGraReply
DsrGraReply()
Definition
dsr-gratuitous-reply-table.cc:46
ns3::dsr::DsrGraReply::~DsrGraReply
~DsrGraReply() override
Definition
dsr-gratuitous-reply-table.cc:50
ns3::dsr::DsrGraReply::Purge
void Purge()
Remove all expired entries.
Definition
dsr-gratuitous-reply-table.cc:80
ns3::dsr::DsrGraReply::FindAndUpdate
bool FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff)
Update the route entry if found.
Definition
dsr-gratuitous-reply-table.cc:56
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:191
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition
log.h:257
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition
log-macros-enabled.h:195
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
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:117
ns3::dsr::GraReplyEntry
The gratuitous table entries, it maintains the already sent gratuitous route reply entries.
Definition
dsr-gratuitous-reply-table.h:40
src
dsr
model
dsr-gratuitous-reply-table.cc
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0