NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
dummy-client-face.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_UTIL_DUMMY_CLIENT_FACE_HPP
23 #define NDN_UTIL_DUMMY_CLIENT_FACE_HPP
24 
25 #include "../face.hpp"
26 #include "signal.hpp"
27 #include "../security/key-chain.hpp"
28 
29 namespace ndn {
30 namespace util {
31 
34 class DummyClientFace : public ndn::Face
35 {
36 public:
39  class Options
40  {
41  public:
43  const std::function<void(time::milliseconds)>& processEventsOverride)
44  : enablePacketLogging(enablePacketLogging)
45  , enableRegistrationReply(enableRegistrationReply)
47  {
48  }
49 
50  Options(bool enablePacketLogging, bool enableRegistrationReply)
51  : Options(enablePacketLogging, enableRegistrationReply, nullptr)
52  {
53  }
54 
56  : Options(true, false)
57  {
58  }
59 
60  public:
64 
69 
72  std::function<void(time::milliseconds)> processEventsOverride;
73  };
74 
77  explicit
78  DummyClientFace(const Options& options = Options());
79 
82  explicit
83  DummyClientFace(KeyChain& keyChain, const Options& options = Options());
84 
87  explicit
88  DummyClientFace(boost::asio::io_service& ioService, const Options& options = Options());
89 
92  DummyClientFace(boost::asio::io_service& ioService, KeyChain& keyChain,
93  const Options& options = Options());
94 
98  template<typename Packet>
99  void
100  receive(const Packet& packet);
101 
102 private:
103  class Transport;
104 
105  void
106  construct(const Options& options);
107 
108  void
110 
111  void
113 
114  virtual void
115  doProcessEvents(const time::milliseconds& timeout, bool keepThread) override;
116 
117 public:
124  std::vector<Interest> sentInterests;
125 
132  std::vector<Data> sentData;
133 
140  std::vector<lp::Nack> sentNacks;
141 
147 
153 
159 
160 private:
161  std::unique_ptr<KeyChain> m_internalKeyChain;
162  KeyChain& m_keyChain;
163  std::function<void(time::milliseconds)> m_processEventsOverride;
164 };
165 
166 template<>
167 void
169 
170 } // namespace util
171 } // namespace ndn
172 
173 #endif // NDN_UTIL_DUMMY_CLIENT_FACE_HPP
bool enableRegistrationReply
if true, prefix registration command will be automatically replied with a successful response ...
std::vector< lp::Nack > sentNacks
Nacks sent out of this DummyClientFace.
Copyright (c) 2011-2015 Regents of the University of California.
Signal< DummyClientFace, Interest > onSendInterest
emits whenever an Interest is sent
std::vector< Interest > sentInterests
Interests sent out of this DummyClientFace.
The packet signing interface.
Definition: key-chain.hpp:47
std::vector< Data > sentData
Data sent out of this DummyClientFace.
provides a lightweight signal / event system
represents a Network Nack
Definition: nack.hpp:40
options for DummyClientFace
DummyClientFace(const Options &options=Options())
Create a dummy face with internal IO service.
Signal< DummyClientFace, lp::Nack > onSendNack
emits whenever a Nack is sent
Provide a communication channel with local or remote NDN forwarder.
Definition: face.hpp:125
Signal< DummyClientFace, Data > onSendData
emits whenever a Data packet is sent
a client-side face for unit testing
Options(bool enablePacketLogging, bool enableRegistrationReply)
void receive(const Packet &packet)
cause the Face to receive a packet
Options(bool enablePacketLogging, bool enableRegistrationReply, const std::function< void(time::milliseconds)> &processEventsOverride)
bool enablePacketLogging
if true, packets sent out of DummyClientFace will be appended to a container
std::function< void(time::milliseconds)> processEventsOverride
if not empty, face.processEvents() will be overridden by this function