NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
link-service.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2020, 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 
26 #include "link-service.hpp"
27 #include "face.hpp"
28 
29 namespace nfd {
30 namespace face {
31 
33 
35  : m_face(nullptr)
36  , m_transport(nullptr)
37 {
38 }
39 
41 {
42 }
43 
44 void
46 {
47  BOOST_ASSERT(m_face == nullptr);
48  BOOST_ASSERT(m_transport == nullptr);
49 
50  m_face = &face;
51  m_transport = &transport;
52 }
53 
54 void
56 {
57  BOOST_ASSERT(m_transport != nullptr);
58  NFD_LOG_FACE_TRACE(__func__);
59 
60  ++this->nOutInterests;
61 
62  doSendInterest(interest);
63 
64  afterSendInterest(interest);
65 }
66 
67 void
69 {
70  BOOST_ASSERT(m_transport != nullptr);
71  NFD_LOG_FACE_TRACE(__func__);
72 
73  ++this->nOutData;
74 
75  doSendData(data);
76 
77  afterSendData(data);
78 }
79 
80 void
82 {
83  BOOST_ASSERT(m_transport != nullptr);
84  NFD_LOG_FACE_TRACE(__func__);
85 
86  ++this->nOutNacks;
87 
88  doSendNack(nack);
89 
90  afterSendNack(nack);
91 }
92 
93 void
94 LinkService::receiveInterest(const Interest& interest, const EndpointId& endpoint)
95 {
96  NFD_LOG_FACE_TRACE(__func__);
97 
98  ++this->nInInterests;
99 
100  afterReceiveInterest(interest, endpoint);
101 }
102 
103 void
104 LinkService::receiveData(const Data& data, const EndpointId& endpoint)
105 {
106  NFD_LOG_FACE_TRACE(__func__);
107 
108  ++this->nInData;
109 
110  afterReceiveData(data, endpoint);
111 }
112 
113 void
114 LinkService::receiveNack(const ndn::lp::Nack& nack, const EndpointId& endpoint)
115 {
116  NFD_LOG_FACE_TRACE(__func__);
117 
118  ++this->nInNacks;
119 
120  afterReceiveNack(nack, endpoint);
121 }
122 
123 void
125 {
126  ++this->nInterestsExceededRetx;
127  onDroppedInterest(interest);
128 }
129 
130 std::ostream&
131 operator<<(std::ostream& os, const FaceLogHelper<LinkService>& flh)
132 {
133  const Face* face = flh.obj.getFace();
134  if (face == nullptr) {
135  os << "[id=0,local=unknown,remote=unknown] ";
136  }
137  else {
138  os << "[id=" << face->getId() << ",local=" << face->getLocalUri()
139  << ",remote=" << face->getRemoteUri() << "] ";
140  }
141  return os;
142 }
143 
144 } // namespace face
145 } // namespace nfd
void sendInterest(const Interest &interest)
Send Interest.
the upper part of a Face
PacketCounter nOutData
count of outgoing Data packets
void sendData(const Data &data)
Send Data.
#define NFD_LOG_INIT(name)
Definition: logger.hpp:31
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
PacketCounter nInInterests
count of incoming Interests
void notifyDroppedInterest(const Interest &packet)
PacketCounter nInterestsExceededRetx
count of Interests dropped by reliability system for exceeding allowed number of retx ...
PacketCounter nInNacks
count of incoming Nacks
Represents an Interest packet.
Definition: interest.hpp:48
uint64_t EndpointId
Identifies a remote endpoint on the link.
Definition: face-common.hpp:71
signal::Signal< LinkService, lp::Nack, EndpointId > afterReceiveNack
signals on Nack received
signal::Signal< LinkService, Interest > onDroppedInterest
signals on Interest dropped by reliability system for exceeding allowed number of retx ...
represents a Network Nack
Definition: nack.hpp:38
ndn Face
Definition: face-impl.hpp:42
void receiveInterest(const Interest &interest, const EndpointId &endpoint)
delivers received Interest to forwarding
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:39
signal::Signal< LinkService, Interest, EndpointId > afterReceiveInterest
signals on Interest received
PacketCounter nOutInterests
count of outgoing Interests
signal::Signal< LinkService, Interest > afterSendInterest
signals on Interest sent
signal::Signal< LinkService, Data, EndpointId > afterReceiveData
signals on Data received
PacketCounter nInData
count of incoming Data packets
void receiveNack(const lp::Nack &nack, const EndpointId &endpoint)
delivers received Nack to forwarding
PacketCounter nOutNacks
count of outgoing Nacks
void sendNack(const ndn::lp::Nack &nack)
Send Nack.
void setFaceAndTransport(Face &face, Transport &transport)
set Face and Transport for LinkService
Represents a Data packet.
Definition: data.hpp:37
The lower half of a Face.
Definition: transport.hpp:108
signal::Signal< LinkService, lp::Nack > afterSendNack
signals on Nack sent
signal::Signal< LinkService, Data > afterSendData
signals on Data sent
void receiveData(const Data &data, const EndpointId &endpoint)
delivers received Data to forwarding