30 #include <boost/asio/io_service.hpp> 74 std::vector<DummyClientFace*>
faces;
78 :
Error(
"Face has already been linked to another face")
87 this->construct(options);
94 this->construct(options);
102 this->construct(options);
109 this->construct(options);
118 DummyClientFace::construct(
const Options& options)
122 lp::Packet lpPacket(packet);
123 auto frag = lpPacket.get<lp::FragmentField>();
124 Block block({frag.first, frag.second});
127 auto interest = make_shared<Interest>(block);
129 auto nack = make_shared<lp::Nack>(
std::move(*interest));
131 addTagFromField<lp::CongestionMarkTag, lp::CongestionMarkField>(*nack, lpPacket);
135 addTagFromField<lp::NextHopFaceIdTag, lp::NextHopFaceIdField>(*interest, lpPacket);
136 addTagFromField<lp::CongestionMarkTag, lp::CongestionMarkField>(*interest, lpPacket);
141 auto data = make_shared<Data>(block);
142 addTagFromField<lp::CachePolicyTag, lp::CachePolicyField>(*data, lpPacket);
143 addTagFromField<lp::CongestionMarkTag, lp::CongestionMarkField>(*data, lpPacket);
149 this->enablePacketLogging();
156 enableBroadcastLink();
160 DummyClientFace::enableBroadcastLink()
165 if (otherFace != this) {
166 otherFace->receive(interest);
174 if (otherFace != this) {
175 otherFace->receive(data);
183 if (otherFace != this) {
184 otherFace->receive(nack);
192 DummyClientFace::enablePacketLogging()
206 DummyClientFace::enableRegistrationReply(uint64_t faceId)
209 static const Name localhostRibPrefix(
"/localhost/nfd/rib");
222 if (!params.
hasCost() &&
name[3] == registerVerb) {
230 shared_ptr<Data> data = make_shared<Data>(
name);
242 addFieldFromTag<lp::IncomingFaceIdField, lp::IncomingFaceIdTag>(lpPacket, interest);
243 addFieldFromTag<lp::NextHopFaceIdField, lp::NextHopFaceIdTag>(lpPacket, interest);
244 addFieldFromTag<lp::CongestionMarkField, lp::CongestionMarkTag>(lpPacket, interest);
246 static_pointer_cast<
Transport>(getTransport())->
receive(lpPacket.wireEncode());
254 addFieldFromTag<lp::IncomingFaceIdField, lp::IncomingFaceIdTag>(lpPacket, data);
255 addFieldFromTag<lp::CongestionMarkField, lp::CongestionMarkTag>(lpPacket, data);
257 static_pointer_cast<
Transport>(getTransport())->
receive(lpPacket.wireEncode());
268 addFieldFromTag<lp::IncomingFaceIdField, lp::IncomingFaceIdTag>(lpPacket, nack);
269 addFieldFromTag<lp::CongestionMarkField, lp::CongestionMarkTag>(lpPacket, nack);
271 static_pointer_cast<
Transport>(getTransport())->
receive(lpPacket.wireEncode());
void pause() final
Pause the transport, canceling all pending operations.
bool enableRegistrationReply
if true, prefix registration command will be automatically replied with a successful response ...
ControlParameters & setFaceId(uint64_t faceId)
std::vector< lp::Nack > sentNacks
Nacks sent out of this DummyClientFace.
Copyright (c) 2011-2015 Regents of the University of California.
virtual void doProcessEvents(time::milliseconds timeout, bool keepThread)
Signal< DummyClientFace, Interest > onSendInterest
emits whenever an Interest is sent
represents parameters in a ControlCommand request or response
std::vector< Interest > sentInterests
Interests sent out of this DummyClientFace.
Packet & add(const typename FIELD::ValueType &value)
add a FIELD with value
bool isPrefixOf(const Name &other) const
Check if this name is a prefix of another name.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
void close() final
Close the connection.
DummyIoService & getIoService()
std::vector< DummyClientFace * > faces
~DummyClientFace() override
Represents a TLV element of the NDN packet format.
Represents an Interest packet.
const Block & wireEncode() const
Use a SHA-256 digest only, no signer needs to be specified.
const NackHeader & getHeader() const
std::vector< Data > sentData
Data sent out of this DummyClientFace.
ReceiveCallback m_receiveCallback
provides a lightweight signal / event system
void resume() final
Resume the transport.
Signing parameters passed to KeyChain.
std::function< void(time::milliseconds)> m_processEventsOverride
represents a Network Nack
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.
Signal< DummyClientFace, Data > onSendData
emits whenever a Data packet is sent
void unlink()
unlink the broadcast media if previously linked
Represents an absolute name.
void receive(const Interest &interest)
cause the Face to receive an interest
shared_ptr< BroadcastLink > m_bcastLink
void linkTo(DummyClientFace &other)
link another DummyClientFace through a broadcast media
Provides TLV-block delivery service.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Prepend wire encoding to encoder.
A client-side face for unit testing.
ControlParameters & setCost(uint64_t cost)
Represents a name component.
ControlResponse & setBody(const Block &body)
void encode()
Encode sub-elements into TLV-VALUE.
const Name & getName() const noexcept
size_t wireEncode(EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const
Prepend wire encoding to encoder.
ControlParameters & setOrigin(RouteOrigin origin)
void send(const Block &block) final
Send a TLV block through the transport.
virtual void connect(ReceiveCallback receiveCallback)
Asynchronously open the connection.
uint64_t registrationReplyFaceId
FaceId used in prefix registration replies.
Represents a Data packet.
std::unique_ptr< KeyChain > m_internalKeyChain
ControlResponse & setCode(uint32_t code)
Signal< Transport, Block > onSendBlock
const Interest & getInterest() const
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
void receive(Block block) const
boost::chrono::milliseconds milliseconds