NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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; -*- */
26 #include "link-service.hpp"
27 #include "face.hpp"
28 
29 namespace nfd {
30 namespace face {
31 
32 NFD_LOG_INIT("LinkService");
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 std::ostream&
124 operator<<(std::ostream& os, const FaceLogHelper<LinkService>& flh)
125 {
126  const Face* face = flh.obj.getFace();
127  if (face == nullptr) {
128  os << "[id=0,local=unknown,remote=unknown] ";
129  }
130  else {
131  os << "[id=" << face->getId() << ",local=" << face->getLocalUri()
132  << ",remote=" << face->getRemoteUri() << "] ";
133  }
134  return os;
135 }
136 
137 } // namespace face
138 } // namespace nfd
signal::Signal< LinkService, Data > afterReceiveData
signals on Data received
FaceUri getLocalUri() const
Definition: face.hpp:253
void sendInterest(const Interest &interest)
send Interest
PacketCounter nOutData
count of outgoing Data
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
PacketCounter nInNacks
count of incoming Nacks
represents an Interest packet
Definition: interest.hpp:42
FaceUri getRemoteUri() const
Definition: face.hpp:259
represents a Network Nack
Definition: nack.hpp:40
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
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
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
#define NFD_LOG_INIT(name)
Definition: logger.hpp:34
Represents a Data packet.
Definition: data.hpp:35
the lower part of a Face
Definition: transport.hpp:104
signal::Signal< LinkService, lp::Nack > afterSendNack
signals on Nack sent
signal::Signal< LinkService, Data > afterSendData
signals on Data sent
FaceId getId() const
Definition: face.hpp:229
signal::Signal< LinkService, Interest > afterReceiveInterest
signals on Interest received
void receiveInterest(const Interest &interest)
delivers received Interest to forwarding