|
NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
|
API Documentation
|
Go to the documentation of this file.
46 , m_faceSystem(faceSystem)
47 , m_faceTable(faceSystem.getFaceTable())
50 registerCommandHandler<ndn::nfd::FaceCreateCommand>(
"create", bind(&FaceManager::createFace,
this, _4, _5));
51 registerCommandHandler<ndn::nfd::FaceUpdateCommand>(
"update", bind(&FaceManager::updateFace,
this, _3, _4, _5));
52 registerCommandHandler<ndn::nfd::FaceDestroyCommand>(
"destroy", bind(&FaceManager::destroyFace,
this, _4, _5));
61 m_faceAddConn = m_faceTable.
afterAdd.connect([
this] (
const Face& face) {
62 connectFaceStateChangeSignal(face);
65 m_faceRemoveConn = m_faceTable.
beforeRemove.connect([
this] (
const Face& face) {
87 optional<FaceUri> localUri;
97 if (!localUri->isCanonical()) {
98 NFD_LOG_TRACE(
"received non-canonical local URI: " << localUri->toString());
105 if (factory ==
nullptr) {
111 face::FaceParams faceParams;
119 if (parameters.
hasMtu()) {
120 faceParams.mtu = parameters.
getMtu();
130 factory->createFace({remoteUri, localUri, faceParams},
131 [
this, parameters, done] (
const auto& face) {
132 this->afterCreateFaceSuccess(face, parameters, done);
134 [done] (uint32_t status,
const std::string& reason) {
139 catch (
const std::runtime_error& error) {
141 done(
ControlResponse(500,
"Face creation failed due to internal error"));
144 catch (
const std::logic_error& error) {
146 done(
ControlResponse(500,
"Face creation failed due to internal error"));
156 BOOST_ASSERT(transport !=
nullptr);
158 if (transport->getMtu() > 0) {
174 if (linkService !=
nullptr) {
175 const auto& options = linkService->
getOptions();
199 FaceManager::afterCreateFaceSuccess(
const shared_ptr<Face>& face,
204 NFD_LOG_TRACE(
"Attempted to create duplicate face of " << face->getId());
206 done(
ControlResponse(409,
"Face with remote URI already exists").setBody(response.wireEncode()));
217 m_faceTable.
add(face);
227 if (linkService ==
nullptr) {
249 linkService->setOptions(options);
253 FaceManager::updateFace(
const Interest& interest,
257 FaceId faceId = parameters.getFaceId();
260 if (incomingFaceIdTag ==
nullptr) {
262 done(
ControlResponse(404,
"No FaceId specified and IncomingFaceId not available"));
265 faceId = *incomingFaceIdTag;
268 Face* face = m_faceTable.
get(faceId);
269 if (face ==
nullptr) {
277 bool areParamsValid =
true;
282 NFD_LOG_TRACE(
"received request to enable local fields on non-local face");
283 areParamsValid =
false;
289 if (parameters.hasFacePersistency()) {
290 auto persistency = parameters.getFacePersistency();
291 if (!face->getTransport()->canChangePersistencyTo(persistency)) {
292 NFD_LOG_TRACE(
"cannot change face persistency to " << persistency);
293 areParamsValid =
false;
294 response.setFacePersistency(persistency);
298 if (!areParamsValid) {
299 done(
ControlResponse(409,
"Invalid properties specified").setBody(response.wireEncode()));
304 if (parameters.hasFacePersistency()) {
305 face->setPersistency(parameters.getFacePersistency());
318 Face* face = m_faceTable.
get(parameters.getFaceId());
319 if (face !=
nullptr) {
330 to.setFaceId(face.
getId())
338 if (linkService !=
nullptr) {
339 const auto& options = linkService->
getOptions();
353 if (expirationTime != time::steady_clock::TimePoint::max()) {
355 time::duration_cast<time::milliseconds>(expirationTime - now)));
359 if (linkService !=
nullptr) {
360 const auto& options = linkService->
getOptions();
384 for (
const auto& face : m_faceTable) {
395 for (
const auto* factory : factories) {
396 for (
const auto& channel : factory->getChannels()) {
448 FaceManager::queryFaces(
const Interest& interest,
453 faceFilter.
wireDecode(interest.getName()[-1].blockFromValue());
455 catch (
const tlv::Error& e) {
461 for (
const auto& face : m_faceTable) {
477 m_postNotification(notification.
wireEncode());
481 FaceManager::connectFaceStateChangeSignal(
const Face& face)
485 FaceId faceId = face.getId();
486 m_faceStateChangeConn[faceId] = face.afterStateChange.connect(
488 if (newState == FaceState::UP) {
491 else if (newState == FaceState::DOWN) {
494 else if (newState == FaceState::CLOSED) {
496 m_faceStateChangeConn.erase(faceId);
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend FaceEventNotification to the encoder
FaceStatus & setNInNacks(uint64_t nInNacks)
@ FACE_EVENT_DOWN
face went DOWN (from UP state)
const Options & getOptions() const
get Options used by GenericLinkService
const FaceCounters & getCounters() const
static ControlParameters makeUpdateFaceResponse(const Face &face)
void reject(const ControlResponse &resp=ControlResponse().setCode(400))
declare the non-existence of a response
uint64_t getFaceId() const
FaceStatus & setNOutData(uint64_t nOutData)
ControlParameters & setDefaultCongestionThreshold(uint64_t threshold)
set default congestion threshold (measured in bytes)
const ssize_t MTU_UNLIMITED
indicates the transport has no limit on payload size
FaceEventNotification & setKind(FaceEventKind kind)
void append(const Block &block)
append a Block to the response
ControlParameters & setFacePersistency(FacePersistency persistency)
const std::string & getUriScheme() const
Transport * getTransport() const
size_t wireEncode(EncodingImpl< TAG > &encoder) const
represents the underlying protocol and address used by a Face
Implements the Face Management of NFD Management Protocol.
void wireDecode(const Block &wire)
decode FaceQueryFilter
provides a tag type for simple types
FaceScope getFaceScope() const
bool hasFaceScope() const
@ FACE_EVENT_DESTROYED
face was destroyed
entry point of the face system
static time_point now() noexcept
ProtocolFactory * getFactoryByScheme(const std::string &scheme)
std::function< void(const ControlResponse &resp)> CommandContinuation
a function to be called after ControlCommandHandler completes
@ BIT_CONGESTION_MARKING_ENABLED
whether congestion detection and marking is enabled on a face
represents an item in NFD Channel dataset
TransportState FaceState
indicates the state of a face
mgmt::ControlResponse ControlResponse
void registerStatusDatasetHandler(const std::string &verb, const ndn::mgmt::StatusDatasetHandler &handler)
FaceStatus & setNInBytes(uint64_t nInBytes)
std::set< const ProtocolFactory * > listProtocolFactories() const
std::string toString() const
write as a string
FaceStatus & setDefaultCongestionThreshold(uint64_t threshold)
set default congestion threshold (measured in bytes)
bool hasFlagBit(size_t bit) const
static ndn::nfd::FaceStatus makeFaceStatus(const Face &face, const time::steady_clock::TimePoint &now)
signal::Signal< FaceTable, Face > afterAdd
Fires immediately after a face is added.
FaceUri getLocalUri() const
ControlParameters & setFlagBit(size_t bit, bool value, bool wantMask=true)
set a bit in Flags
bool hasFacePersistency() const
static void copyMtu(const Face &face, T &to)
represents a Face status change notification
void close()
request the face to be closed
ControlParameters & setUri(const std::string &uri)
FaceStatus & setExpirationPeriod(time::milliseconds expirationPeriod)
bool hasUriScheme() const
Copyright (c) 2011-2015 Regents of the University of California.
FaceUri getRemoteUri() const
const FaceId INVALID_FACEID
indicates an invalid FaceId
ndn::nfd::FacePersistency getPersistency() const
bool hasRemoteUri() const
const std::string & getLocalUri() const
const std::string & getLocalUri() const
time::steady_clock::TimePoint getExpirationTime() const
uint64_t FaceId
Identifies a face.
generalization of a network interface
ndn::mgmt::PostNotification registerNotificationStream(const std::string &verb)
time::nanoseconds getBaseCongestionMarkingInterval() const
@ FACE_EVENT_UP
face went UP (from DOWN state)
bool allowLocalFields
enables encoding of IncomingFaceId, and decoding of NextHopFaceId and CachePolicy
provides a context for generating response to a StatusDataset request
FaceStatus & setNInInterests(uint64_t nInInterests)
const std::string & getUri() const
@ BIT_LP_RELIABILITY_ENABLED
whether the link reliability feature is enabled on a face
ControlParameters & setFaceId(uint64_t faceId)
static bool matchFilter(const ndn::nfd::FaceQueryFilter &filter, const Face &face)
uint64_t getMtu() const
get MTU (measured in bytes)
static ControlParameters makeCreateFaceResponse(const Face &face)
LinkService * getLinkService() const
FaceStatus & setBaseCongestionMarkingInterval(time::nanoseconds interval)
LinkType getLinkType() const
ChannelStatus & setLocalUri(const std::string localUri)
bool getFlagBit(size_t bit) const
FacePersistency getFacePersistency() const
static void copyFaceProperties(const Face &face, T &to)
Face * get(FaceId id) const
get face by FaceId
const std::string & getRemoteUri() const
FaceStatus & setNOutInterests(uint64_t nOutInterests)
represents an item in NFD Face dataset
A collection of common functions shared by all NFD managers, such as communicating with the dispatche...
represents parameters in a ControlCommand request or response
void add(shared_ptr< Face > face)
add a face
bool hasBaseCongestionMarkingInterval() const
GenericLinkService is a LinkService that implements the NDNLPv2 protocol.
@ FACE_EVENT_CREATED
face was created
const size_t MAX_NDN_PACKET_SIZE
practical limit of network layer packet size
ndn::nfd::FaceScope getScope() const
@ FACE_SCOPE_LOCAL
face is local
ControlParameters & setLocalUri(const std::string &localUri)
bool hasDefaultCongestionThreshold() const
represents a dispatcher on server side of NFD Management protocol
void end()
end the response successfully after appending zero or more blocks
bool isCanonical() const
determine whether this FaceUri is in canonical form
size_t wireEncode(EncodingImpl< TAG > &encoder) const
prepend FaceStatus to the encoder
signal::Signal< FaceTable, Face > beforeRemove
Fires immediately before a face is removed.
ndn::nfd::LinkType getLinkType() const
@ BIT_LOCAL_FIELDS_ENABLED
whether local fields are enabled on a face
Provides ControlCommand authorization according to NFD configuration file.
FaceStatus & setNInData(uint64_t nInData)
FacePersistency getFacePersistency() const
FaceManager(FaceSystem &faceSystem, Dispatcher &dispatcher, CommandAuthenticator &authenticator)
uint64_t getDefaultCongestionThreshold() const
get default congestion threshold (measured in bytes)
NDN_CXX_NODISCARD bool parse(const std::string &uri)
exception-safe parsing
const std::string & getScheme() const
get scheme (protocol)
represents Face Query Filter
#define NFD_LOG_INIT(name)
FaceStatus & setNOutBytes(uint64_t nOutBytes)
FaceStatus & setNOutNacks(uint64_t nOutNacks)
static void updateLinkServiceOptions(Face &face, const ControlParameters ¶meters)
ControlParameters & setBaseCongestionMarkingInterval(time::nanoseconds interval)