blob: a3fe5b5edb50a5c596d66a5086fb75abc344642d [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
32class Face;
Alexander Afanasyev73f06f62013-03-15 15:41:38 -070033
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -070034class Interest;
35class ContentObject;
Alexander Afanasyev73f06f62013-03-15 15:41:38 -070036
37typedef Interest InterestHeader;
38typedef ContentObject ContentObjectHeader;
39
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070040class Pit;
41namespace pit { class Entry; }
42class FibFaceMetric;
43class Fib;
Alexander Afanasyevadcccf42012-11-26 23:55:34 -080044namespace fib { class Entry; }
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070045class ContentStore;
46
47/**
48 * \ingroup ndn
49 * \brief Abstract base class for Ndn forwarding strategies
50 */
51class ForwardingStrategy :
52 public Object
53{
54public:
55 static TypeId GetTypeId (void);
56
57 /**
Alexander Afanasyev042b4a72012-11-09 17:47:48 -080058 * @brief Helper function to retrieve logging name for the forwarding strategy
59 */
60 static std::string GetLogName ();
61
62 /**
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070063 * @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 Afanasyeve6c07b52013-02-12 11:05:14 -080070 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070071 * Processing Interest packets
72 * @param face incoming face
73 * @param header deserialized Interest header
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070074 * @param origPacket original packet
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070075 */
76 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070077 OnInterest (Ptr<Face> face,
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -070078 Ptr<const Interest> header,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070079 Ptr<const Packet> origPacket);
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070080
81 /**
82 * \brief Actual processing of incoming Ndn content objects
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -080083 *
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070084 * Processing ContentObject packets
85 * @param face incoming face
86 * @param header deserialized ContentObject header
87 * @param payload data packet payload
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070088 * @param origPacket original packet
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070089 */
90 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070091 OnData (Ptr<Face> face,
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -070092 Ptr<const ContentObject> header,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -070093 Ptr<Packet> payload,
94 Ptr<const Packet> origPacket);
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070095
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -070096 /**
97 * @brief Event fired just before PIT entry is removed by timeout
98 * @param pitEntry PIT entry to be removed
99 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700100 virtual void
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700101 WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700102
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700103 /**
Alexander Afanasyevf5c07742012-10-31 13:13:05 -0700104 * @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 Afanasyeve6c07b52013-02-12 11:05:14 -0800109
Alexander Afanasyevf5c07742012-10-31 13:13:05 -0700110 /**
Alexander Afanasyevea9b3e62012-08-13 19:02:54 -0700111 * @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 Afanasyev2b4c9472012-08-09 15:00:38 -0700116 virtual void
117 RemoveFace (Ptr<Face> face);
Alexander Afanasyevadcccf42012-11-26 23:55:34 -0800118
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 Afanasyeve6c07b52013-02-12 11:05:14 -0800132
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700133protected:
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700134 /**
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 Afanasyeve6c07b52013-02-12 11:05:14 -0800140 *
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700141 * 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 Afanasyeveae83ee2013-03-15 15:01:10 -0700152 Ptr<const Interest> header,
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700153 Ptr<const Packet> origPacket,
154 Ptr<pit::Entry> pitEntry);
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800155
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700156 /**
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 Afanasyeve6c07b52013-02-12 11:05:14 -0800161 *
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700162 * @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 Afanasyeveae83ee2013-03-15 15:01:10 -0700168 Ptr<const Interest> header,
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700169 Ptr<const Packet> origPacket);
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
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 Afanasyev2b4c9472012-08-09 15:00:38 -0700183 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700184 DidReceiveDuplicateInterest (Ptr<Face> inFace,
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700185 Ptr<const Interest> header,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700186 Ptr<const Packet> origPacket,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700187 Ptr<pit::Entry> pitEntry);
188
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700189 /**
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 Afanasyeveae83ee2013-03-15 15:01:10 -0700203 Ptr<const Interest> header,
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700204 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 Afanasyeveae83ee2013-03-15 15:01:10 -0700221 Ptr<const Interest> header,
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700222 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 Afanasyev2b4c9472012-08-09 15:00:38 -0700238 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700239 DidExhaustForwardingOptions (Ptr<Face> inFace,
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700240 Ptr<const Interest> header,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700241 Ptr<const Packet> origPacket,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700242 Ptr<pit::Entry> pitEntry);
243
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800244 /**
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 Afanasyev2b4c9472012-08-09 15:00:38 -0700258 virtual bool
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700259 DetectRetransmittedInterest (Ptr<Face> inFace,
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700260 Ptr<const Interest> header,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700261 Ptr<const Packet> origPacket,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700262 Ptr<pit::Entry> pitEntry);
263
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800264 /**
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 Afanasyeve6c07b52013-02-12 11:05:14 -0800270 * @param pitEntry an existing PIT entry, corresponding to the duplicated Interest
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800271 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700272 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700273 WillSatisfyPendingInterest (Ptr<Face> inFace,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700274 Ptr<pit::Entry> pitEntry);
275
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800276 /**
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 Afanasyev2b4c9472012-08-09 15:00:38 -0700287 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700288 SatisfyPendingInterest (Ptr<Face> inFace, // 0 allowed (from cache)
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700289 Ptr<const ContentObject> header,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700290 Ptr<const Packet> payload,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700291 Ptr<const Packet> origPacket,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700292 Ptr<pit::Entry> pitEntry);
293
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800294 /**
295 * @brief Event which is fired just after data was send out on the face
296 *
Alexander Afanasyev67f4a4a2012-11-24 17:18:17 -0800297 * @param inFace incoming face of the ContentObject
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800298 * @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 Afanasyev2b4c9472012-08-09 15:00:38 -0700304 virtual void
Alexander Afanasyev67f4a4a2012-11-24 17:18:17 -0800305 DidSendOutData (Ptr<Face> inFace,
306 Ptr<Face> outFace,
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700307 Ptr<const ContentObject> header,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700308 Ptr<const Packet> payload,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700309 Ptr<const Packet> origPacket,
310 Ptr<pit::Entry> pitEntry);
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800311
312 /**
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800313 * @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 Afanasyeveae83ee2013-03-15 15:01:10 -0700323 Ptr<const ContentObject> header,
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800324 Ptr<const Packet> payload,
325 Ptr<const Packet> origPacket,
326 bool didCreateCacheEntry);
327
328 /**
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800329 * @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 Afanasyeve6c07b52013-02-12 11:05:14 -0800338 * @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 -0800339 */
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700340 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700341 DidReceiveUnsolicitedData (Ptr<Face> inFace,
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700342 Ptr<const ContentObject> header,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700343 Ptr<const Packet> payload,
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800344 Ptr<const Packet> origPacket,
345 bool didCreateCacheEntry);
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800346
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 Afanasyev2b4c9472012-08-09 15:00:38 -0700360 virtual bool
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700361 ShouldSuppressIncomingInterest (Ptr<Face> inFace,
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700362 Ptr<const Interest> header,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700363 Ptr<const Packet> origPacket,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700364 Ptr<pit::Entry> pitEntry);
365
366 /**
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800367 * @brief Method to check whether Interest can be send out on the particular face or not
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700368 *
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800369 * 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 Afanasyeveae83ee2013-03-15 15:01:10 -0700385 Ptr<const Interest> header,
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800386 Ptr<const Packet> origPacket,
387 Ptr<pit::Entry> pitEntry);
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800388
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800389 /**
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 Afanasyev2b4c9472012-08-09 15:00:38 -0700401 */
402 virtual bool
Alexander Afanasyev5db92172012-08-21 16:52:07 -0700403 TrySendOutInterest (Ptr<Face> inFace,
404 Ptr<Face> outFace,
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700405 Ptr<const Interest> header,
Alexander Afanasyev5db92172012-08-21 16:52:07 -0700406 Ptr<const Packet> origPacket,
407 Ptr<pit::Entry> pitEntry);
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700408
409 /**
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800410 * @brief Event fired just after forwarding the Interest
411 *
Alexander Afanasyev67f4a4a2012-11-24 17:18:17 -0800412 * @param inFace incoming face of the Interest
Alexander Afanasyevdb15acb2012-11-09 14:16:27 -0800413 * @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 Afanasyev2b4c9472012-08-09 15:00:38 -0700417 */
418 virtual void
Alexander Afanasyev67f4a4a2012-11-24 17:18:17 -0800419 DidSendOutInterest (Ptr<Face> inFace,
420 Ptr<Face> outFace,
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700421 Ptr<const Interest> header,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700422 Ptr<const Packet> origPacket,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700423 Ptr<pit::Entry> pitEntry);
424
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700425 /**
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 Afanasyev2b4c9472012-08-09 15:00:38 -0700438 virtual void
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700439 PropagateInterest (Ptr<Face> inFace,
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700440 Ptr<const Interest> header,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700441 Ptr<const Packet> origPacket,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700442 Ptr<pit::Entry> pitEntry);
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800443
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700444 /**
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700445 * @brief Virtual method to perform Interest propagation according to the forwarding strategy logic
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700446 *
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700447 * 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 Afanasyev2b4c9472012-08-09 15:00:38 -0700458 *
459 * @return true if interest was successfully propagated, false if all options have failed
Alexander Afanasyev6466fff2012-10-24 22:51:57 -0700460 *
461 * @see PropagateInterest
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700462 */
463 virtual bool
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700464 DoPropagateInterest (Ptr<Face> inFace,
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700465 Ptr<const Interest> header,
Alexander Afanasyev31cb4692012-08-17 13:08:20 -0700466 Ptr<const Packet> origPacket,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700467 Ptr<pit::Entry> pitEntry) = 0;
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800468
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700469protected:
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800470 // inherited from Object class
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700471 virtual void NotifyNewAggregate (); ///< @brief Even when object is aggregated to another Object
472 virtual void DoDispose (); ///< @brief Do cleanup
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800473
474protected:
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700475 Ptr<Pit> m_pit; ///< \brief Reference to PIT to which this forwarding strategy is associated
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800476 Ptr<Fib> m_fib; ///< \brief FIB
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700477 Ptr<ContentStore> m_contentStore; ///< \brief Content store (for caching purposes only)
478
479 bool m_cacheUnsolicitedData;
480 bool m_detectRetransmissions;
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800481
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700482 TracedCallback<Ptr<const Interest>,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700483 Ptr<const Face> > m_outInterests; ///< @brief Transmitted interests trace
484
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700485 TracedCallback<Ptr<const Interest>,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700486 Ptr<const Face> > m_inInterests; ///< @brief trace of incoming Interests
487
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700488 TracedCallback<Ptr<const Interest>,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700489 Ptr<const Face> > m_dropInterests; ///< @brief trace of dropped Interests
Alexander Afanasyeve6c07b52013-02-12 11:05:14 -0800490
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700491 ////////////////////////////////////////////////////////////////////
492 ////////////////////////////////////////////////////////////////////
493 ////////////////////////////////////////////////////////////////////
494
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700495 TracedCallback<Ptr<const ContentObject>, Ptr<const Packet>,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700496 bool /*from cache*/,
497 Ptr<const Face> > m_outData; ///< @brief trace of outgoing Data
498
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700499 TracedCallback<Ptr<const ContentObject>, Ptr<const Packet>,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700500 Ptr<const Face> > m_inData; ///< @brief trace of incoming Data
501
Alexander Afanasyeveae83ee2013-03-15 15:01:10 -0700502 TracedCallback<Ptr<const ContentObject>, Ptr<const Packet>,
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700503 Ptr<const Face> > m_dropData; ///< @brief trace of dropped Data
Alexander Afanasyev37b84c52013-04-26 13:38:52 -0700504
505 ////////////////////////////////////////////////////////////////////
506 ////////////////////////////////////////////////////////////////////
507 ////////////////////////////////////////////////////////////////////
508
509 TracedCallback< Ptr<const pit::Entry> > m_satisfiedInterests;
510 TracedCallback< Ptr<const pit::Entry> > m_timedOutInterests;
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700511};
512
513} // namespace ndn
514} // namespace ns3
515
516#endif /* NDN_FORWARDING_STRATEGY_H */