|
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 #ifndef IPV6_PMTU_CACHE_H |
|
22 #define IPV6_PMTU_CACHE_H |
|
23 |
|
24 #include <map> |
|
25 |
|
26 #include "ns3/core-module.h" |
|
27 #include "ns3/ipv6-address.h" |
|
28 |
|
29 namespace ns3 { |
|
30 |
|
31 /** |
|
32 * \ingroup ipv6 |
|
33 * \brief This class implements the Path MTU cache, as defined by RFC 1981. |
|
34 * |
|
35 * The Path MTU is stored according to the destination address, and it is |
|
36 * cleared upon expiration (default validity time is 10 minutes). |
|
37 * |
|
38 * The "infinite lifetime" PMTU entry type is not implemented, since it is |
|
39 * useful only in an very limited number of cases. See the RFC for further |
|
40 * details. |
|
41 */ |
|
42 |
|
43 class Ipv6PmtuCache : public Object |
|
44 { |
|
45 public: |
|
46 class Entry; |
|
47 |
|
48 /** |
|
49 * \brief Get the type ID |
|
50 * \return type ID |
|
51 */ |
|
52 static TypeId GetTypeId (); |
|
53 |
|
54 /** |
|
55 * \brief Constructor. |
|
56 */ |
|
57 Ipv6PmtuCache (); |
|
58 |
|
59 /** |
|
60 * \brief Destructor. |
|
61 */ |
|
62 ~Ipv6PmtuCache (); |
|
63 |
|
64 /** |
|
65 * \brief Dispose object. |
|
66 */ |
|
67 virtual void DoDispose (); |
|
68 |
|
69 /** |
|
70 * \brief Gets the known Path MTU for the specific destination |
|
71 * \param dst the destination |
|
72 * \return the Path MTU (zero if unknown) |
|
73 */ |
|
74 uint32_t GetPmtu (Ipv6Address dst); |
|
75 |
|
76 /** |
|
77 * \brief Sets the Path MTU for the specific destination |
|
78 * \param dst the destination |
|
79 * \param pmtu the Path MTU |
|
80 */ |
|
81 void SetPmtu (Ipv6Address dst, uint32_t pmtu); |
|
82 |
|
83 /** |
|
84 * \brief Gets the Path MTU validity time |
|
85 * \return the Path MTU validity time |
|
86 */ |
|
87 Time GetPmtuValidityTime () const; |
|
88 |
|
89 /** |
|
90 * \brief Sets the Path MTU validity time (minimum is 5 minutes) |
|
91 * \param validity the Path MTU validity time |
|
92 * \return true if the change was successful |
|
93 */ |
|
94 bool SetPmtuValidityTime (Time validity); |
|
95 |
|
96 private: |
|
97 /** |
|
98 * \brief Clears the Path MTU for the specific destination |
|
99 * \param dst the destination |
|
100 */ |
|
101 void ClearPmtu (Ipv6Address dst); |
|
102 |
|
103 /** |
|
104 * \brief Path MTU table |
|
105 */ |
|
106 std::map<Ipv6Address, uint32_t> m_pathMtu; |
|
107 |
|
108 typedef std::map<Ipv6Address, EventId> ::iterator pathMtuTimerIter; |
|
109 /** |
|
110 * \brief Path MTU Expiration table |
|
111 */ |
|
112 std::map<Ipv6Address, EventId> m_pathMtuTimer; |
|
113 |
|
114 /** |
|
115 * \brief Path MTU entry validity time |
|
116 */ |
|
117 Time m_validityTime; |
|
118 }; |
|
119 |
|
120 } |
|
121 |
|
122 #endif /* IPV6_PMTU_CACHE_H */ |