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