A Discrete-Event Network Simulator
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 * 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
31namespace ns3
32{
33namespace aodv
34{
35bool
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
51void
53{
54 m_idCache.erase(remove_if(m_idCache.begin(), m_idCache.end(), IsExpired()), m_idCache.end());
55}
56
59{
60 Purge();
61 return m_idCache.size();
62}
63
64} // namespace aodv
65} // namespace ns3
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
std::vector< UniqueId > m_idCache
Already seen IDs.
void Purge()
Remove all expired entries.
Time m_lifetime
Default lifetime for ID records.
bool IsDuplicate(Ipv4Address addr, uint32_t id)
Check that entry (addr, id) exists in cache.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
IsExpired structure.