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 * 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
20namespace ns3
21{
22namespace aodv
23{
24bool
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
40void
42{
43 m_idCache.erase(remove_if(m_idCache.begin(), m_idCache.end(), IsExpired()), m_idCache.end());
44}
45
48{
49 Purge();
50 return m_idCache.size();
51}
52
53} // namespace aodv
54} // namespace ns3
Ipv4 addresses are stored in host order in this class.
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
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.