NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
multicast-strategy.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #include "multicast-strategy.hpp"
27 #include "algorithm.hpp"
28 
29 namespace nfd {
30 namespace fw {
31 
32 const Name MulticastStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/multicast/%FD%01");
33 NFD_REGISTER_STRATEGY(MulticastStrategy);
34 
36  : Strategy(forwarder, name)
37 {
38 }
39 
40 void
41 MulticastStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
42  const shared_ptr<pit::Entry>& pitEntry)
43 {
44  const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
45  const fib::NextHopList& nexthops = fibEntry.getNextHops();
46 
47  for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
48  Face& outFace = it->getFace();
49  if (!wouldViolateScope(inFace, interest, outFace) &&
50  canForwardToLegacy(*pitEntry, outFace)) {
51  this->sendInterest(pitEntry, outFace, interest);
52  }
53  }
54 
55  if (!hasPendingOutRecords(*pitEntry)) {
56  this->rejectPendingInterest(pitEntry);
57  }
58 }
59 
60 } // namespace fw
61 } // namespace nfd
bool canForwardToLegacy(const pit::Entry &pitEntry, const Face &face)
decide whether Interest can be forwarded to face
Definition: algorithm.cpp:82
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Interest is received
generalization of a network interface
Definition: face.hpp:67
represents a FIB entry
Definition: fib-entry.hpp:51
main class of NFD
Definition: forwarder.hpp:54
represents an Interest packet
Definition: interest.hpp:42
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
NFD_REGISTER_STRATEGY(AccessStrategy)
std::vector< fib::NextHop > NextHopList
Definition: fib-entry.hpp:47
void rejectPendingInterest(const shared_ptr< pit::Entry > &pitEntry)
decide that a pending Interest cannot be forwarded
Definition: strategy.hpp:162
Name abstraction to represent an absolute name.
Definition: name.hpp:46
bool hasPendingOutRecords(const pit::Entry &pitEntry)
determine whether pitEntry has any pending out-records
Definition: algorithm.cpp:136
represents a forwarding strategy
Definition: strategy.hpp:38
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...
const fib::Entry & lookupFib(const pit::Entry &pitEntry) const
performs a FIB lookup, considering Link object if present
Definition: strategy.cpp:129
const NextHopList & getNextHops() const
Definition: fib-entry.hpp:64
MulticastStrategy(Forwarder &forwarder, const Name &name=STRATEGY_NAME)
void sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &outFace, const Interest &interest)
send Interest to outFace
Definition: strategy.hpp:137
bool wouldViolateScope(const Face &inFace, const Interest &interest, const Face &outFace)
determine whether forwarding the Interest in pitEntry to outFace would violate scope ...
Definition: algorithm.cpp:37