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 |
| 65 | * |
| 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 |
| 78 | * |
| 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); |
| 104 | |
| 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 | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 127 | |
| 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 |
| 135 | * |
| 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); |
| 150 | |
| 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. |
| 156 | * |
| 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); |
| 165 | |
| 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 |
| 265 | * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest |
| 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 | /** |
| 308 | * @brief Event which is fired every time an unsolicited DATA packet (no active PIT entry) is received |
| 309 | * |
| 310 | * The current implementation allows ignoring unsolicited DATA (by default), or cache it by setting |
| 311 | * attribute CacheUnsolicitedData true |
| 312 | * |
| 313 | * @param inFace incoming face |
| 314 | * @param header deserialized ContentObject header |
| 315 | * @param payload ContentObject payload |
| 316 | * @param origPacket original packet |
| 317 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 318 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 319 | DidReceiveUnsolicitedData (Ptr<Face> inFace, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 320 | Ptr<const ContentObjectHeader> header, |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 321 | Ptr<const Packet> payload, |
| 322 | Ptr<const Packet> origPacket); |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 323 | |
| 324 | /** |
| 325 | * @brief Method implementing logic to suppress (collapse) similar Interests |
| 326 | * |
| 327 | * In the base class implementation this method checks list of incoming/outgoing faces of the PIT entry |
| 328 | * (for new Intersets, both lists are empty before this call) |
| 329 | * |
| 330 | * For more details, refer to the source code. |
| 331 | * |
| 332 | * @param inFace incoming face |
| 333 | * @param header deserialized ContentObject header |
| 334 | * @param payload ContentObject payload |
| 335 | * @param origPacket original packet |
| 336 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 337 | virtual bool |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 338 | ShouldSuppressIncomingInterest (Ptr<Face> inFace, |
| 339 | Ptr<const InterestHeader> header, |
| 340 | Ptr<const Packet> origPacket, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 341 | Ptr<pit::Entry> pitEntry); |
| 342 | |
| 343 | /** |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 344 | * @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] | 345 | * |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 346 | * In the base class, this method perfoms two checks: |
| 347 | * 1. If inFace is equal to outFace (when equal, Interest forwarding is prohibited) |
| 348 | * 2. Whether Interest should be suppressed (list of outgoing faces include outFace), |
| 349 | * considering (if enabled) retransmission logic |
| 350 | * |
| 351 | * @param inFace incoming face of the Interest |
| 352 | * @param outFace proposed outgoing face of the Interest |
| 353 | * @param header parsed Interest header |
| 354 | * @param origPacket original Interest packet |
| 355 | * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside) |
| 356 | * |
| 357 | * @see DetectRetransmittedInterest |
| 358 | */ |
| 359 | virtual bool |
| 360 | CanSendOutInterest (Ptr<Face> inFace, |
| 361 | Ptr<Face> outFace, |
| 362 | Ptr<const InterestHeader> header, |
| 363 | Ptr<const Packet> origPacket, |
| 364 | Ptr<pit::Entry> pitEntry); |
| 365 | |
| 366 | /** |
| 367 | * @brief Method implementing actual interest forwarding, taking into account CanSendOutInterest decision |
| 368 | * |
| 369 | * If event returns false, then there is some kind of a problem exists |
| 370 | * |
| 371 | * @param inFace incoming face of the Interest |
| 372 | * @param outFace proposed outgoing face of the Interest |
| 373 | * @param header parsed Interest header |
| 374 | * @param origPacket original Interest packet |
| 375 | * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside) |
| 376 | * |
| 377 | * @see CanSendOutInterest |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 378 | */ |
| 379 | virtual bool |
Alexander Afanasyev | 5db9217 | 2012-08-21 16:52:07 -0700 | [diff] [blame] | 380 | TrySendOutInterest (Ptr<Face> inFace, |
| 381 | Ptr<Face> outFace, |
| 382 | Ptr<const InterestHeader> header, |
| 383 | Ptr<const Packet> origPacket, |
| 384 | Ptr<pit::Entry> pitEntry); |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 385 | |
| 386 | /** |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 387 | * @brief Event fired just after forwarding the Interest |
| 388 | * |
Alexander Afanasyev | 67f4a4a | 2012-11-24 17:18:17 -0800 | [diff] [blame] | 389 | * @param inFace incoming face of the Interest |
Alexander Afanasyev | db15acb | 2012-11-09 14:16:27 -0800 | [diff] [blame] | 390 | * @param outFace 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) |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 394 | */ |
| 395 | virtual void |
Alexander Afanasyev | 67f4a4a | 2012-11-24 17:18:17 -0800 | [diff] [blame] | 396 | DidSendOutInterest (Ptr<Face> inFace, |
| 397 | Ptr<Face> outFace, |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 398 | Ptr<const InterestHeader> header, |
| 399 | Ptr<const Packet> origPacket, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 400 | Ptr<pit::Entry> pitEntry); |
| 401 | |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 402 | /** |
| 403 | * @brief Wrapper method, which performs general tasks and calls DoPropagateInterest method |
| 404 | * |
| 405 | * General tasks so far are adding face to the list of incoming face, updating |
| 406 | * PIT entry lifetime, calling DoPropagateInterest, and retransmissions (enabled by default). |
| 407 | * |
| 408 | * @param inFace incoming face |
| 409 | * @param header Interest header |
| 410 | * @param origPacket original Interest packet |
| 411 | * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside) |
| 412 | * |
| 413 | * @see DoPropagateInterest |
| 414 | */ |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 415 | virtual void |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 416 | PropagateInterest (Ptr<Face> inFace, |
| 417 | Ptr<const InterestHeader> header, |
| 418 | Ptr<const Packet> origPacket, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 419 | Ptr<pit::Entry> pitEntry); |
| 420 | |
| 421 | /** |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 422 | * @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] | 423 | * |
Alexander Afanasyev | 6466fff | 2012-10-24 22:51:57 -0700 | [diff] [blame] | 424 | * In most cases, this is the call that needs to be implemented/re-implemented in order |
| 425 | * to perform forwarding of Interests according to the desired logic. |
| 426 | * |
| 427 | * There is also PropagateInterest method (generally, do not require to be overriden) |
| 428 | * which performs general tasks (adding face to the list of incoming face, updating |
| 429 | * PIT entry lifetime, calling DoPropagateInterest, as well as perform retransmissions (enabled by default). |
| 430 | * |
| 431 | * @param inFace incoming face |
| 432 | * @param header Interest header |
| 433 | * @param origPacket original Interest packet |
| 434 | * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside) |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 435 | * |
| 436 | * @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] | 437 | * |
| 438 | * @see PropagateInterest |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 439 | */ |
| 440 | virtual bool |
Alexander Afanasyev | 31cb469 | 2012-08-17 13:08:20 -0700 | [diff] [blame] | 441 | DoPropagateInterest (Ptr<Face> inFace, |
| 442 | Ptr<const InterestHeader> header, |
| 443 | Ptr<const Packet> origPacket, |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 444 | Ptr<pit::Entry> pitEntry) = 0; |
| 445 | |
| 446 | protected: |
| 447 | // inherited from Object class |
| 448 | virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object |
| 449 | virtual void DoDispose (); ///< @brief Do cleanup |
| 450 | |
| 451 | protected: |
| 452 | Ptr<Pit> m_pit; ///< \brief Reference to PIT to which this forwarding strategy is associated |
| 453 | Ptr<Fib> m_fib; ///< \brief FIB |
| 454 | Ptr<ContentStore> m_contentStore; ///< \brief Content store (for caching purposes only) |
| 455 | |
| 456 | bool m_cacheUnsolicitedData; |
| 457 | bool m_detectRetransmissions; |
| 458 | |
| 459 | TracedCallback<Ptr<const InterestHeader>, |
| 460 | Ptr<const Face> > m_outInterests; ///< @brief Transmitted interests trace |
| 461 | |
| 462 | TracedCallback<Ptr<const InterestHeader>, |
| 463 | Ptr<const Face> > m_inInterests; ///< @brief trace of incoming Interests |
| 464 | |
| 465 | TracedCallback<Ptr<const InterestHeader>, |
| 466 | Ptr<const Face> > m_dropInterests; ///< @brief trace of dropped Interests |
| 467 | |
| 468 | //////////////////////////////////////////////////////////////////// |
| 469 | //////////////////////////////////////////////////////////////////// |
| 470 | //////////////////////////////////////////////////////////////////// |
| 471 | |
| 472 | TracedCallback<Ptr<const ContentObjectHeader>, Ptr<const Packet>, |
| 473 | bool /*from cache*/, |
| 474 | Ptr<const Face> > m_outData; ///< @brief trace of outgoing Data |
| 475 | |
| 476 | TracedCallback<Ptr<const ContentObjectHeader>, Ptr<const Packet>, |
| 477 | Ptr<const Face> > m_inData; ///< @brief trace of incoming Data |
| 478 | |
| 479 | TracedCallback<Ptr<const ContentObjectHeader>, Ptr<const Packet>, |
| 480 | Ptr<const Face> > m_dropData; ///< @brief trace of dropped Data |
| 481 | }; |
| 482 | |
| 483 | } // namespace ndn |
| 484 | } // namespace ns3 |
| 485 | |
| 486 | #endif /* NDN_FORWARDING_STRATEGY_H */ |