A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
aodv-id-cache.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2009 IITP RAS
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Based on
19
* NS-2 AODV model developed by the CMU/MONARCH group and optimized and
20
* tuned by Samir Das and Mahesh Marina, University of Cincinnati;
21
*
22
* AODV-UU implementation by Erik Nordström of Uppsala University
23
* http://core.it.uu.se/core/index.php/AODV-UU
24
*
25
* Authors: Elena Buchatskaia <borovkovaes@iitp.ru>
26
* Pavel Boyko <boyko@iitp.ru>
27
*/
28
#include "
aodv-id-cache.h
"
29
#include <algorithm>
30
31
namespace
ns3
{
32
namespace
aodv {
33
bool
34
IdCache::IsDuplicate
(
Ipv4Address
addr, uint32_t
id
)
35
{
36
Purge
();
37
for
(std::vector<UniqueId>::const_iterator i =
m_idCache
.begin ();
38
i !=
m_idCache
.end (); ++i)
39
{
40
if
(i->m_context == addr && i->m_id ==
id
)
41
{
42
return
true
;
43
}
44
}
45
struct
UniqueId
uniqueId =
46
{
47
addr, id,
m_lifetime
+
Simulator::Now
()
48
};
49
m_idCache
.push_back (uniqueId);
50
return
false
;
51
}
52
void
53
IdCache::Purge
()
54
{
55
m_idCache
.erase (remove_if (
m_idCache
.begin (),
m_idCache
.end (),
56
IsExpired
()),
m_idCache
.end ());
57
}
58
59
uint32_t
60
IdCache::GetSize
()
61
{
62
Purge
();
63
return
m_idCache
.size ();
64
}
65
66
}
67
}
aodv-id-cache.h
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:41
ns3::Simulator::Now
static Time Now(void)
Return the current simulation virtual time.
Definition:
simulator.cc:195
ns3::aodv::IdCache::m_idCache
std::vector< UniqueId > m_idCache
Already seen IDs.
Definition:
aodv-id-cache.h:110
ns3::aodv::IdCache::Purge
void Purge()
Remove all expired entries.
Definition:
aodv-id-cache.cc:53
ns3::aodv::IdCache::m_lifetime
Time m_lifetime
Default lifetime for ID records.
Definition:
aodv-id-cache.h:112
ns3::aodv::IdCache::IsDuplicate
bool IsDuplicate(Ipv4Address addr, uint32_t id)
Check that entry (addr, id) exists in cache.
Definition:
aodv-id-cache.cc:34
ns3::aodv::IdCache::GetSize
uint32_t GetSize()
Definition:
aodv-id-cache.cc:60
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:97
ns3::aodv::IdCache::UniqueId
Unique packet ID.
Definition:
aodv-id-cache.h:85
src
aodv
model
aodv-id-cache.cc
Generated on Tue Feb 6 2024 19:21:14 for ns-3 by
1.9.1