A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
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
/* -*- 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
#include "
dsr-gratuitous-reply-table.h
"
33
#include "ns3/log.h"
34
#include <algorithm>
35
36
namespace
ns3
{
37
38
NS_LOG_COMPONENT_DEFINE
(
"DsrGraReplyTable"
);
39
40
namespace
dsr {
41
42
NS_OBJECT_ENSURE_REGISTERED
(DsrGraReply);
43
44
TypeId
DsrGraReply::GetTypeId
()
45
{
46
static
TypeId
tid =
TypeId
(
"ns3::dsr::DsrGraReply"
)
47
.
SetParent
<
Object
> ()
48
.SetGroupName (
"Dsr"
)
49
.AddConstructor<
DsrGraReply
> ()
50
;
51
return
tid;
52
}
53
54
DsrGraReply::DsrGraReply
()
55
{
56
}
57
58
DsrGraReply::~DsrGraReply
()
59
{
60
NS_LOG_FUNCTION_NOARGS
();
61
}
62
63
bool
64
DsrGraReply::FindAndUpdate
(
Ipv4Address
replyTo,
Ipv4Address
replyFrom,
Time
gratReplyHoldoff)
65
{
66
Purge
();
// purge the gratuitous reply table
67
for
(std::vector<GraReplyEntry>::iterator i =
m_graReply
.begin ();
68
i !=
m_graReply
.end (); ++i)
69
{
70
if
((i->m_replyTo == replyTo) && (i->m_hearFrom == replyFrom))
71
{
72
NS_LOG_DEBUG
(
"Update the reply to ip address if found the gratuitous reply entry"
);
73
i->m_gratReplyHoldoff =
std::max
(gratReplyHoldoff +
Simulator::Now
(), i->m_gratReplyHoldoff);
74
return
true
;
75
}
76
}
77
return
false
;
78
}
79
80
bool
81
DsrGraReply::AddEntry
(
GraReplyEntry
& graTableEntry)
82
{
83
m_graReply
.push_back (graTableEntry);
84
return
true
;
85
}
86
87
void
88
DsrGraReply::Purge
()
89
{
90
/*
91
* Purge the expired gratuitous reply entries
92
*/
93
m_graReply
.erase (remove_if (
m_graReply
.begin (),
m_graReply
.end (),
94
IsExpired
()),
m_graReply
.end ());
95
}
96
97
}
// namespace dsr
98
}
// namespace ns3
max
#define max(a, b)
Definition:
80211b.c:43
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:41
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:88
ns3::Simulator::Now
static Time Now(void)
Return the current simulation virtual time.
Definition:
simulator.cc:195
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:103
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:922
ns3::dsr::DsrGraReply
maintain the gratuitous reply
Definition:
dsr-gratuitous-reply-table.h:73
ns3::dsr::DsrGraReply::AddEntry
bool AddEntry(GraReplyEntry &graTableEntry)
Add a new gratuitous reply entry.
Definition:
dsr-gratuitous-reply-table.cc:81
ns3::dsr::DsrGraReply::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
dsr-gratuitous-reply-table.cc:44
ns3::dsr::DsrGraReply::m_graReply
std::vector< GraReplyEntry > m_graReply
Vector of entries.
Definition:
dsr-gratuitous-reply-table.h:116
ns3::dsr::DsrGraReply::~DsrGraReply
virtual ~DsrGraReply()
Definition:
dsr-gratuitous-reply-table.cc:58
ns3::dsr::DsrGraReply::DsrGraReply
DsrGraReply()
Definition:
dsr-gratuitous-reply-table.cc:54
ns3::dsr::DsrGraReply::Purge
void Purge()
Remove all expired entries.
Definition:
dsr-gratuitous-reply-table.cc:88
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
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:205
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition:
log.h:273
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log-macros-enabled.h:209
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
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:122
ns3::dsr::GraReplyEntry
The gratuitous table entries, it maintains the already sent gratuitous route reply entries.
Definition:
dsr-gratuitous-reply-table.h:49
src
dsr
model
dsr-gratuitous-reply-table.cc
Generated on Tue Feb 6 2024 19:21:17 for ns-3 by
1.9.1