| /* |
| * Consumer for CongestionMark test (test_congestionmark) |
| * |
| * Sends an Interest for a specified prefix and prints the returned congestion mark (or whether |
| * there was a Nack or Timeout). |
| * |
| * Author: Eric Newberry <enewberry@cs.arizona.edu> |
| * |
| * Based on ndn-cxx example consumer |
| */ |
| |
| #include <ndn-cxx/data.hpp> |
| #include <ndn-cxx/face.hpp> |
| #include <ndn-cxx/interest.hpp> |
| #include <ndn-cxx/lp/nack.hpp> |
| |
| #include <iostream> |
| |
| using namespace ndn; |
| |
| class TestCongestionMarkConsumer |
| { |
| public: |
| void |
| run(Name name) |
| { |
| Interest interest(name); |
| |
| m_face.expressInterest(interest, |
| [] (const Interest& interest, const Data& data) { |
| std::cout << "CongestionMark=" << data.getCongestionMark() << std::endl; |
| }, |
| [] (const Interest& interest, const lp::Nack& nack) { |
| std::cout << "Nack" << std::endl; |
| }, |
| [] (const Interest& interest) { |
| std::cout << "Timeout" << std::endl; |
| }); |
| m_face.processEvents(); |
| } |
| |
| private: |
| Face m_face; |
| }; |
| |
| int |
| main(int argc, char** argv) |
| { |
| if (argc != 2) { |
| return 2; |
| } |
| |
| try { |
| TestCongestionMarkConsumer consumer; |
| consumer.run(Name(argv[1])); |
| } |
| catch (const std::exception& e) { |
| std::cerr << "ERROR: " << e.what() << std::endl; |
| return 1; |
| } |
| |
| return 0; |
| } |