A Discrete-Event Network Simulator
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
30namespace ns3
31{
32namespace 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 */
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 */
58};
59
60/**
61 * @ingroup dsr
62 * @brief maintain the gratuitous reply
63 */
64class DsrGraReply : public Object
65{
66 public:
67 /**
68 * @brief Get the type ID.
69 * @return the object TypeId
70 */
71 static TypeId GetTypeId();
72
74 ~DsrGraReply() override;
75
76 /// Set the gratuitous reply table size
77 /// @param g The gratuitous reply table size
79 {
81 }
82
83 /// Get the gratuitous reply table size
84 /// @returns The gratuitous reply table size
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
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
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
114
115 /// Check if the entry is expired or not
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 */
Ipv4 addresses are stored in host order in this class.
A base class which provides memory management and object aggregation.
Definition object.h:78
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:49
maintain the gratuitous reply
bool AddEntry(GraReplyEntry &graTableEntry)
Add a new gratuitous reply entry.
static TypeId GetTypeId()
Get the type ID.
std::vector< GraReplyEntry > m_graReply
Vector of entries.
uint32_t GraReplyTableSize
The max # of gratuitous reply entries to hold.
void SetGraTableSize(uint32_t g)
Set the gratuitous reply table size.
void Purge()
Remove all expired entries.
uint32_t GetGraTableSize() const
Get the gratuitous reply table size.
bool FindAndUpdate(Ipv4Address replyTo, Ipv4Address replyFrom, Time gratReplyHoldoff)
Update the route entry if found.
void Clear()
Remove all entries.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Check if the entry is expired or not.
bool operator()(const GraReplyEntry &b) const
Check if the entry is expired.
The gratuitous table entries, it maintains the already sent gratuitous route reply entries.
GraReplyEntry(Ipv4Address t, Ipv4Address f, Time h)
Constructor.
Time m_gratReplyHoldoff
gratuitous reply holdoff time
Ipv4Address m_replyTo
reply to address
Ipv4Address m_hearFrom
heard from address