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