src/internet/model/ipv6-pmtu-cache.h
author Tommaso Pecorella <tommaso.pecorella@unifi.it>
Mon, 12 Aug 2013 06:51:18 +0200
changeset 10127 f4cee68de571
child 10137 3e25a23e7c48
permissions -rw-r--r--
Bug 1721 - Path MTU isn't handled properly
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10127
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
     2
/*
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
     3
 * Copyright (c) 2013 Universita' di Firenze
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
     4
 *
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
     8
 *
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    12
 * GNU General Public License for more details.
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    13
 *
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    17
 *
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    18
 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    19
 */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    20
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    21
#ifndef IPV6_PMTU_CACHE_H
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    22
#define IPV6_PMTU_CACHE_H
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    23
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    24
#include <map>
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    25
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    26
#include "ns3/core-module.h"
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    27
#include "ns3/ipv6-address.h"
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    28
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    29
namespace ns3 {
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    30
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    31
/**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    32
 * \ingroup ipv6
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    33
 * \brief This class implements the Path MTU cache, as defined by RFC 1981.
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    34
 *
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    35
 * The Path MTU is stored according to the destination address, and it is
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    36
 * cleared upon expiration (default validity time is 10 minutes).
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    37
 *
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    38
 * The "infinite lifetime" PMTU entry type is not implemented, since it is
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    39
 * useful only in an very limited number of cases. See the RFC for further
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    40
 * details.
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    41
 */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    42
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    43
class Ipv6PmtuCache : public Object
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    44
{
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    45
public:
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    46
  class Entry;
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    47
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    48
  /**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    49
   * \brief Get the type ID
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    50
   * \return type ID
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    51
   */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    52
  static TypeId GetTypeId ();
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    53
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    54
  /**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    55
   * \brief Constructor.
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    56
   */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    57
  Ipv6PmtuCache ();
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    58
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    59
  /**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    60
   * \brief Destructor.
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    61
   */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    62
  ~Ipv6PmtuCache ();
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    63
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    64
  /**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    65
   * \brief Dispose object.
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    66
   */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    67
  virtual void DoDispose ();
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    68
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    69
  /**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    70
   * \brief Gets the known Path MTU for the specific destination
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    71
   * \param dst the destination
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    72
   * \return the Path MTU (zero if unknown)
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    73
   */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    74
  uint32_t GetPmtu (Ipv6Address dst);
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    75
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    76
  /**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    77
   * \brief Sets the Path MTU for the specific destination
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    78
   * \param dst the destination
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    79
   * \param pmtu the Path MTU
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    80
   */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    81
  void SetPmtu (Ipv6Address dst, uint32_t pmtu);
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    82
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    83
  /**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    84
   * \brief Gets the Path MTU validity time
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    85
   * \return the Path MTU validity time
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    86
   */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    87
  Time GetPmtuValidityTime () const;
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    88
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    89
  /**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    90
   * \brief Sets the Path MTU validity time (minimum is 5 minutes)
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    91
   * \param validity the Path MTU validity time
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    92
   * \return true if the change was successful
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    93
   */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    94
  bool SetPmtuValidityTime (Time validity);
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    95
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    96
private:
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    97
  /**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    98
   * \brief Clears the Path MTU for the specific destination
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
    99
   * \param dst the destination
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   100
   */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   101
  void ClearPmtu (Ipv6Address dst);
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   102
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   103
  /**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   104
   * \brief Path MTU table
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   105
   */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   106
  std::map<Ipv6Address, uint32_t> m_pathMtu;
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   107
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   108
  typedef std::map<Ipv6Address, EventId> ::iterator pathMtuTimerIter;
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   109
  /**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   110
   * \brief Path MTU Expiration table
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   111
   */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   112
  std::map<Ipv6Address, EventId> m_pathMtuTimer;
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   113
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   114
  /**
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   115
   * \brief Path MTU entry validity time
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   116
   */
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   117
  Time m_validityTime;
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   118
};
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   119
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   120
}
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   121
f4cee68de571 Bug 1721 - Path MTU isn't handled properly
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
diff changeset
   122
#endif /* IPV6_PMTU_CACHE_H */