Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 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: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | */ |
| 20 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 21 | #ifndef _NDN_PIT_IMPL_H_ |
| 22 | #define _NDN_PIT_IMPL_H_ |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 23 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 24 | #include "ndn-pit.h" |
Alexander Afanasyev | e3d126f | 2012-07-16 17:07:31 -0700 | [diff] [blame] | 25 | |
Alexander Afanasyev | 1a2df6a | 2012-08-17 13:21:51 -0700 | [diff] [blame] | 26 | #include "../../utils/trie/trie-with-policy.h" |
Alexander Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 27 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 28 | #include "ndn-pit-entry-impl.h" |
Alexander Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 29 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 30 | #include "ns3/ndn-name-components.h" |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 31 | |
| 32 | namespace ns3 { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 33 | namespace ndn { |
| 34 | |
| 35 | class ForwardingStrategy; |
| 36 | |
| 37 | namespace pit { |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 38 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 39 | /** |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 40 | * \ingroup ndn |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 41 | * \brief Class implementing Pending Interests Table |
| 42 | */ |
Alexander Afanasyev | bd6f3f4 | 2012-07-26 17:50:17 -0700 | [diff] [blame] | 43 | template<class Policy> |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 44 | class PitImpl : public Pit |
| 45 | , protected ndnSIM::trie_with_policy<NameComponents, |
| 46 | ndnSIM::smart_pointer_payload_traits< EntryImpl< PitImpl< Policy > > >, |
| 47 | // ndnSIM::persistent_policy_traits |
| 48 | Policy |
| 49 | > |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 50 | { |
| 51 | public: |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 52 | typedef ndnSIM::trie_with_policy<NameComponents, |
| 53 | ndnSIM::smart_pointer_payload_traits< EntryImpl< PitImpl< Policy > > >, |
Alexander Afanasyev | bd6f3f4 | 2012-07-26 17:50:17 -0700 | [diff] [blame] | 54 | // ndnSIM::persistent_policy_traits |
| 55 | Policy |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 56 | > super; |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 57 | typedef EntryImpl< PitImpl< Policy > > entry; |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 58 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 59 | /** |
| 60 | * \brief Interface ID |
| 61 | * |
| 62 | * \return interface ID |
| 63 | */ |
| 64 | static TypeId GetTypeId (); |
| 65 | |
| 66 | /** |
| 67 | * \brief PIT constructor |
| 68 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 69 | PitImpl (); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 70 | |
| 71 | /** |
| 72 | * \brief Destructor |
| 73 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 74 | virtual ~PitImpl (); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 75 | |
Alexander Afanasyev | 7456b70 | 2013-02-01 22:41:48 -0800 | [diff] [blame] | 76 | // inherited from Pit |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 77 | virtual Ptr<Entry> |
| 78 | Lookup (const ContentObjectHeader &header); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 79 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 80 | virtual Ptr<Entry> |
| 81 | Lookup (const InterestHeader &header); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 82 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 83 | virtual Ptr<Entry> |
| 84 | Create (Ptr<const InterestHeader> header); |
Alexander Afanasyev | 7456b70 | 2013-02-01 22:41:48 -0800 | [diff] [blame] | 85 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 86 | virtual void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 87 | MarkErased (Ptr<Entry> entry); |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 88 | |
| 89 | virtual void |
| 90 | Print (std::ostream &os) const; |
Alexander Afanasyev | 1aa4bbc | 2012-07-09 17:17:25 -0700 | [diff] [blame] | 91 | |
Alexander Afanasyev | f1e013f | 2012-07-11 17:59:40 -0700 | [diff] [blame] | 92 | virtual uint32_t |
| 93 | GetSize () const; |
| 94 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 95 | virtual Ptr<Entry> |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 96 | Begin (); |
| 97 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 98 | virtual Ptr<Entry> |
Alexander Afanasyev | 30f60e3 | 2012-07-10 14:21:16 -0700 | [diff] [blame] | 99 | End (); |
| 100 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 101 | virtual Ptr<Entry> |
| 102 | Next (Ptr<Entry>); |
Alexander Afanasyev | 7456b70 | 2013-02-01 22:41:48 -0800 | [diff] [blame] | 103 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 104 | protected: |
Alexander Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 105 | void RescheduleCleaning (); |
| 106 | void CleanExpired (); |
Alexander Afanasyev | 7456b70 | 2013-02-01 22:41:48 -0800 | [diff] [blame] | 107 | |
| 108 | // inherited from Object class |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 109 | virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object |
| 110 | virtual void DoDispose (); ///< @brief Do cleanup |
| 111 | |
| 112 | private: |
| 113 | uint32_t |
| 114 | GetMaxSize () const; |
| 115 | |
| 116 | void |
| 117 | SetMaxSize (uint32_t maxSize); |
Alexander Afanasyev | 7456b70 | 2013-02-01 22:41:48 -0800 | [diff] [blame] | 118 | |
| 119 | uint32_t |
| 120 | GetCurrentSize () const; |
| 121 | |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 122 | private: |
Alexander Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 123 | EventId m_cleanEvent; |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 124 | Ptr<Fib> m_fib; ///< \brief Link to FIB table |
| 125 | Ptr<ForwardingStrategy> m_forwardingStrategy; |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 126 | |
| 127 | // indexes |
| 128 | typedef |
Alexander Afanasyev | 6b51b08 | 2012-07-27 16:28:34 -0700 | [diff] [blame] | 129 | boost::intrusive::multiset<entry, |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 130 | boost::intrusive::compare < TimestampIndex< entry > >, |
| 131 | boost::intrusive::member_hook< entry, |
| 132 | boost::intrusive::set_member_hook<>, |
| 133 | &entry::time_hook_> |
Alexander Afanasyev | 413c7f1 | 2012-07-10 17:35:16 -0700 | [diff] [blame] | 134 | > time_index; |
Alexander Afanasyev | 7456b70 | 2013-02-01 22:41:48 -0800 | [diff] [blame] | 135 | time_index i_time; |
| 136 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 137 | friend class EntryImpl< PitImpl >; |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 138 | }; |
| 139 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 140 | } // namespace pit |
| 141 | } // namespace ndn |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 142 | } // namespace ns3 |
| 143 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 144 | #endif /* NDN_PIT_IMPL_H */ |