NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
client-control-strategy.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
27 #include "core/logger.hpp"
28 
29 namespace nfd {
30 namespace fw {
31 
32 NFD_LOG_INIT("ClientControlStrategy");
33 
34 const Name
35 ClientControlStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/client-control/%FD%01");
36 
38  : BestRouteStrategy(forwarder, name)
39 {
40 }
41 
43 {
44 }
45 
46 void
48  const Interest& interest,
49  shared_ptr<fib::Entry> fibEntry,
50  shared_ptr<pit::Entry> pitEntry)
51 {
52  // Strategy needn't check whether LocalControlHeader-NextHopFaceId is enabled.
53  // LocalFace does this check.
54  if (!interest.getLocalControlHeader().hasNextHopFaceId()) {
55  this->BestRouteStrategy::afterReceiveInterest(inFace, interest, fibEntry, pitEntry);
56  return;
57  }
58 
59  FaceId outFaceId = static_cast<FaceId>(interest.getNextHopFaceId());
60  shared_ptr<Face> outFace = this->getFace(outFaceId);
61  if (!static_cast<bool>(outFace)) {
62  // If outFace doesn't exist, it's better to reject the Interest
63  // than to use BestRouteStrategy.
64  NFD_LOG_WARN("Interest " << interest.getName() <<
65  " NextHopFaceId=" << outFaceId << " non-existent face");
66  this->rejectPendingInterest(pitEntry);
67  return;
68  }
69 
70  this->sendInterest(pitEntry, outFace);
71 }
72 
73 } // namespace fw
74 } // namespace nfd
ClientControlStrategy(Forwarder &forwarder, const Name &name=STRATEGY_NAME)
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, shared_ptr< fib::Entry > fibEntry, shared_ptr< pit::Entry > pitEntry) 1
trigger after Interest is received
main class of NFD
Definition: forwarder.hpp:54
represents a face
Definition: face.hpp:59
shared_ptr< Face > getFace(FaceId id)
Definition: strategy.hpp:180
#define NFD_LOG_WARN(expression)
Definition: logger.hpp:39
Best Route strategy version 1.
identifies a face
void rejectPendingInterest(shared_ptr< pit::Entry > pitEntry)
decide that a pending Interest cannot be forwarded
Definition: strategy.hpp:168
#define NFD_LOG_INIT(name)
Definition: logger.hpp:33
void sendInterest(shared_ptr< pit::Entry > pitEntry, shared_ptr< Face > outFace, bool wantNewNonce=false)
send Interest to outFace
Definition: strategy.hpp:160
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, shared_ptr< fib::Entry > fibEntry, shared_ptr< pit::Entry > pitEntry) 1
trigger after Interest is received