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
aodv-id-cache.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 IITP RAS
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Based on
7
* NS-2 AODV model developed by the CMU/MONARCH group and optimized and
8
* tuned by Samir Das and Mahesh Marina, University of Cincinnati;
9
*
10
* AODV-UU implementation by Erik Nordström of Uppsala University
11
* https://web.archive.org/web/20100527072022/http://core.it.uu.se/core/index.php/AODV-UU
12
*
13
* Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
14
* Pavel Boyko <boyko@iitp.ru>
15
*/
16
#include "
aodv-id-cache.h
"
17
18
#include <algorithm>
19
20
namespace
ns3
21
{
22
namespace
aodv
23
{
24
bool
25
IdCache::IsDuplicate
(
Ipv4Address
addr,
uint32_t
id
)
26
{
27
Purge
();
28
for
(
auto
i =
m_idCache
.begin(); i !=
m_idCache
.end(); ++i)
29
{
30
if
(i->m_context == addr && i->m_id ==
id
)
31
{
32
return
true
;
33
}
34
}
35
UniqueId
uniqueId = {addr, id,
m_lifetime
+
Simulator::Now
()};
36
m_idCache
.push_back(uniqueId);
37
return
false
;
38
}
39
40
void
41
IdCache::Purge
()
42
{
43
m_idCache
.erase(remove_if(
m_idCache
.begin(),
m_idCache
.end(),
IsExpired
()),
m_idCache
.end());
44
}
45
46
uint32_t
47
IdCache::GetSize
()
48
{
49
Purge
();
50
return
m_idCache
.size();
51
}
52
53
}
// namespace aodv
54
}
// namespace ns3
aodv-id-cache.h
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::Simulator::Now
static Time Now()
Return the current simulation virtual time.
Definition
simulator.cc:197
ns3::aodv::IdCache::m_idCache
std::vector< UniqueId > m_idCache
Already seen IDs.
Definition
aodv-id-cache.h:108
ns3::aodv::IdCache::Purge
void Purge()
Remove all expired entries.
Definition
aodv-id-cache.cc:41
ns3::aodv::IdCache::m_lifetime
Time m_lifetime
Default lifetime for ID records.
Definition
aodv-id-cache.h:110
ns3::aodv::IdCache::IsDuplicate
bool IsDuplicate(Ipv4Address addr, uint32_t id)
Check that entry (addr, id) exists in cache.
Definition
aodv-id-cache.cc:25
ns3::aodv::IdCache::GetSize
uint32_t GetSize()
Definition
aodv-id-cache.cc:47
uint32_t
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:94
ns3::aodv::IdCache::UniqueId
Unique packet ID.
Definition
aodv-id-cache.h:81
src
aodv
model
aodv-id-cache.cc
Generated on Fri Nov 8 2024 13:58:58 for ns-3 by
1.11.0