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
ipv6-pmtu-cache.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2013 Universita' di Firenze
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
* Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
19
*/
20
21
#include "
ipv6-pmtu-cache.h
"
22
#include "ns3/log.h"
23
#include "ns3/simulator.h"
24
25
NS_LOG_COMPONENT_DEFINE
(
"Ipv6PmtuCache"
);
26
27
namespace
ns3 {
28
29
NS_OBJECT_ENSURE_REGISTERED
(Ipv6PmtuCache);
30
31
TypeId
Ipv6PmtuCache::GetTypeId
()
32
{
33
static
TypeId
tid =
TypeId
(
"ns3::Ipv6PmtuCache"
)
34
.
SetParent
<
Object
> ()
35
.AddAttribute (
"CacheExpiryTime"
,
36
"Validity time for a Path MTU entry. Default is 10 minutes, minimum is 5 minutes."
,
37
TimeValue
(Seconds (60 * 10)),
38
MakeTimeAccessor (&
Ipv6PmtuCache::m_validityTime
),
39
MakeTimeChecker
(
Time
(Seconds (60 * 5))))
40
;
41
return
tid;
42
}
43
44
Ipv6PmtuCache::Ipv6PmtuCache
()
45
{
46
}
47
48
Ipv6PmtuCache::~Ipv6PmtuCache
()
49
{
50
}
51
52
void
Ipv6PmtuCache::DoDispose
()
53
{
54
for
(
pathMtuTimerIter
iter =
m_pathMtuTimer
.begin (); iter !=
m_pathMtuTimer
.end (); iter++)
55
{
56
iter->second.Cancel ();
57
}
58
m_pathMtuTimer
.clear ();
59
m_pathMtu
.clear ();
60
}
61
62
uint32_t
Ipv6PmtuCache::GetPmtu
(
Ipv6Address
dst)
63
{
64
NS_LOG_FUNCTION
(
this
<< dst);
65
66
if
(
m_pathMtu
.find (dst) !=
m_pathMtu
.end ())
67
{
68
return
m_pathMtu
[dst];
69
}
70
return
0;
71
}
72
73
void
Ipv6PmtuCache::SetPmtu
(
Ipv6Address
dst, uint32_t pmtu)
74
{
75
NS_LOG_FUNCTION
(
this
<< dst << pmtu);
76
77
m_pathMtu
[dst] = pmtu;
78
if
(
m_pathMtuTimer
.find (dst) !=
m_pathMtuTimer
.end ())
79
{
80
m_pathMtuTimer
[dst].Cancel ();
81
}
82
EventId
pMtuTimer;
83
pMtuTimer =
Simulator::Schedule
(
m_validityTime
, &
Ipv6PmtuCache::ClearPmtu
,
this
, dst);
84
m_pathMtuTimer
[dst] = pMtuTimer;
85
}
86
87
Time
Ipv6PmtuCache::GetPmtuValidityTime
()
const
88
{
89
NS_LOG_FUNCTION
(
this
);
90
return
m_validityTime
;
91
}
92
93
bool
Ipv6PmtuCache::SetPmtuValidityTime
(
Time
validity)
94
{
95
NS_LOG_FUNCTION
(
this
<< validity);
96
97
if
(validity > Seconds (60 * 5))
98
{
99
m_validityTime
= validity;
100
return
true
;
101
}
102
103
NS_LOG_LOGIC
(
"rejecting a PMTU validity timer lesser than 5 minutes"
);
104
return
false
;
105
}
106
107
void
Ipv6PmtuCache::ClearPmtu
(
Ipv6Address
dst)
108
{
109
NS_LOG_FUNCTION
(
this
<< dst);
110
111
m_pathMtu
.erase (dst);
112
m_pathMtuTimer
.erase (dst);
113
}
114
115
}
116
ns3::Time
keep track of time values and allow control of global simulation resolution
Definition:
nstime.h:81
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
ns3::Ipv6PmtuCache::GetPmtu
uint32_t GetPmtu(Ipv6Address dst)
Gets the known Path MTU for the specific destination.
Definition:
ipv6-pmtu-cache.cc:62
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Definition:
log.h:122
ns3::Simulator::Schedule
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Definition:
simulator.h:824
ns3::Ipv6PmtuCache::SetPmtuValidityTime
bool SetPmtuValidityTime(Time validity)
Sets the Path MTU validity time (minimum is 5 minutes)
Definition:
ipv6-pmtu-cache.cc:93
ns3::Ipv6PmtuCache::Ipv6PmtuCache
Ipv6PmtuCache()
Constructor.
Definition:
ipv6-pmtu-cache.cc:44
ns3::TimeValue
hold objects of type ns3::Time
Definition:
nstime.h:828
ns3::NS_OBJECT_ENSURE_REGISTERED
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
ns3::Ipv6PmtuCache::m_pathMtu
std::map< Ipv6Address, uint32_t > m_pathMtu
Path MTU table.
Definition:
ipv6-pmtu-cache.h:109
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Definition:
log.h:334
ns3::Ipv6PmtuCache::DoDispose
virtual void DoDispose()
Dispose object.
Definition:
ipv6-pmtu-cache.cc:52
ns3::Ipv6PmtuCache::m_pathMtuTimer
std::map< Ipv6Address, EventId > m_pathMtuTimer
Path MTU Expiration table.
Definition:
ipv6-pmtu-cache.h:115
ns3::Ipv6PmtuCache::GetPmtuValidityTime
Time GetPmtuValidityTime() const
Gets the Path MTU validity time.
Definition:
ipv6-pmtu-cache.cc:87
ns3::Ipv6PmtuCache::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
ipv6-pmtu-cache.cc:31
ns3::Ipv6PmtuCache::~Ipv6PmtuCache
~Ipv6PmtuCache()
Destructor.
Definition:
ipv6-pmtu-cache.cc:48
ns3::Ipv6Address
Describes an IPv6 address.
Definition:
ipv6-address.h:46
ns3::EventId
an identifier for simulation events.
Definition:
event-id.h:46
ipv6-pmtu-cache.h
ns3::Ipv6PmtuCache::pathMtuTimerIter
std::map< Ipv6Address, EventId >::iterator pathMtuTimerIter
Definition:
ipv6-pmtu-cache.h:111
ns3::Ipv6PmtuCache::m_validityTime
Time m_validityTime
Path MTU entry validity time.
Definition:
ipv6-pmtu-cache.h:120
ns3::Ipv6PmtuCache::SetPmtu
void SetPmtu(Ipv6Address dst, uint32_t pmtu)
Sets the Path MTU for the specific destination.
Definition:
ipv6-pmtu-cache.cc:73
ns3::MakeTimeChecker
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive.
Definition:
time.cc:404
ns3::Ipv6PmtuCache::ClearPmtu
void ClearPmtu(Ipv6Address dst)
Clears the Path MTU for the specific destination.
Definition:
ipv6-pmtu-cache.cc:107
ns3::Object
a base class which provides memory management and object aggregation
Definition:
object.h:63
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:49
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Definition:
type-id.cc:610
src
internet
model
ipv6-pmtu-cache.cc
Generated on Sat Nov 16 2013 16:17:41 for ns-3 by
1.8.5