NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
forwarder-status-manager.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2018, Regents of the University of California,
4  * Arizona Board of Regents,
5  * Colorado State University,
6  * University Pierre & Marie Curie, Sorbonne University,
7  * Washington University in St. Louis,
8  * Beijing Institute of Technology,
9  * The University of Memphis.
10  *
11  * This file is part of NFD (Named Data Networking Forwarding Daemon).
12  * See AUTHORS.md for complete list of NFD authors and contributors.
13  *
14  * NFD is free software: you can redistribute it and/or modify it under the terms
15  * of the GNU General Public License as published by the Free Software Foundation,
16  * either version 3 of the License, or (at your option) any later version.
17  *
18  * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20  * PURPOSE. See the GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License along with
23  * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
27 #include "fw/forwarder.hpp"
28 #include "core/version.hpp"
29 
30 namespace nfd {
31 
32 static const time::milliseconds STATUS_FRESHNESS(5000);
33 
35  : m_forwarder(forwarder)
36  , m_dispatcher(dispatcher)
37  , m_startTimestamp(time::system_clock::now())
38 {
39  m_dispatcher.addStatusDataset("status/general", ndn::mgmt::makeAcceptAllAuthorization(),
40  bind(&ForwarderStatusManager::listGeneralStatus, this, _1, _2, _3));
41 }
42 
44 ForwarderStatusManager::collectGeneralStatus()
45 {
47 
48  status.setNfdVersion(NFD_VERSION_BUILD_STRING);
49  status.setStartTimestamp(m_startTimestamp);
51 
52  status.setNNameTreeEntries(m_forwarder.getNameTree().size());
53  status.setNFibEntries(m_forwarder.getFib().size());
54  status.setNPitEntries(m_forwarder.getPit().size());
55  status.setNMeasurementsEntries(m_forwarder.getMeasurements().size());
56  status.setNCsEntries(m_forwarder.getCs().size());
57 
58  const ForwarderCounters& counters = m_forwarder.getCounters();
59  status.setNInInterests(counters.nInInterests)
61  .setNInData(counters.nInData)
62  .setNOutData(counters.nOutData)
63  .setNInNacks(counters.nInNacks)
64  .setNOutNacks(counters.nOutNacks)
67 
68  return status;
69 }
70 
71 void
72 ForwarderStatusManager::listGeneralStatus(const Name& topPrefix, const Interest& interest,
74 {
75  context.setExpiry(STATUS_FRESHNESS);
76 
77  auto status = this->collectGeneralStatus();
78  const Block& wire = status.wireEncode();
79  wire.parse();
80  for (const auto& subblock : wire.elements()) {
81  context.append(subblock);
82  }
83  context.end();
84 }
85 
86 } // namespace nfd
ndn::nfd::ForwarderStatus::setNInInterests
ForwarderStatus & setNInInterests(uint64_t nInInterests)
Definition: forwarder-status.cpp:308
ndn::nfd::ForwarderStatus::setNNameTreeEntries
ForwarderStatus & setNNameTreeEntries(uint64_t nNameTreeEntries)
Definition: forwarder-status.cpp:268
ndn::nfd::ForwarderStatus::setNfdVersion
ForwarderStatus & setNfdVersion(const std::string &nfdVersion)
Definition: forwarder-status.cpp:244
ndn::nfd::ForwarderStatus::setNOutInterests
ForwarderStatus & setNOutInterests(uint64_t nOutInterests)
Definition: forwarder-status.cpp:332
ndn::nfd::ForwarderStatus::setNUnsatisfiedInterests
ForwarderStatus & setNUnsatisfiedInterests(uint64_t nUnsatisfiedInterests)
Definition: forwarder-status.cpp:364
nfd::ForwarderCounters::nUnsatisfiedInterests
PacketCounter nUnsatisfiedInterests
Definition: forwarder-counters.hpp:45
nfd::measurements::Measurements::size
size_t size() const
Definition: measurements.hpp:149
ndn::nfd::ForwarderStatus::setNInNacks
ForwarderStatus & setNInNacks(uint64_t nInNacks)
Definition: forwarder-status.cpp:324
ndn::mgmt::StatusDatasetContext::append
void append(const Block &block)
append a Block to the response
Definition: status-dataset-context.cpp:69
ndn::nfd::ForwarderStatus::setNPitEntries
ForwarderStatus & setNPitEntries(uint64_t nPitEntries)
Definition: forwarder-status.cpp:284
ndn::tlv::Interest
@ Interest
Definition: tlv.hpp:65
nfd::ForwarderCounters::nSatisfiedInterests
PacketCounter nSatisfiedInterests
Definition: forwarder-counters.hpp:44
ndn::nfd::ForwarderStatus::setNCsEntries
ForwarderStatus & setNCsEntries(uint64_t nCsEntries)
Definition: forwarder-status.cpp:300
nfd::name_tree::NameTree::size
size_t size() const
Definition: name-tree.hpp:59
nfd::Forwarder::getPit
Pit & getPit()
Definition: forwarder.hpp:133
nfd::ForwarderStatusManager::ForwarderStatusManager
ForwarderStatusManager(Forwarder &forwarder, Dispatcher &dispatcher)
Definition: forwarder-status-manager.cpp:34
nfd::Forwarder::getCs
Cs & getCs()
Definition: forwarder.hpp:139
ndn::time::system_clock::now
static time_point now() noexcept
Definition: time.cpp:46
nfd::ForwarderCounters::nOutData
PacketCounter nOutData
Definition: forwarder-counters.hpp:41
ndn::nfd::ForwarderStatus::setNSatisfiedInterests
ForwarderStatus & setNSatisfiedInterests(uint64_t nSatisfiedInterests)
Definition: forwarder-status.cpp:356
ndn::nfd::ForwarderStatus::setNMeasurementsEntries
ForwarderStatus & setNMeasurementsEntries(uint64_t nMeasurementsEntries)
Definition: forwarder-status.cpp:292
nfd::pit::Pit::size
size_t size() const
Definition: pit.hpp:56
forwarder.hpp
nfd::ForwarderCounters::nInData
PacketCounter nInData
Definition: forwarder-counters.hpp:40
ndn::nfd::ForwarderStatus::setStartTimestamp
ForwarderStatus & setStartTimestamp(const time::system_clock::TimePoint &startTimestamp)
Definition: forwarder-status.cpp:252
nfd::ForwarderCounters
counters provided by Forwarder
Definition: forwarder-counters.hpp:36
ndn::nfd::ForwarderStatus::setNOutData
ForwarderStatus & setNOutData(uint64_t nOutData)
Definition: forwarder-status.cpp:340
ndn::mgmt::Dispatcher::addStatusDataset
void addStatusDataset(const PartialName &relPrefix, Authorization authorize, StatusDatasetHandler handle)
register a StatusDataset or a prefix under which StatusDatasets can be requested
Definition: dispatcher.cpp:223
nfd::STATUS_FRESHNESS
static const time::milliseconds STATUS_FRESHNESS(5000)
nfd::ForwarderCounters::nOutNacks
PacketCounter nOutNacks
Definition: forwarder-counters.hpp:43
nfd::Forwarder::getMeasurements
Measurements & getMeasurements()
Definition: forwarder.hpp:145
ns3::ndn::Name
Name
Definition: ndn-common.cpp:25
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::Forwarder::getNameTree
NameTree & getNameTree()
Definition: forwarder.hpp:121
nfd::Forwarder::getCounters
const ForwarderCounters & getCounters() const
Definition: forwarder.hpp:61
ndn::time
Definition: time-custom-clock.hpp:28
nfd::ForwarderCounters::nInNacks
PacketCounter nInNacks
Definition: forwarder-counters.hpp:42
ndn::mgmt::StatusDatasetContext
provides a context for generating response to a StatusDataset request
Definition: status-dataset-context.hpp:37
ndn::mgmt::makeAcceptAllAuthorization
Authorization makeAcceptAllAuthorization()
return an Authorization that accepts all Interests, with empty string as requester
Definition: dispatcher.cpp:34
ndn::nfd::ForwarderStatus::setNInData
ForwarderStatus & setNInData(uint64_t nInData)
Definition: forwarder-status.cpp:316
ndn::nfd::ForwarderStatus::setCurrentTimestamp
ForwarderStatus & setCurrentTimestamp(const time::system_clock::TimePoint &currentTimestamp)
Definition: forwarder-status.cpp:260
nfd::ForwarderCounters::nInInterests
PacketCounter nInInterests
Definition: forwarder-counters.hpp:38
ndn::nfd::ForwarderStatus::setNFibEntries
ForwarderStatus & setNFibEntries(uint64_t nFibEntries)
Definition: forwarder-status.cpp:276
nfd::Forwarder
Main class of NFD's forwarding engine.
Definition: forwarder.hpp:52
nfd::Forwarder::getFib
Fib & getFib()
Definition: forwarder.hpp:127
nfd::ForwarderCounters::nOutInterests
PacketCounter nOutInterests
Definition: forwarder-counters.hpp:39
ndn::mgmt::Dispatcher
represents a dispatcher on server side of NFD Management protocol
Definition: dispatcher.hpp:131
ndn::mgmt::StatusDatasetContext::end
void end()
end the response successfully after appending zero or more blocks
Definition: status-dataset-context.cpp:95
ndn::mgmt::StatusDatasetContext::setExpiry
StatusDatasetContext & setExpiry(const time::milliseconds &expiry)
set expiration duration
Definition: status-dataset-context.cpp:62
ndn::nfd::ForwarderStatus::wireEncode
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend ForwarderStatus as a Content block to the encoder
Definition: forwarder-status.cpp:57
nfd::fib::Fib::size
size_t size() const
Definition: fib.hpp:54
nfd::cs::Cs::size
size_t size() const
get number of stored packets
Definition: cs.hpp:94
ndn::nfd::ForwarderStatus::setNOutNacks
ForwarderStatus & setNOutNacks(uint64_t nOutNacks)
Definition: forwarder-status.cpp:348
ndn::nfd::ForwarderStatus
represents NFD General Status dataset
Definition: forwarder-status.hpp:37
forwarder-status-manager.hpp