A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
{
38
namespace
aodv
39
{
45
class
IdCache
46
{
47
public
:
49
IdCache
(
Time
lifetime) :
m_lifetime
(lifetime) {}
51
bool
IsDuplicate
(
Ipv4Address
addr, uint32_t
id
);
53
void
Purge
();
55
uint32_t
GetSize
();
57
void
SetLifetime
(
Time
lifetime) {
m_lifetime
= lifetime; }
59
Time
GetLifeTime
()
const
{
return
m_lifetime
; }
60
private
:
62
struct
UniqueId
63
{
65
Ipv4Address
m_context
;
67
uint32_t
m_id
;
69
Time
m_expire
;
70
};
71
struct
IsExpired
72
{
73
bool
operator()
(
const
struct
UniqueId
& u)
const
74
{
75
return
(u.
m_expire
<
Simulator::Now
());
76
}
77
};
79
std::vector<UniqueId>
m_idCache
;
81
Time
m_lifetime
;
82
};
83
84
}
85
}
86
#endif
/* AODV_ID_CACHE_H */
ns3::Time
keep track of time values and allow control of global simulation resolution
Definition:
nstime.h:81
ns3::aodv::IdCache::IsExpired
Definition:
aodv-id-cache.h:71
ns3::aodv::IdCache
Unique packets identification cache used for simple duplicate detection.
Definition:
aodv-id-cache.h:45
ns3::aodv::IdCache::IsExpired::operator()
bool operator()(const struct UniqueId &u) const
Definition:
aodv-id-cache.h:73
ns3::aodv::IdCache::Purge
void Purge()
Remove all expired entries.
Definition:
aodv-id-cache.cc:49
ns3::aodv::IdCache::UniqueId::m_id
uint32_t m_id
The id.
Definition:
aodv-id-cache.h:67
ns3::aodv::IdCache::m_idCache
std::vector< UniqueId > m_idCache
Already seen IDs.
Definition:
aodv-id-cache.h:79
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:65
ns3::aodv::IdCache::IdCache
IdCache(Time lifetime)
c-tor
Definition:
aodv-id-cache.h:49
ns3::aodv::IdCache::GetSize
uint32_t GetSize()
Return number of entries in cache.
Definition:
aodv-id-cache.cc:56
ns3::Simulator::Now
static Time Now(void)
Return the "current simulation time".
Definition:
simulator.cc:180
ns3::aodv::IdCache::GetLifeTime
Time GetLifeTime() const
Return lifetime for existing entries in cache.
Definition:
aodv-id-cache.h:59
ns3::aodv::IdCache::SetLifetime
void SetLifetime(Time lifetime)
Set lifetime for future added entries.
Definition:
aodv-id-cache.h:57
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:38
ns3::aodv::IdCache::UniqueId
Unique packet ID.
Definition:
aodv-id-cache.h:62
ns3::aodv::IdCache::IsDuplicate
bool IsDuplicate(Ipv4Address addr, uint32_t id)
Check that entry (addr, id) exists in cache. Add entry, if it doesn't exist.
Definition:
aodv-id-cache.cc:36
ns3::aodv::IdCache::UniqueId::m_expire
Time m_expire
When record will expire.
Definition:
aodv-id-cache.h:69
ns3::aodv::IdCache::m_lifetime
Time m_lifetime
Default lifetime for ID records.
Definition:
aodv-id-cache.h:81
src
aodv
model
aodv-id-cache.h
Generated on Sat Apr 19 2014 14:06:49 for ns-3 by
1.8.6