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-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 
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
95 {
96  NFD_LOG_FACE_TRACE(__func__);
97 
98  ++this->nInInterests;
99 
100  afterReceiveInterest(interest);
101 }
102 
103 void
105 {
106  NFD_LOG_FACE_TRACE(__func__);
107 
108  ++this->nInData;
109 
110  afterReceiveData(data);
111 }
112 
113 void
115 {
116  NFD_LOG_FACE_TRACE(__func__);
117 
118  ++this->nInNacks;
119 
120  afterReceiveNack(nack);
121 }
122 
123 void
125 {
126  ++this->nDroppedInterests;
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
signal::Signal< LinkService, Data > afterReceiveData
signals on Data received
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_FACE_TRACE(msg)
Log a message at TRACE level.
Definition: face-log.hpp:79
PacketCounter nInInterests
count of incoming Interests
generalization of a network interface
Definition: face.hpp:67
std::ostream & operator<<(std::ostream &os, const Face &face)
Definition: ndn-common.hpp:89
void notifyDroppedInterest(const Interest &packet)
const Face * getFace() const
PacketCounter nInNacks
count of incoming Nacks
Represents an Interest packet.
Definition: interest.hpp:44
FaceUri getLocalUri() const
Definition: face.hpp:257
FaceUri getRemoteUri() const
Definition: face.hpp:263
PacketCounter nDroppedInterests
count of Interests dropped by reliability system for exceeding allowed number of retx
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
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
signal::Signal< LinkService, lp::Nack > afterReceiveNack
signals on Nack received
FaceId getId() const
Definition: face.hpp:233
void receiveNack(const lp::Nack &nack)
delivers received Nack to forwarding
PacketCounter nOutInterests
count of outgoing Interests
signal::Signal< LinkService, Interest > afterSendInterest
signals on Interest sent
PacketCounter nInData
count of incoming Data packets
PacketCounter nOutNacks
count of outgoing Nacks
void receiveData(const Data &data)
delivers received Data to forwarding
void sendNack(const ndn::lp::Nack &nack)
send Nack
void setFaceAndTransport(Face &face, Transport &transport)
set Face and Transport for LinkService
for internal use by FaceLogging macros
Definition: face-log.hpp:43
#define NFD_LOG_INIT(name)
Definition: logger.hpp:31
Represents a Data packet.
Definition: data.hpp:35
the lower part of a Face
Definition: transport.hpp:113
signal::Signal< LinkService, lp::Nack > afterSendNack
signals on Nack sent
signal::Signal< LinkService, Data > afterSendData
signals on Data sent
signal::Signal< LinkService, Interest > afterReceiveInterest
signals on Interest received
void receiveInterest(const Interest &interest)
delivers received Interest to forwarding