NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ndn-forwarding-strategy.h
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>
19  */
20 
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 
42 namespace fw {
43 }
44 
45 class Face;
46 
47 class Interest;
48 class Data;
49 
50 class Pit;
51 namespace pit { class Entry; }
52 class FibFaceMetric;
53 class Fib;
54 namespace fib { class Entry; }
55 class ContentStore;
56 
62  public Object
63 {
64 public:
65  static TypeId GetTypeId ();
66 
70  static std::string GetLogName ();
71 
76  virtual ~ForwardingStrategy ();
77 
85  virtual void
86  OnInterest (Ptr<Face> face,
87  Ptr<Interest> interest);
88 
96  virtual void
97  OnData (Ptr<Face> face,
98  Ptr<Data> data);
99 
104  virtual void
105  WillEraseTimedOutPendingInterest (Ptr<pit::Entry> pitEntry);
106 
111  virtual void
112  AddFace (Ptr<Face> face);
113 
120  virtual void
121  RemoveFace (Ptr<Face> face);
122 
127  virtual void
128  DidAddFibEntry (Ptr<fib::Entry> fibEntry);
129 
134  virtual void
135  WillRemoveFibEntry (Ptr<fib::Entry> fibEntry);
136 
137 protected:
153  virtual void
154  DidCreatePitEntry (Ptr<Face> inFace,
155  Ptr<const Interest> interest,
156  Ptr<pit::Entry> pitEntry);
157 
167  virtual void
168  FailedToCreatePitEntry (Ptr<Face> inFace,
169  Ptr<const Interest> interest);
170 
182  virtual void
183  DidReceiveDuplicateInterest (Ptr<Face> inFace,
184  Ptr<const Interest> interest,
185  Ptr<pit::Entry> pitEntry);
186 
198  virtual void
199  DidSuppressSimilarInterest (Ptr<Face> inFace,
200  Ptr<const Interest> interest,
201  Ptr<pit::Entry> pitEntry);
202 
214  virtual void
215  DidForwardSimilarInterest (Ptr<Face> inFace,
216  Ptr<const Interest> interest,
217  Ptr<pit::Entry> pitEntry);
218 
231  virtual void
232  DidExhaustForwardingOptions (Ptr<Face> inFace,
233  Ptr<const Interest> interest,
234  Ptr<pit::Entry> pitEntry);
235 
249  virtual bool
250  DetectRetransmittedInterest (Ptr<Face> inFace,
251  Ptr<const Interest> interest,
252  Ptr<pit::Entry> pitEntry);
253 
262  virtual void
263  WillSatisfyPendingInterest (Ptr<Face> inFace,
264  Ptr<pit::Entry> pitEntry);
265 
275  virtual void
276  SatisfyPendingInterest (Ptr<Face> inFace, // 0 allowed (from cache)
277  Ptr<const Data> data,
278  Ptr<pit::Entry> pitEntry);
279 
288  virtual void
289  DidSendOutData (Ptr<Face> inFace,
290  Ptr<Face> outFace,
291  Ptr<const Data> data,
292  Ptr<pit::Entry> pitEntry);
293 
301  virtual void
302  DidReceiveSolicitedData (Ptr<Face> inFace,
303  Ptr<const Data> data,
304  bool didCreateCacheEntry);
305 
316  virtual void
317  DidReceiveUnsolicitedData (Ptr<Face> inFace,
318  Ptr<const Data> data,
319  bool didCreateCacheEntry);
320 
333  virtual bool
334  ShouldSuppressIncomingInterest (Ptr<Face> inFace,
335  Ptr<const Interest> interest,
336  Ptr<pit::Entry> pitEntry);
337 
353  virtual bool
354  CanSendOutInterest (Ptr<Face> inFace,
355  Ptr<Face> outFace,
356  Ptr<const Interest> interest,
357  Ptr<pit::Entry> pitEntry);
358 
371  virtual bool
372  TrySendOutInterest (Ptr<Face> inFace,
373  Ptr<Face> outFace,
374  Ptr<const Interest> interest,
375  Ptr<pit::Entry> pitEntry);
376 
385  virtual void
386  DidSendOutInterest (Ptr<Face> inFace,
387  Ptr<Face> outFace,
388  Ptr<const Interest> interest,
389  Ptr<pit::Entry> pitEntry);
390 
403  virtual void
404  PropagateInterest (Ptr<Face> inFace,
405  Ptr<const Interest> interest,
406  Ptr<pit::Entry> pitEntry);
407 
426  virtual bool
427  DoPropagateInterest (Ptr<Face> inFace,
428  Ptr<const Interest> interest,
429  Ptr<pit::Entry> pitEntry) = 0;
430 
431 protected:
432  // inherited from Object class
433  virtual void NotifyNewAggregate ();
434  virtual void DoDispose ();
435 
436 protected:
437  Ptr<Pit> m_pit;
438  Ptr<Fib> m_fib;
439  Ptr<ContentStore> m_contentStore;
440 
441  bool m_cacheUnsolicitedDataFromApps;
442  bool m_cacheUnsolicitedData;
443  bool m_detectRetransmissions;
444 
445  TracedCallback<Ptr<const Interest>,
446  Ptr<const Face> > m_outInterests;
447 
448  TracedCallback<Ptr<const Interest>,
449  Ptr<const Face> > m_inInterests;
450 
451  TracedCallback<Ptr<const Interest>,
452  Ptr<const Face> > m_dropInterests;
453 
457 
458  TracedCallback<Ptr<const Data>,
459  bool /*from cache*/,
460  Ptr<const Face> > m_outData;
461 
462  TracedCallback<Ptr<const Data>,
463  Ptr<const Face> > m_inData;
464 
465  TracedCallback<Ptr<const Data>,
466  Ptr<const Face> > m_dropData;
467 
471 
472  TracedCallback< Ptr<const pit::Entry> > m_satisfiedInterests;
473  TracedCallback< Ptr<const pit::Entry> > m_timedOutInterests;
474 };
475 
476 } // namespace ndn
477 } // namespace ns3
478 
479 #endif /* NDN_FORWARDING_STRATEGY_H */
structure for PIT entry
Definition: ndn-pit-entry.h:57
virtual bool DetectRetransmittedInterest(Ptr< Face > inFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
Method that implements logic to distinguish between new and retransmitted interest.
virtual void FailedToCreatePitEntry(Ptr< Face > inFace, Ptr< const Interest > interest)
An event that is fired every time a new PIT entry cannot be created (e.g., PIT container imposes a li...
virtual void OnInterest(Ptr< Face > face, Ptr< Interest > interest)
Actual processing of incoming Ndn interests.
TracedCallback< Ptr< const Interest >, Ptr< const Face > > m_outInterests
Transmitted interests trace.
virtual bool CanSendOutInterest(Ptr< Face > inFace, Ptr< Face > outFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
Method to check whether Interest can be send out on the particular face or not.
virtual bool DoPropagateInterest(Ptr< Face > inFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)=0
Virtual method to perform Interest propagation according to the forwarding strategy logic...
virtual void DidReceiveSolicitedData(Ptr< Face > inFace, Ptr< const Data > data, bool didCreateCacheEntry)
Event which is fired every time a requested (solicited) DATA packet (there is an active PIT entry) is...
virtual void DidExhaustForwardingOptions(Ptr< Face > inFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
An even that is fired when Interest cannot be forwarded.
virtual void DidReceiveUnsolicitedData(Ptr< Face > inFace, Ptr< const Data > data, bool didCreateCacheEntry)
Event which is fired every time an unsolicited DATA packet (no active PIT entry) is received...
virtual void WillSatisfyPendingInterest(Ptr< Face > inFace, Ptr< pit::Entry > pitEntry)
Even fired just before Interest will be satisfied.
virtual void NotifyNewAggregate()
Even when object is aggregated to another Object.
virtual void DidSuppressSimilarInterest(Ptr< Face > inFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
An event that is fired every time when a similar Interest is received and suppressed (collapsed) ...
static std::string GetLogName()
Helper function to retrieve logging name for the forwarding strategy.
virtual void DidSendOutData(Ptr< Face > inFace, Ptr< Face > outFace, Ptr< const Data > data, Ptr< pit::Entry > pitEntry)
Event which is fired just after data was send out on the face.
virtual void DidReceiveDuplicateInterest(Ptr< Face > inFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
An event that is fired every time a duplicated Interest is received.
virtual bool ShouldSuppressIncomingInterest(Ptr< Face > inFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
Method implementing logic to suppress (collapse) similar Interests.
TracedCallback< Ptr< const Data >, bool, Ptr< const Face > > m_outData
trace of outgoing Data
virtual void WillEraseTimedOutPendingInterest(Ptr< pit::Entry > pitEntry)
Event fired just before PIT entry is removed by timeout.
TracedCallback< Ptr< const Interest >, Ptr< const Face > > m_dropInterests
trace of dropped Interests
Class implementing FIB functionality.
Definition: ndn-fib.h:44
virtual void RemoveFace(Ptr< Face > face)
Event fired every time face is removed from NDN stack.
virtual void DoDispose()
Do cleanup.
virtual void DidSendOutInterest(Ptr< Face > inFace, Ptr< Face > outFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
Event fired just after forwarding the Interest.
TracedCallback< Ptr< const Data >, Ptr< const Face > > m_dropData
trace of dropped Data
ForwardingStrategy()
Default constructor.
virtual void DidCreatePitEntry(Ptr< Face > inFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
An event that is fired every time a new PIT entry is created.
virtual void OnData(Ptr< Face > face, Ptr< Data > data)
Actual processing of incoming Ndn content objects.
virtual void PropagateInterest(Ptr< Face > inFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
Wrapper method, which performs general tasks and calls DoPropagateInterest method.
virtual void WillRemoveFibEntry(Ptr< fib::Entry > fibEntry)
Fired just before FIB entry will be removed from FIB.
Ptr< ContentStore > m_contentStore
Content store (for caching purposes only)
virtual void DidAddFibEntry(Ptr< fib::Entry > fibEntry)
Event fired every time a FIB entry is added to FIB.
Ptr< Pit > m_pit
Reference to PIT to which this forwarding strategy is associated.
TracedCallback< Ptr< const Interest >, Ptr< const Face > > m_inInterests
trace of incoming Interests
virtual void DidForwardSimilarInterest(Ptr< Face > inFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
An event that is fired every time when a similar Interest is received and further forwarded (not supp...
Abstract base class for Ndn forwarding strategies.
virtual void AddFace(Ptr< Face > face)
Event fired every time face is added to NDN stack.
virtual bool TrySendOutInterest(Ptr< Face > inFace, Ptr< Face > outFace, Ptr< const Interest > interest, Ptr< pit::Entry > pitEntry)
Method implementing actual interest forwarding, taking into account CanSendOutInterest decision...
TracedCallback< Ptr< const Data >, Ptr< const Face > > m_inData
trace of incoming Data
virtual void SatisfyPendingInterest(Ptr< Face > inFace, Ptr< const Data > data, Ptr< pit::Entry > pitEntry)
Actual procedure to satisfy Interest.