A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
NS_LOG_COMPONENT_DEFINE
(
"DsrGraReplyTable"
);
37
38
namespace
ns3 {
39
namespace
dsr {
40
41
NS_OBJECT_ENSURE_REGISTERED
(GraReply)
42
;
43
44
TypeId
GraReply::GetTypeId
()
45
{
46
static
TypeId
tid =
TypeId
(
"ns3::dsr::GraReply"
)
47
.
SetParent
<
Object
> ()
48
.AddConstructor<GraReply> ()
49
;
50
return
tid;
51
}
52
53
GraReply::GraReply
()
54
{
55
}
56
57
GraReply::~GraReply
()
58
{
59
NS_LOG_FUNCTION_NOARGS
();
60
}
61
62
bool
63
GraReply::FindAndUpdate
(
Ipv4Address
replyTo,
Ipv4Address
replyFrom,
Time
gratReplyHoldoff)
64
{
65
Purge
();
// purge the gratuitous reply table
66
for
(std::vector<GraReplyEntry>::iterator i =
m_graReply
.begin ();
67
i !=
m_graReply
.end (); ++i)
68
{
69
if
((i->m_replyTo == replyTo) && (i->m_hearFrom == replyFrom))
70
{
71
NS_LOG_DEBUG
(
"Update the reply to ip address if found the gratuitous reply entry"
);
72
i->m_gratReplyHoldoff = std::max (gratReplyHoldoff +
Simulator::Now
(), i->m_gratReplyHoldoff);
73
return
true
;
74
}
75
}
76
return
false
;
77
}
78
79
bool
80
GraReply::AddEntry
(
GraReplyEntry
& graTableEntry)
81
{
82
m_graReply
.push_back (graTableEntry);
83
return
true
;
84
}
85
86
void
87
GraReply::Purge
()
88
{
89
/*
90
* Purge the expired gratuitous reply entries
91
*/
92
m_graReply
.erase (remove_if (
m_graReply
.begin (),
m_graReply
.end (),
93
IsExpired
()),
m_graReply
.end ());
94
}
95
96
}
// namespace dsr
97
}
// namespace ns3
ns3::dsr::GraReply::~GraReply
virtual ~GraReply()
Definition:
dsr-gratuitous-reply-table.cc:57
ns3::Time
keep track of time values and allow control of global simulation resolution
Definition:
nstime.h:81
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log.h:309
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("DsrGraReplyTable")
dsr-gratuitous-reply-table.h
ns3::dsr::GraReply::IsExpired
Check if the entry is expired or not.
Definition:
dsr-gratuitous-reply-table.h:103
ns3::dsr::GraReply::GraReply
GraReply()
Definition:
dsr-gratuitous-reply-table.cc:53
ns3::dsr::GraReply::m_graReply
std::vector< GraReplyEntry > m_graReply
Vector of entries.
Definition:
dsr-gratuitous-reply-table.h:98
ns3::dsr::GraReplyEntry
Definition:
dsr-gratuitous-reply-table.h:48
ns3::Simulator::Now
static Time Now(void)
Return the "current simulation time".
Definition:
simulator.cc:180
ns3::dsr::GraReply::FindAndUpdate
bool FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff)
Update the route entry if found, create a new one if not.
Definition:
dsr-gratuitous-reply-table.cc:63
ns3::dsr::GraReply::GetTypeId
static TypeId GetTypeId()
Definition:
dsr-gratuitous-reply-table.cc:44
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:38
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Definition:
log.h:289
ns3::Object
a base class which provides memory management and object aggregation
Definition:
object.h:63
ns3::dsr::GraReply::AddEntry
bool AddEntry(GraReplyEntry &graTableEntry)
Add a new gratuitous reply entry.
Definition:
dsr-gratuitous-reply-table.cc:80
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:611
ns3::dsr::GraReply::Purge
void Purge()
Remove all expired entries.
Definition:
dsr-gratuitous-reply-table.cc:87
src
dsr
model
dsr-gratuitous-reply-table.cc
Generated on Sat Apr 19 2014 14:06:53 for ns-3 by
1.8.6