Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -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_ENTRY_H_ |
| 22 | #define _NDN_PIT_ENTRY_H_ |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 23 | |
| 24 | #include "ns3/ptr.h" |
Alexander Afanasyev | 11f7bb4 | 2012-07-09 17:06:30 -0700 | [diff] [blame] | 25 | #include "ns3/simple-ref-count.h" |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 26 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 27 | #include "ns3/ndn-fib.h" |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 28 | |
| 29 | #include "ns3/ndn-pit-entry-incoming-face.h" |
| 30 | #include "ns3/ndn-pit-entry-outgoing-face.h" |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 31 | |
| 32 | #include <boost/multi_index_container.hpp> |
| 33 | #include <boost/multi_index/tag.hpp> |
| 34 | #include <boost/multi_index/ordered_index.hpp> |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 35 | // #include <boost/multi_index/composite_key.hpp> |
| 36 | // #include <boost/multi_index/hashed_index.hpp> |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 37 | #include <boost/multi_index/member.hpp> |
Alexander Afanasyev | 9a98970 | 2012-06-29 17:44:00 -0700 | [diff] [blame] | 38 | // #include <boost/multi_index/mem_fun.hpp> |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 39 | #include <set> |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame] | 40 | #include <boost/shared_ptr.hpp> |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 41 | |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 42 | namespace ns3 { |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 43 | namespace ndn { |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 44 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 45 | class Pit; |
| 46 | |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame] | 47 | namespace fw { class Tag; } |
| 48 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 49 | namespace pit { |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 50 | |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 51 | /** |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 52 | * @ingroup ndn-pit |
| 53 | * @brief structure for PIT entry |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 54 | * |
| 55 | * All set-methods are virtual, in case index rearrangement is necessary in the derived classes |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 56 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 57 | class Entry : public SimpleRefCount<Entry> |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 58 | { |
| 59 | public: |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 60 | typedef std::set< IncomingFace > in_container; ///< @brief incoming faces container type |
Alexander Afanasyev | f034cbd | 2012-06-29 14:28:31 -0700 | [diff] [blame] | 61 | typedef in_container::iterator in_iterator; ///< @brief iterator to incoming faces |
| 62 | |
Alexander Afanasyev | c202fd9 | 2012-09-03 21:46:00 -0700 | [diff] [blame] | 63 | // typedef OutgoingFaceContainer::type out_container; ///< @brief outgoing faces container type |
| 64 | typedef std::set< OutgoingFace > out_container; ///< @brief outgoing faces container type |
Alexander Afanasyev | f034cbd | 2012-06-29 14:28:31 -0700 | [diff] [blame] | 65 | typedef out_container::iterator out_iterator; ///< @brief iterator to outgoing faces |
| 66 | |
| 67 | typedef std::set< uint32_t > nonce_container; ///< @brief nonce container type |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 68 | |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 69 | /** |
| 70 | * \brief PIT entry constructor |
| 71 | * \param prefix Prefix of the PIT entry |
Alexander Afanasyev | 0a61c34 | 2011-12-06 12:48:55 -0800 | [diff] [blame] | 72 | * \param offsetTime Relative time to the current moment, representing PIT entry lifetime |
Alexander Afanasyev | c5a23e2 | 2011-09-07 00:37:36 -0700 | [diff] [blame] | 73 | * \param fibEntry A FIB entry associated with the PIT entry |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 74 | */ |
Alexander Afanasyev | eae83ee | 2013-03-15 15:01:10 -0700 | [diff] [blame] | 75 | Entry (Pit &container, Ptr<const Interest> header, Ptr<fib::Entry> fibEntry); |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 76 | |
| 77 | /** |
| 78 | * @brief Virtual destructor |
| 79 | */ |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 80 | virtual ~Entry (); |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 81 | |
Alexander Afanasyev | 0a61c34 | 2011-12-06 12:48:55 -0800 | [diff] [blame] | 82 | /** |
| 83 | * @brief Update lifetime of PIT entry |
| 84 | * |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 85 | * @param lifetime desired lifetime of the pit entry (relative to the Simulator::Now ()) |
Alexander Afanasyev | 0a61c34 | 2011-12-06 12:48:55 -0800 | [diff] [blame] | 86 | * |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 87 | * This function will update PIT entry lifetime to the maximum of the current lifetime and |
| 88 | * the lifetime Simulator::Now () + lifetime |
Alexander Afanasyev | 0a61c34 | 2011-12-06 12:48:55 -0800 | [diff] [blame] | 89 | */ |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 90 | virtual void |
Alexander Afanasyev | 08b7d9e | 2012-08-23 10:53:46 -0700 | [diff] [blame] | 91 | UpdateLifetime (const Time &lifetime); |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 92 | |
| 93 | /** |
Alexander Afanasyev | 08b7d9e | 2012-08-23 10:53:46 -0700 | [diff] [blame] | 94 | * @brief Offset the currently set PIT lifetime (allowed both negative and positive offsets) |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 95 | * |
Alexander Afanasyev | 08b7d9e | 2012-08-23 10:53:46 -0700 | [diff] [blame] | 96 | * @param offsetTime positive or negative offset for the PIT lifetime. |
| 97 | * |
| 98 | * If PIT expire time becomes less than Simulator::Now, then it is adjusted to Simulator::Now. |
| 99 | */ |
| 100 | virtual void |
| 101 | OffsetLifetime (const Time &offsetTime); |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 102 | |
Alexander Afanasyev | 08b7d9e | 2012-08-23 10:53:46 -0700 | [diff] [blame] | 103 | /** |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 104 | * @brief Get prefix of the PIT entry |
| 105 | */ |
Alexander Afanasyev | cfdc14f | 2013-03-15 14:38:44 -0700 | [diff] [blame] | 106 | const Name & |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 107 | GetPrefix () const; |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 108 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 109 | /** |
| 110 | * @brief Get current expiration time of the record |
| 111 | * |
| 112 | * @returns current expiration time of the record |
| 113 | */ |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 114 | const Time & |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 115 | GetExpireTime () const; |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 116 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 117 | /** |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 118 | * @brief Check if nonce `nonce` for the same prefix has already been seen |
| 119 | * |
| 120 | * @param nonce Nonce to check |
| 121 | */ |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 122 | bool |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 123 | IsNonceSeen (uint32_t nonce) const; |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 124 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 125 | /** |
| 126 | * @brief Add `nonce` to the list of seen nonces |
| 127 | * |
| 128 | * @param nonce nonce to add to the list of seen nonces |
| 129 | * |
| 130 | * All nonces are stored for the lifetime of the PIT entry |
| 131 | */ |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 132 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 133 | AddSeenNonce (uint32_t nonce); |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 134 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 135 | /** |
| 136 | * @brief Add `face` to the list of incoming faces |
| 137 | * |
| 138 | * @param face Face to add to the list of incoming faces |
| 139 | * @returns iterator to the added entry |
| 140 | */ |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 141 | virtual in_iterator |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 142 | AddIncoming (Ptr<Face> face); |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 143 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 144 | /** |
Alexander Afanasyev | 9d313d4 | 2011-11-25 13:36:15 -0800 | [diff] [blame] | 145 | * @brief Remove incoming entry for face `face` |
| 146 | */ |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 147 | virtual void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 148 | RemoveIncoming (Ptr<Face> face); |
Alexander Afanasyev | 9d313d4 | 2011-11-25 13:36:15 -0800 | [diff] [blame] | 149 | |
| 150 | /** |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 151 | * @brief Clear all incoming faces either after all of them were satisfied or NACKed |
| 152 | */ |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 153 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 154 | ClearIncoming (); |
Alexander Afanasyev | a5bbe0e | 2011-11-22 17:28:39 -0800 | [diff] [blame] | 155 | |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 156 | /** |
| 157 | * @brief Add `face` to the list of outgoing faces |
| 158 | * |
| 159 | * @param face Face to add to the list of outgoing faces |
| 160 | * @returns iterator to the added entry |
| 161 | */ |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 162 | virtual out_iterator |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 163 | AddOutgoing (Ptr<Face> face); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 164 | |
| 165 | /** |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 166 | * @brief Clear all incoming faces either after all of them were satisfied or NACKed |
| 167 | */ |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 168 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 169 | ClearOutgoing (); |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 170 | |
Alexander Afanasyev | 120bf31 | 2011-12-19 01:24:47 -0800 | [diff] [blame] | 171 | /** |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 172 | * @brief Remove all references to face. |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 173 | * |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 174 | * This method should be called before face is completely removed from the stack. |
| 175 | * Face is removed from the lists of incoming and outgoing faces |
| 176 | */ |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 177 | virtual void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 178 | RemoveAllReferencesToFace (Ptr<Face> face); |
Alexander Afanasyev | 09c7deb | 2011-11-23 14:50:10 -0800 | [diff] [blame] | 179 | |
Alexander Afanasyev | 5a59507 | 2011-11-25 14:49:07 -0800 | [diff] [blame] | 180 | /** |
| 181 | * @brief Flag outgoing face as hopeless |
| 182 | */ |
Alexander Afanasyev | 786936a | 2012-07-17 19:48:15 -0700 | [diff] [blame] | 183 | // virtual void |
| 184 | // SetWaitingInVain (out_iterator face); |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 185 | virtual void |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 186 | SetWaitingInVain (Ptr<Face> face); |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 187 | |
Alexander Afanasyev | 5a59507 | 2011-11-25 14:49:07 -0800 | [diff] [blame] | 188 | /** |
| 189 | * @brief Check if all outgoing faces are NACKed |
| 190 | */ |
| 191 | bool |
| 192 | AreAllOutgoingInVain () const; |
Alexander Afanasyev | a7a2b8b | 2011-11-28 18:19:09 -0800 | [diff] [blame] | 193 | |
Alexander Afanasyev | b4fee8b | 2012-06-06 12:54:26 -0700 | [diff] [blame] | 194 | /** |
Alexander Afanasyev | a7a2b8b | 2011-11-28 18:19:09 -0800 | [diff] [blame] | 195 | * @brief Similar to AreAllOutgoingInVain, but ignores `face` |
| 196 | * \see AreAllOutgoingInVain |
| 197 | **/ |
| 198 | bool |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 199 | AreTherePromisingOutgoingFacesExcept (Ptr<Face> face) const; |
Alexander Afanasyev | 0a61c34 | 2011-12-06 12:48:55 -0800 | [diff] [blame] | 200 | |
| 201 | /** |
| 202 | * @brief Increase maximum limit of allowed retransmission per outgoing face |
| 203 | */ |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 204 | virtual void |
Alexander Afanasyev | 0a61c34 | 2011-12-06 12:48:55 -0800 | [diff] [blame] | 205 | IncreaseAllowedRetxCount (); |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 206 | |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 207 | /** |
| 208 | * @brief Get maximum allowed number of retransmissions via outgoing faces |
| 209 | */ |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 210 | uint32_t |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 211 | GetMaxRetxCount () const; |
| 212 | |
| 213 | /** |
| 214 | * @brief Get associated FIB entry |
| 215 | */ |
| 216 | Ptr<fib::Entry> |
| 217 | GetFibEntry (); |
| 218 | |
| 219 | /** |
| 220 | * @brief Get associated list (const reference) of incoming faces |
| 221 | */ |
| 222 | const in_container & |
| 223 | GetIncoming () const; |
| 224 | |
| 225 | /** |
| 226 | * @brief Get associated list (const reference) of outgoing faces |
| 227 | */ |
| 228 | const out_container & |
| 229 | GetOutgoing () const; |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 230 | |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame] | 231 | /** |
Alexander Afanasyev | ff03395 | 2012-08-23 15:45:52 -0700 | [diff] [blame] | 232 | * @brief Get number of outgoing faces (needed for python bindings) |
| 233 | */ |
| 234 | uint32_t |
| 235 | GetOutgoingCount () const; |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 236 | |
Alexander Afanasyev | ff03395 | 2012-08-23 15:45:52 -0700 | [diff] [blame] | 237 | /** |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame] | 238 | * @brief Add new forwarding strategy tag |
| 239 | */ |
| 240 | inline void |
| 241 | AddFwTag (boost::shared_ptr< fw::Tag > tag); |
| 242 | |
| 243 | /** |
| 244 | * @brief Get forwarding strategy tag (tag is not removed) |
| 245 | */ |
| 246 | template<class T> |
| 247 | inline boost::shared_ptr< T > |
| 248 | GetFwTag (); |
| 249 | |
| 250 | /** |
| 251 | * @brief Remove the forwarding strategy tag |
| 252 | */ |
| 253 | template<class T> |
| 254 | inline void |
| 255 | RemoveFwTag (); |
| 256 | |
Alexander Afanasyev | 91e1128 | 2012-08-21 17:23:11 -0700 | [diff] [blame] | 257 | /** |
Alexander Afanasyev | eae83ee | 2013-03-15 15:01:10 -0700 | [diff] [blame] | 258 | * @brief Get Interest (if several interests are received, then nonce is from the first Interest) |
Alexander Afanasyev | 91e1128 | 2012-08-21 17:23:11 -0700 | [diff] [blame] | 259 | */ |
Alexander Afanasyev | eae83ee | 2013-03-15 15:01:10 -0700 | [diff] [blame] | 260 | Ptr<const Interest> |
Alexander Afanasyev | 91e1128 | 2012-08-21 17:23:11 -0700 | [diff] [blame] | 261 | GetInterest () const; |
| 262 | |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 263 | private: |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 264 | friend std::ostream& operator<< (std::ostream& os, const Entry &entry); |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 265 | |
Alexander Afanasyev | 36b4577 | 2012-07-10 16:57:42 -0700 | [diff] [blame] | 266 | protected: |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 267 | Pit &m_container; ///< @brief Reference to the container (to rearrange indexes, if necessary) |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 268 | |
Alexander Afanasyev | eae83ee | 2013-03-15 15:01:10 -0700 | [diff] [blame] | 269 | Ptr<const Interest> m_interest; ///< \brief Interest of the PIT entry (if several interests are received, then nonce is from the first Interest) |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 270 | Ptr<fib::Entry> m_fibEntry; ///< \brief FIB entry related to this prefix |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 271 | |
| 272 | nonce_container m_seenNonces; ///< \brief map of nonces that were seen for this prefix |
Alexander Afanasyev | f034cbd | 2012-06-29 14:28:31 -0700 | [diff] [blame] | 273 | in_container m_incoming; ///< \brief container for incoming interests |
| 274 | out_container m_outgoing; ///< \brief container for outgoing interests |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 275 | |
| 276 | Time m_expireTime; ///< \brief Time when PIT entry will be removed |
Alexander Afanasyev | 0a61c34 | 2011-12-06 12:48:55 -0800 | [diff] [blame] | 277 | |
Alexander Afanasyev | 7f3e49e | 2012-04-30 00:17:07 -0700 | [diff] [blame] | 278 | Time m_lastRetransmission; ///< @brief Last time when number of retransmissions were increased |
Alexander Afanasyev | 0a61c34 | 2011-12-06 12:48:55 -0800 | [diff] [blame] | 279 | uint32_t m_maxRetxCount; ///< @brief Maximum allowed number of retransmissions via outgoing faces |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame] | 280 | |
| 281 | std::list< boost::shared_ptr<fw::Tag> > m_fwTags; ///< @brief Forwarding strategy tags |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 282 | }; |
| 283 | |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 284 | /// @cond include_hidden |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 285 | struct EntryIsNotEmpty |
| 286 | { |
| 287 | bool |
| 288 | operator () (Ptr<Entry> entry) |
| 289 | { |
| 290 | return !entry->GetIncoming ().empty (); |
| 291 | } |
| 292 | }; |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 293 | /// @endcond |
Alexander Afanasyev | eec6629 | 2013-02-06 16:23:21 -0800 | [diff] [blame] | 294 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 295 | std::ostream& operator<< (std::ostream& os, const Entry &entry); |
Alexander Afanasyev | a95b739 | 2012-03-09 10:54:10 -0800 | [diff] [blame] | 296 | |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame] | 297 | inline void |
| 298 | Entry::AddFwTag (boost::shared_ptr< fw::Tag > tag) |
| 299 | { |
| 300 | m_fwTags.push_back (tag); |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * @brief Get and remove forwarding strategy tag |
| 305 | */ |
| 306 | template<class T> |
| 307 | inline boost::shared_ptr< T > |
| 308 | Entry::GetFwTag () |
| 309 | { |
| 310 | for (std::list< boost::shared_ptr<fw::Tag> >::iterator item = m_fwTags.begin (); |
| 311 | item != m_fwTags.end (); |
| 312 | item ++) |
| 313 | { |
| 314 | boost::shared_ptr< T > retPtr = boost::dynamic_pointer_cast<T> (*item); |
Alexander Afanasyev | 38ba9b2 | 2012-08-21 13:32:43 -0700 | [diff] [blame] | 315 | if (retPtr != boost::shared_ptr< T > ()) |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame] | 316 | { |
| 317 | return retPtr; |
| 318 | } |
| 319 | } |
| 320 | |
Alexander Afanasyev | 38ba9b2 | 2012-08-21 13:32:43 -0700 | [diff] [blame] | 321 | return boost::shared_ptr< T > (); |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | // /** |
| 325 | // * @brief Peek the forwarding strategy tag |
| 326 | // */ |
| 327 | // template<class T> |
| 328 | // inline boost::shared_ptr< const T > |
| 329 | // Entry::PeekFwTag () const |
| 330 | // { |
| 331 | // for (std::list< boost::shared_ptr<fw::Tag> >::const_iterator item = m_fwTags.begin (); |
| 332 | // item != m_fwTags.end (); |
| 333 | // item ++) |
| 334 | // { |
| 335 | // boost::shared_ptr< const T > retPtr = boost::dynamic_pointer_cast<const T> (*item); |
| 336 | // if (retPtr != 0) |
| 337 | // { |
| 338 | // return retPtr; |
| 339 | // } |
| 340 | // } |
| 341 | |
| 342 | // return 0; |
| 343 | // } |
| 344 | |
| 345 | template<class T> |
| 346 | inline void |
| 347 | Entry::RemoveFwTag () |
| 348 | { |
| 349 | for (std::list< boost::shared_ptr<fw::Tag> >::iterator item = m_fwTags.begin (); |
| 350 | item != m_fwTags.end (); |
| 351 | item ++) |
| 352 | { |
| 353 | boost::shared_ptr< T > retPtr = boost::dynamic_pointer_cast< T > (*item); |
Alexander Afanasyev | 38ba9b2 | 2012-08-21 13:32:43 -0700 | [diff] [blame] | 354 | if (retPtr != boost::shared_ptr< T > ()) |
Alexander Afanasyev | ed449cc | 2012-08-21 11:10:33 -0700 | [diff] [blame] | 355 | { |
| 356 | m_fwTags.erase (item); |
| 357 | return; |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 363 | } // namespace pit |
| 364 | } // namespace ndn |
Alexander Afanasyev | a98cdd2 | 2011-08-29 17:32:37 -0700 | [diff] [blame] | 365 | } // namespace ns3 |
| 366 | |
Alexander Afanasyev | 4aac557 | 2012-08-09 10:49:55 -0700 | [diff] [blame] | 367 | #endif // _NDN_PIT_ENTRY_H_ |