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