blob: 05078d6b3b445acd3d1da970db7ba7d00dcadbde [file] [log] [blame]
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -07001/* -*- 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 Afanasyev2b4c9472012-08-09 15:00:38 -070019 */
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070020
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070021#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
29namespace ns3 {
30namespace ndn {
31
Alexander Afanasyev79206512013-07-27 16:49:12 -070032/**
33 * @ingroup ndn
34 * @defgroup ndn-fw NDN forwarding strategies
35 */
36
37
38/**
39 * @ingroup ndn-fw
40 * @brief Namespace for Forwarding Strategy operations
41 */
42namespace fw {
43}
44
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070045class Face;
Alexander Afanasyev73f06f62013-03-15 15:41:38 -070046
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -070047class Interest;
Alexander Afanasyev772f51b2013-08-01 18:53:25 -070048class Data;
Alexander Afanasyev73f06f62013-03-15 15:41:38 -070049
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070050class Pit;
51namespace pit { class Entry; }
52class FibFaceMetric;
53class Fib;
Alexander Afanasyevadcccf42012-11-26 23:55:34 -080054namespace fib { class Entry; }
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070055class ContentStore;
56
57/**
Alexander Afanasyev79206512013-07-27 16:49:12 -070058 * @ingroup ndn-fw
59 * @brief Abstract base class for Ndn forwarding strategies
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070060 */
61class ForwardingStrategy :
62 public Object
63{
64public:
Alexander Afanasyevb989b122013-07-10 17:15:46 -070065 static TypeId GetTypeId ();
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070066
67 /**
Alexander Afanasyev042b4a72012-11-09 17:47:48 -080068 * @brief Helper function to retrieve logging name for the forwarding strategy
69 */
70 static std::string GetLogName ();
71
72 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070073 * @brief Default constructor
74 */
75 ForwardingStrategy ();
76 virtual ~ForwardingStrategy ();
77
78 /**
79 * \brief Actual processing of incoming Ndn interests. Note, interests do not have payload
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -080080 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070081 * Processing Interest packets
Alexander Afanasyevb989b122013-07-10 17:15:46 -070082 * @param face incoming face
83 * @param interest Interest packet
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070084 */
85 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070086 OnInterest (Ptr<Face> face,
Alexander Afanasyevb989b122013-07-10 17:15:46 -070087 Ptr<Interest> interest);
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070088
89 /**
90 * \brief Actual processing of incoming Ndn content objects
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -080091 *
Alexander Afanasyev772f51b2013-08-01 18:53:25 -070092 * Processing Data packets
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070093 * @param face incoming face
Alexander Afanasyevb989b122013-07-10 17:15:46 -070094 * @param data Data packet
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070095 */
96 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070097 OnData (Ptr<Face> face,
Alexander Afanasyev772f51b2013-08-01 18:53:25 -070098 Ptr<Data> data);
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070099
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700100 /**
101 * @brief Event fired just before PIT entry is removed by timeout
102 * @param pitEntry PIT entry to be removed
103 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700104 virtual void
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700105 WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700106
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700107 /**
Alexander Afanasyevf5c07742012-10-31 13:13:05 -0700108 * @brief Event fired every time face is added to NDN stack
109 * @param face face to be removed
110 */
111 virtual void
112 AddFace (Ptr<Face> face);
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800113
Alexander Afanasyevf5c07742012-10-31 13:13:05 -0700114 /**
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700115 * @brief Event fired every time face is removed from NDN stack
116 * @param face face to be removed
117 *
118 * For example, when an application terminates, AppFace is removed and this method called by NDN stack.
119 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700120 virtual void
121 RemoveFace (Ptr<Face> face);
Alexander Afanasyevadcccf42012-11-26 23:55:34 -0800122
123 /**
124 * @brief Event fired every time a FIB entry is added to FIB
125 * @param fibEntry FIB entry that was added
126 */
127 virtual void
128 DidAddFibEntry (Ptr<fib::Entry> fibEntry);
129
130 /**
131 * @brief Fired just before FIB entry will be removed from FIB
132 * @param fibEntry FIB entry that will be removed
133 */
134 virtual void
135 WillRemoveFibEntry (Ptr<fib::Entry> fibEntry);
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800136
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700137protected:
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700138 /**
139 * @brief An event that is fired every time a new PIT entry is created
140 *
141 * Note that if NDN node is receiving a similar interest (interest for the same name),
142 * then either DidReceiveDuplicateInterest, DidSuppressSimilarInterest, or DidForwardSimilarInterest
143 * will be called
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800144 *
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700145 * Suppression of similar Interests is controlled using ShouldSuppressIncomingInterest virtual method
146 *
147 * @param inFace incoming face
148 * @param header deserialized Interest header
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700149 * @param pitEntry created PIT entry (incoming and outgoing face sets are empty)
150 *
151 * @see DidReceiveDuplicateInterest, DidSuppressSimilarInterest, DidForwardSimilarInterest, ShouldSuppressIncomingInterest
152 */
153 virtual void
154 DidCreatePitEntry (Ptr<Face> inFace,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700155 Ptr<const Interest> interest,
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700156 Ptr<pit::Entry> pitEntry);
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800157
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700158 /**
159 * @brief An event that is fired every time a new PIT entry cannot be created (e.g., PIT container imposes a limit)
160 *
161 * Note that this call can be called only for non-similar Interest (i.e., there is an attempt to create a new PIT entry).
162 * For any non-similar Interests, either FailedToCreatePitEntry or DidCreatePitEntry is called.
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800163 *
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700164 * @param inFace incoming face
165 * @param interest Interest packet
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700166 */
167 virtual void
168 FailedToCreatePitEntry (Ptr<Face> inFace,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700169 Ptr<const Interest> interest);
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800170
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700171 /**
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
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700177 * @param interest Interest packet
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700178 * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
179 *
180 * @see DidReceiveDuplicateInterest, DidSuppressSimilarInterest, DidForwardSimilarInterest, ShouldSuppressIncomingInterest
181 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700182 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700183 DidReceiveDuplicateInterest (Ptr<Face> inFace,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700184 Ptr<const Interest> interest,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700185 Ptr<pit::Entry> pitEntry);
186
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700187 /**
188 * @brief An event that is fired every time when a similar Interest is received and suppressed (collapsed)
189 *
190 * This even is the last action that is performed before the Interest processing is halted
191 *
192 * @param inFace incoming face
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700193 * @param interest Interest packet
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700194 * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
195 *
196 * @see DidReceiveDuplicateInterest, DidForwardSimilarInterest, ShouldSuppressIncomingInterest
197 */
198 virtual void
199 DidSuppressSimilarInterest (Ptr<Face> inFace,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700200 Ptr<const Interest> interest,
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700201 Ptr<pit::Entry> pitEntry);
202
203 /**
204 * @brief An event that is fired every time when a similar Interest is received and further forwarded (not suppressed/collapsed)
205 *
206 * This even is fired just before handling the Interest to PropagateInterest method
207 *
208 * @param inFace incoming face
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700209 * @param interest Interest packet
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700210 * @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,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700216 Ptr<const Interest> interest,
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700217 Ptr<pit::Entry> pitEntry);
218
219 /**
220 * @brief An even that is fired when Interest cannot be forwarded
221 *
222 * Note that the event will not fire if retransmission detection is enabled (by default)
223 * and retransmitted Interest cannot by forwarded. For more details, refer to the implementation.
224 *
225 * @param inFace incoming face
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700226 * @param interest Interest header
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700227 * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
228 *
229 * @see DetectRetransmittedInterest
230 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700231 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700232 DidExhaustForwardingOptions (Ptr<Face> inFace,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700233 Ptr<const Interest> interest,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700234 Ptr<pit::Entry> pitEntry);
235
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800236 /**
237 * @brief Method that implements logic to distinguish between new and retransmitted interest
238 *
239 * This method is called only when DetectRetransmissions attribute is set true (by default).
240 *
241 * Currently, the retransmission detection logic relies on the fact that list of incoming faces
242 * already has inFace (i.e., a similar interest is received on the same face more than once).
243 *
244 * @param inFace incoming face
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700245 * @param interest Interest header
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800246 * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
247 * @return true if Interest should be considered as retransmitted
248 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700249 virtual bool
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700250 DetectRetransmittedInterest (Ptr<Face> inFace,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700251 Ptr<const Interest> interest,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700252 Ptr<pit::Entry> pitEntry);
253
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800254 /**
255 * @brief Even fired just before Interest will be satisfied
256 *
257 * Note that when Interest is satisfied from the cache, incoming face will be 0
258 *
259 * @param inFace incoming face
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800260 * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800261 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700262 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700263 WillSatisfyPendingInterest (Ptr<Face> inFace,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700264 Ptr<pit::Entry> pitEntry);
265
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800266 /**
267 * @brief Actual procedure to satisfy Interest
268 *
269 * Note that when Interest is satisfied from the cache, incoming face will be 0
270 *
271 * @param inFace incoming face
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700272 * @param data Data packet
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800273 * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
274 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700275 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700276 SatisfyPendingInterest (Ptr<Face> inFace, // 0 allowed (from cache)
Alexander Afanasyev772f51b2013-08-01 18:53:25 -0700277 Ptr<const Data> data,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700278 Ptr<pit::Entry> pitEntry);
279
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800280 /**
281 * @brief Event which is fired just after data was send out on the face
282 *
Alexander Afanasyev772f51b2013-08-01 18:53:25 -0700283 * @param inFace incoming face of the Data
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800284 * @param outFace outgoing face
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700285 * @param data Data packet
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800286 * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
287 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700288 virtual void
Alexander Afanasyev67f4a4a2012-11-24 17:18:17 -0800289 DidSendOutData (Ptr<Face> inFace,
290 Ptr<Face> outFace,
Alexander Afanasyev772f51b2013-08-01 18:53:25 -0700291 Ptr<const Data> data,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700292 Ptr<pit::Entry> pitEntry);
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800293
294 /**
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800295 * @brief Event which is fired every time a requested (solicited) DATA packet (there is an active PIT entry) is received
296 *
297 * @param inFace incoming face
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700298 * @param data Data packet
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800299 * @param didCreateCacheEntry flag indicating whether a cache entry was added for this data packet or not (e.g., packet already exists in cache)
300 */
301 virtual void
302 DidReceiveSolicitedData (Ptr<Face> inFace,
Alexander Afanasyev772f51b2013-08-01 18:53:25 -0700303 Ptr<const Data> data,
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800304 bool didCreateCacheEntry);
305
306 /**
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800307 * @brief Event which is fired every time an unsolicited DATA packet (no active PIT entry) is received
308 *
309 * The current implementation allows ignoring unsolicited DATA (by default), or cache it by setting
310 * attribute CacheUnsolicitedData true
311 *
312 * @param inFace incoming face
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700313 * @param data Data packet
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800314 * @param didCreateCacheEntry flag indicating whether a cache entry was added for this data packet or not (e.g., packet already exists in cache)
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800315 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700316 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700317 DidReceiveUnsolicitedData (Ptr<Face> inFace,
Alexander Afanasyev772f51b2013-08-01 18:53:25 -0700318 Ptr<const Data> data,
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800319 bool didCreateCacheEntry);
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800320
321 /**
322 * @brief Method implementing logic to suppress (collapse) similar Interests
323 *
324 * In the base class implementation this method checks list of incoming/outgoing faces of the PIT entry
325 * (for new Intersets, both lists are empty before this call)
326 *
327 * For more details, refer to the source code.
328 *
329 * @param inFace incoming face
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700330 * @param interest Interest packet
Alexander Afanasyev772f51b2013-08-01 18:53:25 -0700331 * @param payload Data payload
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800332 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700333 virtual bool
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700334 ShouldSuppressIncomingInterest (Ptr<Face> inFace,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700335 Ptr<const Interest> interest,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700336 Ptr<pit::Entry> pitEntry);
337
338 /**
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800339 * @brief Method to check whether Interest can be send out on the particular face or not
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700340 *
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800341 * In the base class, this method perfoms two checks:
342 * 1. If inFace is equal to outFace (when equal, Interest forwarding is prohibited)
343 * 2. Whether Interest should be suppressed (list of outgoing faces include outFace),
344 * considering (if enabled) retransmission logic
345 *
346 * @param inFace incoming face of the Interest
347 * @param outFace proposed outgoing face of the Interest
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700348 * @param interest Interest packet
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800349 * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
350 *
351 * @see DetectRetransmittedInterest
352 */
353 virtual bool
354 CanSendOutInterest (Ptr<Face> inFace,
355 Ptr<Face> outFace,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700356 Ptr<const Interest> interest,
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800357 Ptr<pit::Entry> pitEntry);
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800358
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800359 /**
360 * @brief Method implementing actual interest forwarding, taking into account CanSendOutInterest decision
361 *
362 * If event returns false, then there is some kind of a problem exists
363 *
364 * @param inFace incoming face of the Interest
365 * @param outFace proposed outgoing face of the Interest
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700366 * @param interest Interest packet
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800367 * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
368 *
369 * @see CanSendOutInterest
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700370 */
371 virtual bool
Alexander Afanasyev5db92172012-08-21 16:52:07 -0700372 TrySendOutInterest (Ptr<Face> inFace,
373 Ptr<Face> outFace,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700374 Ptr<const Interest> interest,
Alexander Afanasyev5db92172012-08-21 16:52:07 -0700375 Ptr<pit::Entry> pitEntry);
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700376
377 /**
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800378 * @brief Event fired just after forwarding the Interest
379 *
Alexander Afanasyev67f4a4a2012-11-24 17:18:17 -0800380 * @param inFace incoming face of the Interest
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800381 * @param outFace outgoing face of the Interest
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700382 * @param interest Interest packet
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800383 * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700384 */
385 virtual void
Alexander Afanasyev67f4a4a2012-11-24 17:18:17 -0800386 DidSendOutInterest (Ptr<Face> inFace,
387 Ptr<Face> outFace,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700388 Ptr<const Interest> interest,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700389 Ptr<pit::Entry> pitEntry);
390
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700391 /**
392 * @brief Wrapper method, which performs general tasks and calls DoPropagateInterest method
393 *
394 * General tasks so far are adding face to the list of incoming face, updating
395 * PIT entry lifetime, calling DoPropagateInterest, and retransmissions (enabled by default).
396 *
397 * @param inFace incoming face
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700398 * @param interest Interest packet
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700399 * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
400 *
401 * @see DoPropagateInterest
402 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700403 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700404 PropagateInterest (Ptr<Face> inFace,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700405 Ptr<const Interest> interest,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700406 Ptr<pit::Entry> pitEntry);
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800407
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700408 /**
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700409 * @brief Virtual method to perform Interest propagation according to the forwarding strategy logic
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700410 *
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700411 * In most cases, this is the call that needs to be implemented/re-implemented in order
412 * to perform forwarding of Interests according to the desired logic.
413 *
414 * There is also PropagateInterest method (generally, do not require to be overriden)
415 * which performs general tasks (adding face to the list of incoming face, updating
416 * PIT entry lifetime, calling DoPropagateInterest, as well as perform retransmissions (enabled by default).
417 *
418 * @param inFace incoming face
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700419 * @param interest Interest packet
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700420 * @param pitEntry reference to PIT entry (reference to corresponding FIB entry inside)
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700421 *
422 * @return true if interest was successfully propagated, false if all options have failed
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700423 *
424 * @see PropagateInterest
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700425 */
426 virtual bool
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700427 DoPropagateInterest (Ptr<Face> inFace,
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700428 Ptr<const Interest> interest,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700429 Ptr<pit::Entry> pitEntry) = 0;
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800430
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700431protected:
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800432 // inherited from Object class
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700433 virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
434 virtual void DoDispose (); ///< @brief Do cleanup
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800435
436protected:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700437 Ptr<Pit> m_pit; ///< \brief Reference to PIT to which this forwarding strategy is associated
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800438 Ptr<Fib> m_fib; ///< \brief FIB
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700439 Ptr<ContentStore> m_contentStore; ///< \brief Content store (for caching purposes only)
440
Alexander Afanasyevdd9fa4f2013-05-15 16:35:04 -0700441 bool m_cacheUnsolicitedDataFromApps;
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700442 bool m_cacheUnsolicitedData;
443 bool m_detectRetransmissions;
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800444
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700445 TracedCallback<Ptr<const Interest>,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700446 Ptr<const Face> > m_outInterests; ///< @brief Transmitted interests trace
447
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700448 TracedCallback<Ptr<const Interest>,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700449 Ptr<const Face> > m_inInterests; ///< @brief trace of incoming Interests
450
Alexander Afanasyevb989b122013-07-10 17:15:46 -0700451 TracedCallback<Ptr<const Interest>,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700452 Ptr<const Face> > m_dropInterests; ///< @brief trace of dropped Interests
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800453
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700454 ////////////////////////////////////////////////////////////////////
455 ////////////////////////////////////////////////////////////////////
456 ////////////////////////////////////////////////////////////////////
457
Alexander Afanasyev772f51b2013-08-01 18:53:25 -0700458 TracedCallback<Ptr<const Data>,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700459 bool /*from cache*/,
460 Ptr<const Face> > m_outData; ///< @brief trace of outgoing Data
461
Alexander Afanasyev772f51b2013-08-01 18:53:25 -0700462 TracedCallback<Ptr<const Data>,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700463 Ptr<const Face> > m_inData; ///< @brief trace of incoming Data
464
Alexander Afanasyev772f51b2013-08-01 18:53:25 -0700465 TracedCallback<Ptr<const Data>,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700466 Ptr<const Face> > m_dropData; ///< @brief trace of dropped Data
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700467
468 ////////////////////////////////////////////////////////////////////
469 ////////////////////////////////////////////////////////////////////
470 ////////////////////////////////////////////////////////////////////
471
472 TracedCallback< Ptr<const pit::Entry> > m_satisfiedInterests;
473 TracedCallback< Ptr<const pit::Entry> > m_timedOutInterests;
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700474};
475
476} // namespace ndn
477} // namespace ns3
478
479#endif /* NDN_FORWARDING_STRATEGY_H */