Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -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> |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 19 | */ |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 20 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 21 | #ifndef NDN_FORWARDING_STRATEGY_H |
| 22 | #define NDN_FORWARDING_STRATEGY_H |
| 23 | |
| 24 | #include "ns3/packet.h" |
| 25 | #include "ns3/callback.h" |
| 26 | #include "ns3/object.h" |
| 27 | #include "ns3/traced-callback.h" |
| 28 | |
| 29 | namespace ns3 { |
| 30 | namespace ndn { |
| 31 | |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 32 | /** |
| 33 | * @ingroup ndn |
| 34 | * @defgroup ndn-fw NDN forwarding strategies |
| 35 | */ |
| 36 | |
| 37 | |
| 38 | /** |
| 39 | * @ingroup ndn-fw |
| 40 | * @brief Namespace for Forwarding Strategy operations |
| 41 | */ |
| 42 | namespace fw { |
| 43 | } |
| 44 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 45 | class Face; |
Alexander Afanasyev | 73f06f6 | 2013-03-15 15:41:38 -0700 | [diff] [blame] | 46 | |
Alexander Afanasyev | eae83ee | 2013-03-15 15:01:10 -0700 | [diff] [blame] | 47 | class Interest; |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 48 | class Data; |
Alexander Afanasyev | 73f06f6 | 2013-03-15 15:41:38 -0700 | [diff] [blame] | 49 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 50 | class Pit; |
| 51 | namespace pit { class Entry; } |
| 52 | class FibFaceMetric; |
| 53 | class Fib; |
Alexander Afanasyev | adcccf4 | 2012-11-26 23:55:34 -0800 | [diff] [blame] | 54 | namespace fib { class Entry; } |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 55 | class ContentStore; |
| 56 | |
| 57 | /** |
Alexander Afanasyev | 7920651 | 2013-07-27 16:49:12 -0700 | [diff] [blame] | 58 | * @ingroup ndn-fw |
| 59 | * @brief Abstract base class for Ndn forwarding strategies |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 60 | */ |
| 61 | class ForwardingStrategy : |
| 62 | public Object |
| 63 | { |
| 64 | public: |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 65 | static TypeId GetTypeId (); |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
Alexander Afanasyev | 042b4a7 | 2012-11-09 17:47:48 -0800 | [diff] [blame] | 68 | * @brief Helper function to retrieve logging name for the forwarding strategy |
| 69 | */ |
| 70 | static std::string GetLogName (); |
| 71 | |
| 72 | /** |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 73 | * @brief Default constructor |
| 74 | */ |
| 75 | ForwardingStrategy (); |
| 76 | virtual ~ForwardingStrategy (); |
| 77 | |
| 78 | /** |
| 79 | * \brief Actual processing of incoming Ndn interests. Note, interests do not have payload |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 80 | * |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 81 | * Processing Interest packets |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 82 | * @param face incoming face |
| 83 | * @param interest Interest packet |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 84 | */ |
| 85 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 86 | OnInterest (Ptr<Face> face, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 87 | Ptr<Interest> interest); |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 88 | |
| 89 | /** |
| 90 | * \brief Actual processing of incoming Ndn content objects |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 91 | * |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 92 | * Processing Data packets |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 93 | * @param face incoming face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 94 | * @param data Data packet |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 95 | */ |
| 96 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 97 | OnData (Ptr<Face> face, |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 98 | Ptr<Data> data); |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 99 | |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 100 | /** |
| 101 | * @brief Event fired just before PIT entry is removed by timeout |
| 102 | * @param pitEntry PIT entry to be removed |
| 103 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 104 | virtual void |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 105 | WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 106 | |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 107 | /** |
Alexander Afanasyev | f5c0774 | 2012-10-31 13:13:05 -0700 | [diff] [blame] | 108 | * @brief Event fired every time face is added to NDN stack |
| 109 | * @param face face to be removed |
| 110 | */ |
| 111 | virtual void |
| 112 | AddFace (Ptr<Face> face); |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 113 | |
Alexander Afanasyev | f5c0774 | 2012-10-31 13:13:05 -0700 | [diff] [blame] | 114 | /** |
Alexander Afanasyev | ea9b3e6 | 2012-08-13 19:02:54 -0700 | [diff] [blame] | 115 | * @brief Event fired every time face is removed from NDN stack |
| 116 | * @param face face to be removed |
| 117 | * |
| 118 | * For example, when an application terminates, AppFace is removed and this method called by NDN stack. |
| 119 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 120 | virtual void |
| 121 | RemoveFace (Ptr<Face> face); |
Alexander Afanasyev | adcccf4 | 2012-11-26 23:55:34 -0800 | [diff] [blame] | 122 | |
| 123 | /** |
| 124 | * @brief Event fired every time a FIB entry is added to FIB |
| 125 | * @param fibEntry FIB entry that was added |
| 126 | */ |
| 127 | virtual void |
| 128 | DidAddFibEntry (Ptr<fib::Entry> fibEntry); |
| 129 | |
| 130 | /** |
| 131 | * @brief Fired just before FIB entry will be removed from FIB |
| 132 | * @param fibEntry FIB entry that will be removed |
| 133 | */ |
| 134 | virtual void |
| 135 | WillRemoveFibEntry (Ptr<fib::Entry> fibEntry); |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 136 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 137 | protected: |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 138 | /** |
| 139 | * @brief An event that is fired every time a new PIT entry is created |
| 140 | * |
| 141 | * Note that if NDN node is receiving a similar interest (interest for the same name), |
| 142 | * then either DidReceiveDuplicateInterest, DidSuppressSimilarInterest, or DidForwardSimilarInterest |
| 143 | * will be called |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 144 | * |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 145 | * Suppression of similar Interests is controlled using ShouldSuppressIncomingInterest virtual method |
| 146 | * |
| 147 | * @param inFace incoming face |
| 148 | * @param header deserialized Interest header |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 149 | * @param pitEntry created PIT entry (incoming and outgoing face sets are empty) |
| 150 | * |
| 151 | * @see DidReceiveDuplicateInterest, DidSuppressSimilarInterest, DidForwardSimilarInterest, ShouldSuppressIncomingInterest |
| 152 | */ |
| 153 | virtual void |
| 154 | DidCreatePitEntry (Ptr<Face> inFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 155 | Ptr<const Interest> interest, |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 156 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 157 | |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 158 | /** |
| 159 | * @brief An event that is fired every time a new PIT entry cannot be created (e.g., PIT container imposes a limit) |
| 160 | * |
| 161 | * Note that this call can be called only for non-similar Interest (i.e., there is an attempt to create a new PIT entry). |
| 162 | * For any non-similar Interests, either FailedToCreatePitEntry or DidCreatePitEntry is called. |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 163 | * |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 164 | * @param inFace incoming face |
| 165 | * @param interest Interest packet |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 166 | */ |
| 167 | virtual void |
| 168 | FailedToCreatePitEntry (Ptr<Face> inFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 169 | Ptr<const Interest> interest); |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 170 | |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 171 | /** |
| 172 | * @brief An event that is fired every time a duplicated Interest is received |
| 173 | * |
| 174 | * This even is the last action that is performed before the Interest processing is halted |
| 175 | * |
| 176 | * @param inFace incoming face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 177 | * @param interest Interest packet |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 178 | * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest |
| 179 | * |
| 180 | * @see DidReceiveDuplicateInterest, DidSuppressSimilarInterest, DidForwardSimilarInterest, ShouldSuppressIncomingInterest |
| 181 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 182 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 183 | DidReceiveDuplicateInterest (Ptr<Face> inFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 184 | Ptr<const Interest> interest, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 185 | Ptr<pit::Entry> pitEntry); |
| 186 | |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 187 | /** |
| 188 | * @brief An event that is fired every time when a similar Interest is received and suppressed (collapsed) |
| 189 | * |
| 190 | * This even is the last action that is performed before the Interest processing is halted |
| 191 | * |
| 192 | * @param inFace incoming face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 193 | * @param interest Interest packet |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 194 | * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest |
| 195 | * |
| 196 | * @see DidReceiveDuplicateInterest, DidForwardSimilarInterest, ShouldSuppressIncomingInterest |
| 197 | */ |
| 198 | virtual void |
| 199 | DidSuppressSimilarInterest (Ptr<Face> inFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 200 | Ptr<const Interest> interest, |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 201 | Ptr<pit::Entry> pitEntry); |
| 202 | |
| 203 | /** |
| 204 | * @brief An event that is fired every time when a similar Interest is received and further forwarded (not suppressed/collapsed) |
| 205 | * |
| 206 | * This even is fired just before handling the Interest to PropagateInterest method |
| 207 | * |
| 208 | * @param inFace incoming face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 209 | * @param interest Interest packet |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 210 | * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest |
| 211 | * |
| 212 | * @see DidReceiveDuplicateInterest, DidSuppressSimilarInterest, ShouldSuppressIncomingInterest |
| 213 | */ |
| 214 | virtual void |
| 215 | DidForwardSimilarInterest (Ptr<Face> inFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 216 | Ptr<const Interest> interest, |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 217 | Ptr<pit::Entry> pitEntry); |
| 218 | |
| 219 | /** |
| 220 | * @brief An even that is fired when Interest cannot be forwarded |
| 221 | * |
| 222 | * Note that the event will not fire if retransmission detection is enabled (by default) |
| 223 | * and retransmitted Interest cannot by forwarded. For more details, refer to the implementation. |
| 224 | * |
| 225 | * @param inFace incoming face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 226 | * @param interest Interest header |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 227 | * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest |
| 228 | * |
| 229 | * @see DetectRetransmittedInterest |
| 230 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 231 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 232 | DidExhaustForwardingOptions (Ptr<Face> inFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 233 | Ptr<const Interest> interest, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 234 | Ptr<pit::Entry> pitEntry); |
| 235 | |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 236 | /** |
| 237 | * @brief Method that implements logic to distinguish between new and retransmitted interest |
| 238 | * |
| 239 | * This method is called only when DetectRetransmissions attribute is set true (by default). |
| 240 | * |
| 241 | * Currently, the retransmission detection logic relies on the fact that list of incoming faces |
| 242 | * already has inFace (i.e., a similar interest is received on the same face more than once). |
| 243 | * |
| 244 | * @param inFace incoming face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 245 | * @param interest Interest header |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 246 | * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest |
| 247 | * @return true if Interest should be considered as retransmitted |
| 248 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 249 | virtual bool |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 250 | DetectRetransmittedInterest (Ptr<Face> inFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 251 | Ptr<const Interest> interest, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 252 | Ptr<pit::Entry> pitEntry); |
| 253 | |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 254 | /** |
| 255 | * @brief Even fired just before Interest will be satisfied |
| 256 | * |
| 257 | * Note that when Interest is satisfied from the cache, incoming face will be 0 |
| 258 | * |
| 259 | * @param inFace incoming face |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 260 | * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 261 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 262 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 263 | WillSatisfyPendingInterest (Ptr<Face> inFace, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 264 | Ptr<pit::Entry> pitEntry); |
| 265 | |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 266 | /** |
| 267 | * @brief Actual procedure to satisfy Interest |
| 268 | * |
| 269 | * Note that when Interest is satisfied from the cache, incoming face will be 0 |
| 270 | * |
| 271 | * @param inFace incoming face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 272 | * @param data Data packet |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 273 | * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest |
| 274 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 275 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 276 | SatisfyPendingInterest (Ptr<Face> inFace, // 0 allowed (from cache) |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 277 | Ptr<const Data> data, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 278 | Ptr<pit::Entry> pitEntry); |
| 279 | |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 280 | /** |
| 281 | * @brief Event which is fired just after data was send out on the face |
| 282 | * |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 283 | * @param inFace incoming face of the Data |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 284 | * @param outFace outgoing face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 285 | * @param data Data packet |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 286 | * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest |
| 287 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 288 | virtual void |
Alexander Afanasyev | 67f4a4a | 2012-11-24 17:18:17 -0800 | [diff] [blame] | 289 | DidSendOutData (Ptr<Face> inFace, |
| 290 | Ptr<Face> outFace, |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 291 | Ptr<const Data> data, |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 292 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 293 | |
| 294 | /** |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 295 | * @brief Event which is fired every time a requested (solicited) DATA packet (there is an active PIT entry) is received |
| 296 | * |
| 297 | * @param inFace incoming face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 298 | * @param data Data packet |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 299 | * @param didCreateCacheEntry flag indicating whether a cache entry was added for this data packet or not (e.g., packet already exists in cache) |
| 300 | */ |
| 301 | virtual void |
| 302 | DidReceiveSolicitedData (Ptr<Face> inFace, |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 303 | Ptr<const Data> data, |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 304 | bool didCreateCacheEntry); |
| 305 | |
| 306 | /** |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 307 | * @brief Event which is fired every time an unsolicited DATA packet (no active PIT entry) is received |
| 308 | * |
| 309 | * The current implementation allows ignoring unsolicited DATA (by default), or cache it by setting |
| 310 | * attribute CacheUnsolicitedData true |
| 311 | * |
| 312 | * @param inFace incoming face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 313 | * @param data Data packet |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 314 | * @param didCreateCacheEntry flag indicating whether a cache entry was added for this data packet or not (e.g., packet already exists in cache) |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 315 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 316 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 317 | DidReceiveUnsolicitedData (Ptr<Face> inFace, |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 318 | Ptr<const Data> data, |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 319 | bool didCreateCacheEntry); |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 320 | |
| 321 | /** |
| 322 | * @brief Method implementing logic to suppress (collapse) similar Interests |
| 323 | * |
| 324 | * In the base class implementation this method checks list of incoming/outgoing faces of the PIT entry |
| 325 | * (for new Intersets, both lists are empty before this call) |
| 326 | * |
| 327 | * For more details, refer to the source code. |
| 328 | * |
| 329 | * @param inFace incoming face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 330 | * @param interest Interest packet |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 331 | * @param payload Data payload |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 332 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 333 | virtual bool |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 334 | ShouldSuppressIncomingInterest (Ptr<Face> inFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 335 | Ptr<const Interest> interest, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 336 | Ptr<pit::Entry> pitEntry); |
| 337 | |
| 338 | /** |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 339 | * @brief Method to check whether Interest can be send out on the particular face or not |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 340 | * |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 341 | * In the base class, this method perfoms two checks: |
| 342 | * 1. If inFace is equal to outFace (when equal, Interest forwarding is prohibited) |
| 343 | * 2. Whether Interest should be suppressed (list of outgoing faces include outFace), |
| 344 | * considering (if enabled) retransmission logic |
| 345 | * |
| 346 | * @param inFace incoming face of the Interest |
| 347 | * @param outFace proposed outgoing face of the Interest |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 348 | * @param interest Interest packet |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 349 | * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside) |
| 350 | * |
| 351 | * @see DetectRetransmittedInterest |
| 352 | */ |
| 353 | virtual bool |
| 354 | CanSendOutInterest (Ptr<Face> inFace, |
| 355 | Ptr<Face> outFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 356 | Ptr<const Interest> interest, |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 357 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 358 | |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 359 | /** |
| 360 | * @brief Method implementing actual interest forwarding, taking into account CanSendOutInterest decision |
| 361 | * |
| 362 | * If event returns false, then there is some kind of a problem exists |
| 363 | * |
| 364 | * @param inFace incoming face of the Interest |
| 365 | * @param outFace proposed outgoing face of the Interest |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 366 | * @param interest Interest packet |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 367 | * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside) |
| 368 | * |
| 369 | * @see CanSendOutInterest |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 370 | */ |
| 371 | virtual bool |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 372 | TrySendOutInterest (Ptr<Face> inFace, |
| 373 | Ptr<Face> outFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 374 | Ptr<const Interest> interest, |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 375 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 376 | |
| 377 | /** |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 378 | * @brief Event fired just after forwarding the Interest |
| 379 | * |
Alexander Afanasyev | 67f4a4a | 2012-11-24 17:18:17 -0800 | [diff] [blame] | 380 | * @param inFace incoming face of the Interest |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 381 | * @param outFace outgoing face of the Interest |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 382 | * @param interest Interest packet |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 383 | * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside) |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 384 | */ |
| 385 | virtual void |
Alexander Afanasyev | 67f4a4a | 2012-11-24 17:18:17 -0800 | [diff] [blame] | 386 | DidSendOutInterest (Ptr<Face> inFace, |
| 387 | Ptr<Face> outFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 388 | Ptr<const Interest> interest, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 389 | Ptr<pit::Entry> pitEntry); |
| 390 | |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 391 | /** |
| 392 | * @brief Wrapper method, which performs general tasks and calls DoPropagateInterest method |
| 393 | * |
| 394 | * General tasks so far are adding face to the list of incoming face, updating |
| 395 | * PIT entry lifetime, calling DoPropagateInterest, and retransmissions (enabled by default). |
| 396 | * |
| 397 | * @param inFace incoming face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 398 | * @param interest Interest packet |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 399 | * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside) |
| 400 | * |
| 401 | * @see DoPropagateInterest |
| 402 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 403 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 404 | PropagateInterest (Ptr<Face> inFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 405 | Ptr<const Interest> interest, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 406 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 407 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 408 | /** |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 409 | * @brief Virtual method to perform Interest propagation according to the forwarding strategy logic |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 410 | * |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 411 | * In most cases, this is the call that needs to be implemented/re-implemented in order |
| 412 | * to perform forwarding of Interests according to the desired logic. |
| 413 | * |
| 414 | * There is also PropagateInterest method (generally, do not require to be overriden) |
| 415 | * which performs general tasks (adding face to the list of incoming face, updating |
| 416 | * PIT entry lifetime, calling DoPropagateInterest, as well as perform retransmissions (enabled by default). |
| 417 | * |
| 418 | * @param inFace incoming face |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 419 | * @param interest Interest packet |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 420 | * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside) |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 421 | * |
| 422 | * @return true if interest was successfully propagated, false if all options have failed |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 423 | * |
| 424 | * @see PropagateInterest |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 425 | */ |
| 426 | virtual bool |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 427 | DoPropagateInterest (Ptr<Face> inFace, |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 428 | Ptr<const Interest> interest, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 429 | Ptr<pit::Entry> pitEntry) = 0; |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 430 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 431 | protected: |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 432 | // inherited from Object class |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 433 | virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object |
| 434 | virtual void DoDispose (); ///< @brief Do cleanup |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 435 | |
| 436 | protected: |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 437 | Ptr<Pit> m_pit; ///< \brief Reference to PIT to which this forwarding strategy is associated |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 438 | Ptr<Fib> m_fib; ///< \brief FIB |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 439 | Ptr<ContentStore> m_contentStore; ///< \brief Content store (for caching purposes only) |
| 440 | |
Alexander Afanasyev | dd9fa4f | 2013-05-15 16:35:04 -0700 | [diff] [blame] | 441 | bool m_cacheUnsolicitedDataFromApps; |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 442 | bool m_cacheUnsolicitedData; |
| 443 | bool m_detectRetransmissions; |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 444 | |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 445 | TracedCallback<Ptr<const Interest>, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 446 | Ptr<const Face> > m_outInterests; ///< @brief Transmitted interests trace |
| 447 | |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 448 | TracedCallback<Ptr<const Interest>, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 449 | Ptr<const Face> > m_inInterests; ///< @brief trace of incoming Interests |
| 450 | |
Alexander Afanasyev | b989b12 | 2013-07-10 17:15:46 -0700 | [diff] [blame] | 451 | TracedCallback<Ptr<const Interest>, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 452 | Ptr<const Face> > m_dropInterests; ///< @brief trace of dropped Interests |
Alexander Afanasyev | e6c07b5 | 2013-02-12 11:05:14 -0800 | [diff] [blame] | 453 | |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 454 | //////////////////////////////////////////////////////////////////// |
| 455 | //////////////////////////////////////////////////////////////////// |
| 456 | //////////////////////////////////////////////////////////////////// |
| 457 | |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 458 | TracedCallback<Ptr<const Data>, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 459 | bool /*from cache*/, |
| 460 | Ptr<const Face> > m_outData; ///< @brief trace of outgoing Data |
| 461 | |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 462 | TracedCallback<Ptr<const Data>, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 463 | Ptr<const Face> > m_inData; ///< @brief trace of incoming Data |
| 464 | |
Alexander Afanasyev | 772f51b | 2013-08-01 18:53:25 -0700 | [diff] [blame] | 465 | TracedCallback<Ptr<const Data>, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 466 | Ptr<const Face> > m_dropData; ///< @brief trace of dropped Data |
Alexander Afanasyev | 37b84c5 | 2013-04-26 13:38:52 -0700 | [diff] [blame] | 467 | |
| 468 | //////////////////////////////////////////////////////////////////// |
| 469 | //////////////////////////////////////////////////////////////////// |
| 470 | //////////////////////////////////////////////////////////////////// |
| 471 | |
| 472 | TracedCallback< Ptr<const pit::Entry> > m_satisfiedInterests; |
| 473 | TracedCallback< Ptr<const pit::Entry> > m_timedOutInterests; |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 474 | }; |
| 475 | |
| 476 | } // namespace ndn |
| 477 | } // namespace ns3 |
| 478 | |
| 479 | #endif /* NDN_FORWARDING_STRATEGY_H */ |