A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
aodv
model
aodv-id-cache.h
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
29
#ifndef AODV_ID_CACHE_H
30
#define AODV_ID_CACHE_H
31
32
#include "ns3/ipv4-address.h"
33
#include "ns3/simulator.h"
34
#include <vector>
35
36
namespace
ns3
{
37
namespace
aodv {
43
class
IdCache
44
{
45
public
:
50
IdCache
(
Time
lifetime) :
m_lifetime
(lifetime)
51
{
52
}
59
bool
IsDuplicate
(
Ipv4Address
addr, uint32_t
id
);
61
void
Purge
();
65
uint32_t
GetSize
();
70
void
SetLifetime
(
Time
lifetime)
71
{
72
m_lifetime
= lifetime;
73
}
78
Time
GetLifeTime
()
const
79
{
80
return
m_lifetime
;
81
}
82
private
:
84
struct
UniqueId
85
{
87
Ipv4Address
m_context
;
89
uint32_t
m_id
;
91
Time
m_expire
;
92
};
96
struct
IsExpired
97
{
104
bool
operator()
(
const
struct
UniqueId
& u)
const
105
{
106
return
(u.
m_expire
<
Simulator::Now
());
107
}
108
};
110
std::vector<UniqueId>
m_idCache
;
112
Time
m_lifetime
;
113
};
114
115
}
// namespace aodv
116
}
// namespace ns3
117
118
#endif
/* AODV_ID_CACHE_H */
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:102
ns3::aodv::IdCache::IsExpired
IsExpired structure.
Definition:
aodv-id-cache.h:96
ns3::aodv::IdCache
Unique packets identification cache used for simple duplicate detection.
Definition:
aodv-id-cache.h:43
ns3::aodv::IdCache::Purge
void Purge()
Remove all expired entries.
Definition:
aodv-id-cache.cc:53
ns3::aodv::IdCache::UniqueId::m_id
uint32_t m_id
The id.
Definition:
aodv-id-cache.h:89
ns3::aodv::IdCache::IsExpired::operator()
bool operator()(const struct UniqueId &u) const
Check if the entry is expired.
Definition:
aodv-id-cache.h:104
ns3::aodv::IdCache::GetLifeTime
Time GetLifeTime() const
Return lifetime for existing entries in cache.
Definition:
aodv-id-cache.h:78
ns3::aodv::IdCache::m_idCache
std::vector< UniqueId > m_idCache
Already seen IDs.
Definition:
aodv-id-cache.h:110
ns3::aodv::IdCache::UniqueId::m_context
Ipv4Address m_context
ID is supposed to be unique in single address context (e.g. sender address)
Definition:
aodv-id-cache.h:87
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::aodv::IdCache::IdCache
IdCache(Time lifetime)
constructor
Definition:
aodv-id-cache.h:50
ns3::aodv::IdCache::GetSize
uint32_t GetSize()
Definition:
aodv-id-cache.cc:60
ns3::Simulator::Now
static Time Now(void)
Return the current simulation virtual time.
Definition:
simulator.cc:249
ns3::aodv::IdCache::SetLifetime
void SetLifetime(Time lifetime)
Set lifetime for future added entries.
Definition:
aodv-id-cache.h:70
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:40
ns3::aodv::IdCache::UniqueId
Unique packet ID.
Definition:
aodv-id-cache.h:84
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::UniqueId::m_expire
Time m_expire
When record will expire.
Definition:
aodv-id-cache.h:91
ns3::aodv::IdCache::m_lifetime
Time m_lifetime
Default lifetime for ID records.
Definition:
aodv-id-cache.h:112
Generated on Wed Nov 7 2018 10:01:47 for ns-3 by
1.8.14