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