Add Congestion Mark scenario
refs #4327
Change-Id: Iabbbe241585378e77d792c74d005a22b0d1440c5
diff --git a/install_helpers/tools/test-congestionmark-consumer.cpp b/install_helpers/tools/test-congestionmark-consumer.cpp
new file mode 100644
index 0000000..fb78312
--- /dev/null
+++ b/install_helpers/tools/test-congestionmark-consumer.cpp
@@ -0,0 +1,61 @@
+/*
+ * 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>
+
+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;
+}