A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
aodv-id-cache.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 IITP RAS
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Based on
18
* NS-2 AODV model developed by the CMU/MONARCH group and optimized and
19
* tuned by Samir Das and Mahesh Marina, University of Cincinnati;
20
*
21
* AODV-UU implementation by Erik Nordström of Uppsala University
22
* https://web.archive.org/web/20100527072022/http://core.it.uu.se/core/index.php/AODV-UU
23
*
24
* Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
25
* Pavel Boyko <boyko@iitp.ru>
26
*/
27
28
#ifndef AODV_ID_CACHE_H
29
#define AODV_ID_CACHE_H
30
31
#include "ns3/ipv4-address.h"
32
#include "ns3/simulator.h"
33
34
#include <vector>
35
36
namespace
ns3
37
{
38
namespace
aodv
39
{
45
class
IdCache
46
{
47
public
:
52
IdCache
(
Time
lifetime)
53
:
m_lifetime
(lifetime)
54
{
55
}
56
63
bool
IsDuplicate
(
Ipv4Address
addr, uint32_t
id
);
65
void
Purge
();
69
uint32_t
GetSize
();
70
75
void
SetLifetime
(
Time
lifetime)
76
{
77
m_lifetime
= lifetime;
78
}
79
84
Time
GetLifeTime
()
const
85
{
86
return
m_lifetime
;
87
}
88
89
private
:
91
struct
UniqueId
92
{
94
Ipv4Address
m_context
;
96
uint32_t
m_id
;
98
Time
m_expire
;
99
};
100
104
struct
IsExpired
105
{
112
bool
operator()
(
const
UniqueId
& u)
const
113
{
114
return
(u.
m_expire
<
Simulator::Now
());
115
}
116
};
117
119
std::vector<UniqueId>
m_idCache
;
121
Time
m_lifetime
;
122
};
123
124
}
// namespace aodv
125
}
// namespace ns3
126
127
#endif
/* AODV_ID_CACHE_H */
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:42
ns3::Simulator::Now
static Time Now()
Return the current simulation virtual time.
Definition:
simulator.cc:208
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
ns3::aodv::IdCache
Unique packets identification cache used for simple duplicate detection.
Definition:
aodv-id-cache.h:46
ns3::aodv::IdCache::m_idCache
std::vector< UniqueId > m_idCache
Already seen IDs.
Definition:
aodv-id-cache.h:119
ns3::aodv::IdCache::Purge
void Purge()
Remove all expired entries.
Definition:
aodv-id-cache.cc:52
ns3::aodv::IdCache::SetLifetime
void SetLifetime(Time lifetime)
Set lifetime for future added entries.
Definition:
aodv-id-cache.h:75
ns3::aodv::IdCache::m_lifetime
Time m_lifetime
Default lifetime for ID records.
Definition:
aodv-id-cache.h:121
ns3::aodv::IdCache::GetLifeTime
Time GetLifeTime() const
Return lifetime for existing entries in cache.
Definition:
aodv-id-cache.h:84
ns3::aodv::IdCache::IsDuplicate
bool IsDuplicate(Ipv4Address addr, uint32_t id)
Check that entry (addr, id) exists in cache.
Definition:
aodv-id-cache.cc:36
ns3::aodv::IdCache::GetSize
uint32_t GetSize()
Definition:
aodv-id-cache.cc:58
ns3::aodv::IdCache::IdCache
IdCache(Time lifetime)
constructor
Definition:
aodv-id-cache.h:52
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::aodv::IdCache::IsExpired
IsExpired structure.
Definition:
aodv-id-cache.h:105
ns3::aodv::IdCache::IsExpired::operator()
bool operator()(const UniqueId &u) const
Check if the entry is expired.
Definition:
aodv-id-cache.h:112
ns3::aodv::IdCache::UniqueId
Unique packet ID.
Definition:
aodv-id-cache.h:92
ns3::aodv::IdCache::UniqueId::m_expire
Time m_expire
When record will expire.
Definition:
aodv-id-cache.h:98
ns3::aodv::IdCache::UniqueId::m_id
uint32_t m_id
The id.
Definition:
aodv-id-cache.h:96
ns3::aodv::IdCache::UniqueId::m_context
Ipv4Address m_context
ID is supposed to be unique in single address context (e.g. sender address)
Definition:
aodv-id-cache.h:94
src
aodv
model
aodv-id-cache.h
Generated on Sun Mar 3 2024 17:10:52 for ns-3 by
1.9.1