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.cc
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
#include "
aodv-id-cache.h
"
28
29
#include <algorithm>
30
31
namespace
ns3
32
{
33
namespace
aodv
34
{
35
bool
36
IdCache::IsDuplicate
(
Ipv4Address
addr, uint32_t
id
)
37
{
38
Purge
();
39
for
(
auto
i =
m_idCache
.begin(); i !=
m_idCache
.end(); ++i)
40
{
41
if
(i->m_context == addr && i->m_id ==
id
)
42
{
43
return
true
;
44
}
45
}
46
UniqueId
uniqueId = {addr, id,
m_lifetime
+
Simulator::Now
()};
47
m_idCache
.push_back(uniqueId);
48
return
false
;
49
}
50
51
void
52
IdCache::Purge
()
53
{
54
m_idCache
.erase(remove_if(
m_idCache
.begin(),
m_idCache
.end(),
IsExpired
()),
m_idCache
.end());
55
}
56
57
uint32_t
58
IdCache::GetSize
()
59
{
60
Purge
();
61
return
m_idCache
.size();
62
}
63
64
}
// namespace aodv
65
}
// namespace ns3
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::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::m_lifetime
Time m_lifetime
Default lifetime for ID records.
Definition:
aodv-id-cache.h:121
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
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::UniqueId
Unique packet ID.
Definition:
aodv-id-cache.h:92
src
aodv
model
aodv-id-cache.cc
Generated on Sun Mar 3 2024 17:10:52 for ns-3 by
1.9.1