1 #ifndef NDNPH_APP_PING_CLIENT_HPP
2 #define NDNPH_APP_PING_CLIENT_HPP
4 #include "../face/packet-handler.hpp"
5 #include "../port/clock/port.hpp"
26 , m_prefix(std::move(prefix))
27 , m_interval(interval)
28 , m_next(port::
Clock::add(port::
Clock::now(), interval)) {
52 StaticRegion<1024> region;
55 Name name = m_prefix.
append(region, seqNumComp);
60 interest.setName(name);
61 interest.setMustBeFresh(
true);
63 if (!
send(interest)) {
70 bool processData(
Data data)
final {
71 const Name& dataName = data.getName();
72 if (!m_prefix.
isPrefixOf(dataName) || m_prefix.
size() + 1 != dataName.size()) {
75 Component lastComp = dataName[-1];
83 if (m_seqNum == seqNum) {
91 uint64_t m_seqNum = 0;
92 int m_interval = 1000;
93 port::Clock::Time m_next;
static bool generate(uint8_t *output, size_t count)
static Component from(Region ®ion, uint16_t type, const Arg &... arg)
Construct from TLV-TYPE, and several arguments to be encoded to TLV-VALUE.
Definition: component.hpp:75
static bool readTlv(Tlv &d, const uint8_t *input, const uint8_t *end)
Definition: decoder.hpp:46
Network layer face.
Definition: face.hpp:12
Name.
Definition: name.hpp:14
size_t size() const
Get number of components.
Definition: name.hpp:86
Name append(Region ®ion, const C &... comps) const
Append a sequence of components.
Definition: name.hpp:183
bool isPrefixOf(const Name &other) const
Determine if this name is a prefix of other.
Definition: name.hpp:239
Base class to receive packets from Face.
Definition: packet-handler.hpp:10
bool send(Region ®ion, const Packet &packet, PacketInfo pi={})
Synchronously transmit a packet.
Definition: packet-handler.hpp:49
Periodically transmit Interests to test reachability.
Definition: ping-client.hpp:16
Counters readCounters() const
Definition: ping-client.hpp:37
PingClient(Name prefix, Face &face, int interval=1000)
Constructor.
Definition: ping-client.hpp:24
static bool isBefore(Time a, Time b)
Definition: ino.hpp:42
static Time now()
Definition: ino.hpp:21
static Time add(Time t, int ms)
Definition: ino.hpp:27
static bool decode(const Decoder::Tlv &d, T &value)
Definition: nni.hpp:14
#define NDNPH_ASSERT(x)
Definition: common.hpp:30
@ Interest
Definition: an.hpp:30
@ Name
Definition: an.hpp:19
@ GenericNameComponent
Definition: an.hpp:20
@ Data
Definition: an.hpp:41
port_clock_ino::Clock Clock
Definition: ino.hpp:59
detail::NNIValue< uint64_t > NNI8
8-byte number encoding.
Definition: nni.hpp:115
Definition: ping-client.hpp:32
uint32_t nTxInterests
Definition: ping-client.hpp:33
uint32_t nRxData
Definition: ping-client.hpp:34