A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv6-pmtu-cache.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013 Universita' di Firenze
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
7 */
8
9#include "ipv6-pmtu-cache.h"
10
11#include "ns3/log.h"
12#include "ns3/simulator.h"
13
14namespace ns3
15{
16
17NS_LOG_COMPONENT_DEFINE("Ipv6PmtuCache");
18
19NS_OBJECT_ENSURE_REGISTERED(Ipv6PmtuCache);
20
21TypeId
23{
24 static TypeId tid =
25 TypeId("ns3::Ipv6PmtuCache")
27 .SetGroupName("Internet")
28 .AddAttribute(
29 "CacheExpiryTime",
30 "Validity time for a Path MTU entry. Default is 10 minutes, minimum is 5 minutes.",
31 TimeValue(Seconds(60 * 10)),
33 MakeTimeChecker(Time(Seconds(60 * 5))));
34 return tid;
35}
36
40
44
45void
47{
48 for (auto iter = m_pathMtuTimer.begin(); iter != m_pathMtuTimer.end(); iter++)
49 {
50 iter->second.Cancel();
51 }
52 m_pathMtuTimer.clear();
53 m_pathMtu.clear();
54}
55
58{
59 NS_LOG_FUNCTION(this << dst);
60
61 if (m_pathMtu.find(dst) != m_pathMtu.end())
62 {
63 return m_pathMtu[dst];
64 }
65 return 0;
66}
67
68void
70{
71 NS_LOG_FUNCTION(this << dst << pmtu);
72
73 m_pathMtu[dst] = pmtu;
74 if (m_pathMtuTimer.find(dst) != m_pathMtuTimer.end())
75 {
76 m_pathMtuTimer[dst].Cancel();
77 }
78 EventId pMtuTimer;
80 m_pathMtuTimer[dst] = pMtuTimer;
81}
82
83Time
89
90bool
92{
93 NS_LOG_FUNCTION(this << validity);
94
95 if (validity > Seconds(60 * 5))
96 {
97 m_validityTime = validity;
98 return true;
99 }
100
101 NS_LOG_LOGIC("rejecting a PMTU validity timer lesser than 5 minutes");
102 return false;
103}
104
105void
107{
108 NS_LOG_FUNCTION(this << dst);
109
110 m_pathMtu.erase(dst);
111 m_pathMtuTimer.erase(dst);
112}
113
114} // namespace ns3
An identifier for simulation events.
Definition event-id.h:45
Describes an IPv6 address.
void DoDispose() override
Dispose object.
~Ipv6PmtuCache() override
Destructor.
std::map< Ipv6Address, uint32_t > m_pathMtu
Path MTU table.
void ClearPmtu(Ipv6Address dst)
Clears the Path MTU for the specific destination.
Ipv6PmtuCache()
Constructor.
std::map< Ipv6Address, EventId > m_pathMtuTimer
Path MTU Expiration table.
static TypeId GetTypeId()
Get the type ID.
Time GetPmtuValidityTime() const
Gets the Path MTU validity time.
Time m_validityTime
Path MTU entry validity time.
uint32_t GetPmtu(Ipv6Address dst)
Gets the known Path MTU for the specific destination.
bool SetPmtuValidityTime(Time validity)
Sets the Path MTU validity time (minimum is 5 minutes)
void SetPmtu(Ipv6Address dst, uint32_t pmtu)
Sets the Path MTU for the specific destination.
A base class which provides memory management and object aggregation.
Definition object.h:78
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition log.h:271
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition nstime.h:1396
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1416