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
* 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
#ifndef DSR_GRATUITOUS_REPLY_TABLE_H
21
#define DSR_GRATUITOUS_REPLY_TABLE_H
22
23
#include "ns3/callback.h"
24
#include "ns3/ipv4-address.h"
25
#include "ns3/simulator.h"
26
#include "ns3/timer.h"
27
28
#include <vector>
29
30
namespace
ns3
31
{
32
namespace
dsr
33
{
34
/**
35
* The gratuitous table entries, it maintains the already sent gratuitous route reply entries.
36
* When the node "promiscuously" received a packet destined for other nodes, and inferred a shorter
37
* route for the data packet, it will construct a route reply and send back to the source
38
*/
39
struct
GraReplyEntry
40
{
41
Ipv4Address
m_replyTo
;
///< reply to address
42
Ipv4Address
m_hearFrom
;
///< heard from address
43
Time
m_gratReplyHoldoff
;
///< gratuitous reply holdoff time
44
45
/**
46
* Constructor
47
*
48
* \param t IPv4 address to reply to
49
* \param f IPv4 address to hear from
50
* \param h gratuitous hold off time
51
*/
52
GraReplyEntry
(
Ipv4Address
t,
Ipv4Address
f,
Time
h)
53
:
m_replyTo
(t),
54
m_hearFrom
(f),
55
m_gratReplyHoldoff
(h)
56
{
57
}
58
};
59
60
/**
61
* \ingroup dsr
62
* \brief maintain the gratuitous reply
63
*/
64
class
DsrGraReply
:
public
Object
65
{
66
public
:
67
/**
68
* \brief Get the type ID.
69
* \return the object TypeId
70
*/
71
static
TypeId
GetTypeId
();
72
73
DsrGraReply
();
74
~DsrGraReply
()
override
;
75
76
/// Set the gratuitous reply table size
77
/// \param g The gratuitous reply table size
78
void
SetGraTableSize
(
uint32_t
g)
79
{
80
GraReplyTableSize
= g;
81
}
82
83
/// Get the gratuitous reply table size
84
/// \returns The gratuitous reply table size
85
uint32_t
GetGraTableSize
()
const
86
{
87
return
GraReplyTableSize
;
88
}
89
90
/// Add a new gratuitous reply entry
91
/// \param graTableEntry The gratuitous reply entry
92
/// \return true on success
93
bool
AddEntry
(
GraReplyEntry
& graTableEntry);
94
/// Update the route entry if found
95
/// \param replyTo Entry directed to
96
/// \param replyFrom Entry heard from
97
/// \param gratReplyHoldoff New gratuitous reply holdoff time
98
/// \return true on success
99
bool
FindAndUpdate
(
Ipv4Address
replyTo,
Ipv4Address
replyFrom,
Time
gratReplyHoldoff);
100
/// Remove all expired entries
101
void
Purge
();
102
103
/// Remove all entries
104
void
Clear
()
105
{
106
m_graReply
.clear();
107
}
108
109
private
:
110
/// Vector of entries
111
std::vector<GraReplyEntry>
m_graReply
;
112
/// The max # of gratuitous reply entries to hold
113
uint32_t
GraReplyTableSize
;
114
115
/// Check if the entry is expired or not
116
struct
IsExpired
117
{
118
/**
119
* Check if the entry is expired
120
*
121
* \param b GraReplyEntry entry
122
* \return true if expired, false otherwise
123
*/
124
bool
operator()
(
const
GraReplyEntry
& b)
const
125
{
126
return
(b.
m_gratReplyHoldoff
<
Simulator::Now
());
127
}
128
};
129
};
130
}
// namespace dsr
131
}
// namespace ns3
132
133
#endif
/* DSR_GRATUITOUS_REPLY_TABLE_H */
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::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::GraReplyTableSize
uint32_t GraReplyTableSize
The max # of gratuitous reply entries to hold.
Definition
dsr-gratuitous-reply-table.h:113
ns3::dsr::DsrGraReply::DsrGraReply
DsrGraReply()
Definition
dsr-gratuitous-reply-table.cc:46
ns3::dsr::DsrGraReply::SetGraTableSize
void SetGraTableSize(uint32_t g)
Set the gratuitous reply table size.
Definition
dsr-gratuitous-reply-table.h:78
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::GetGraTableSize
uint32_t GetGraTableSize() const
Get the gratuitous reply table size.
Definition
dsr-gratuitous-reply-table.h:85
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
ns3::dsr::DsrGraReply::Clear
void Clear()
Remove all entries.
Definition
dsr-gratuitous-reply-table.h:104
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:117
ns3::dsr::DsrGraReply::IsExpired::operator()
bool operator()(const GraReplyEntry &b) const
Check if the entry is expired.
Definition
dsr-gratuitous-reply-table.h:124
ns3::dsr::GraReplyEntry
The gratuitous table entries, it maintains the already sent gratuitous route reply entries.
Definition
dsr-gratuitous-reply-table.h:40
ns3::dsr::GraReplyEntry::GraReplyEntry
GraReplyEntry(Ipv4Address t, Ipv4Address f, Time h)
Constructor.
Definition
dsr-gratuitous-reply-table.h:52
ns3::dsr::GraReplyEntry::m_gratReplyHoldoff
Time m_gratReplyHoldoff
gratuitous reply holdoff time
Definition
dsr-gratuitous-reply-table.h:43
ns3::dsr::GraReplyEntry::m_replyTo
Ipv4Address m_replyTo
reply to address
Definition
dsr-gratuitous-reply-table.h:41
ns3::dsr::GraReplyEntry::m_hearFrom
Ipv4Address m_hearFrom
heard from address
Definition
dsr-gratuitous-reply-table.h:42
src
dsr
model
dsr-gratuitous-reply-table.h
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0