blob: fb783120f05e9fc7bcd870325144e92f5fb0f9ca [file] [log] [blame]
Eric Newberry608211e2017-11-27 21:59:37 -07001/*
2 * Consumer for CongestionMark test (test_congestionmark)
3 *
4 * Sends an Interest for a specified prefix and prints the returned congestion mark (or whether
5 * there was a Nack or Timeout).
6 *
7 * Author: Eric Newberry <enewberry@cs.arizona.edu>
8 *
9 * Based on ndn-cxx example consumer
10 */
11
12#include <ndn-cxx/data.hpp>
13#include <ndn-cxx/face.hpp>
14#include <ndn-cxx/interest.hpp>
15#include <ndn-cxx/lp/nack.hpp>
16
17using namespace ndn;
18
19class TestCongestionMarkConsumer
20{
21public:
22 void
23 run(Name name)
24 {
25 Interest interest(name);
26
27 m_face.expressInterest(interest,
28 [] (const Interest& interest, const Data& data) {
29 std::cout << "CongestionMark=" << data.getCongestionMark() << std::endl;
30 },
31 [] (const Interest& interest, const lp::Nack& nack) {
32 std::cout << "Nack" << std::endl;
33 },
34 [] (const Interest& interest) {
35 std::cout << "Timeout" << std::endl;
36 });
37 m_face.processEvents();
38 }
39
40private:
41 Face m_face;
42};
43
44int
45main(int argc, char** argv)
46{
47 if (argc != 2) {
48 return 2;
49 }
50
51 try {
52 TestCongestionMarkConsumer consumer;
53 consumer.run(Name(argv[1]));
54 }
55 catch (const std::exception& e) {
56 std::cerr << "ERROR: " << e.what() << std::endl;
57 return 1;
58 }
59
60 return 0;
61}