Changes to support ndn-cpp-dev -> ndn-cxx renaming and adding quiet
logging option (-q)
Change-Id: Ifd28ec81d49e75191abd25788ef35c2125d456b1
diff --git a/src/ndn-traffic-client.cpp b/src/ndn-traffic-client.cpp
index 011c5e1..3cc2aac 100644
--- a/src/ndn-traffic-client.cpp
+++ b/src/ndn-traffic-client.cpp
@@ -7,25 +7,26 @@
* Author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
*/
-#include <string>
-#include <sstream>
#include <fstream>
+#include <sstream>
+#include <string>
#include <vector>
+#include <boost/asio.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/noncopyable.hpp>
+
+#include <ndn-cxx/exclude.hpp>
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/name-component.hpp>
+
#include "logger.hpp"
-#include <boost/asio.hpp>
-#include <boost/filesystem.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
-
-#include <ndn-cpp-dev/face.hpp>
-#include <ndn-cpp-dev/exclude.hpp>
-#include <ndn-cpp-dev/name-component.hpp>
-
namespace ndn {
-class NdnTrafficClient
+class NdnTrafficClient : boost::noncopyable
{
public:
@@ -34,6 +35,7 @@
: m_programName(programName)
, m_logger("NdnTrafficClient")
, m_hasError(false)
+ , m_hasQuietLogging(false)
, m_ioService(new boost::asio::io_service)
, m_face(m_ioService)
, m_interestInterval(getDefaultInterestInterval())
@@ -260,6 +262,7 @@
" [-i interval] - set interest generation interval in milliseconds (default "
<< getDefaultInterestInterval() << ")\n"
" [-c count] - set total number of interests to be generated\n"
+ " [-q] - quiet logging - no interest generation/data reception messages\n"
" [-h] - print help and exit\n\n";
exit(1);
}
@@ -293,6 +296,12 @@
}
void
+ setQuietLogging()
+ {
+ m_hasQuietLogging = true;
+ }
+
+ void
signalHandler()
{
logStatistics();
@@ -542,7 +551,8 @@
}
else
logLine += ", IsConsistent=NotChecked";
- m_logger.log(logLine, true, false);
+ if (!m_hasQuietLogging)
+ m_logger.log(logLine, true, false);
double roundTripTime = (time::steady_clock::now() - sentTime).count() / 1000000.0;
if (m_minimumInterestRoundTripTime > roundTripTime)
m_minimumInterestRoundTripTime = roundTripTime;
@@ -709,7 +719,8 @@
logLine += ", LocalID=" + boost::lexical_cast<std::string>(
m_trafficPatterns[patternId].m_nInterestsSent);
logLine += ", Name="+interest.getName().toUri();
- m_logger.log(logLine, true, false);
+ if (!m_hasQuietLogging)
+ m_logger.log(logLine, true, false);
deadlineTimer->expires_at(deadlineTimer->expires_at() +
boost::posix_time::millisec(
m_interestInterval.count()));
@@ -769,6 +780,7 @@
std::string m_programName;
std::string m_instanceId;
bool m_hasError;
+ bool m_hasQuietLogging;
time::milliseconds m_interestInterval;
int m_nMaximumInterests;
Logger m_logger;
@@ -797,7 +809,7 @@
std::srand(std::time(0));
ndn::NdnTrafficClient ndnTrafficClient (argv[0]);
int option;
- while ((option = getopt(argc, argv, "hi:c:")) != -1) {
+ while ((option = getopt(argc, argv, "hqi:c:")) != -1) {
switch (option) {
case 'h':
ndnTrafficClient.usage();
@@ -808,6 +820,9 @@
case 'c':
ndnTrafficClient.setMaximumInterests(atoi(optarg));
break;
+ case 'q':
+ ndnTrafficClient.setQuietLogging();
+ break;
default:
ndnTrafficClient.usage();
break;
diff --git a/src/ndn-traffic-server.cpp b/src/ndn-traffic-server.cpp
index ff56fe0..916b0e4 100644
--- a/src/ndn-traffic-server.cpp
+++ b/src/ndn-traffic-server.cpp
@@ -8,18 +8,20 @@
*/
#include <sstream>
+
#include <boost/asio.hpp>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/noncopyable.hpp>
-#include <ndn-cpp-dev/face.hpp>
-#include <ndn-cpp-dev/security/key-chain.hpp>
+#include <ndn-cxx/face.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
#include "logger.hpp"
namespace ndn {
-class NdnTrafficServer
+class NdnTrafficServer : boost::noncopyable
{
public:
@@ -28,6 +30,7 @@
: m_logger("NdnTrafficServer")
, m_programName(programName)
, m_hasError(false)
+ , m_hasQuietLogging(false)
, m_nRegistrationsFailed(0)
, m_nMaximumInterests(-1)
, m_nInterestsReceived(0)
@@ -162,6 +165,7 @@
"Set environment variable NDN_TRAFFIC_LOGFOLDER for redirecting output to a log.\n"
" [-d interval] - set delay before responding to interest in milliseconds\n"
" [-c count] - specify maximum number of interests to be satisfied\n"
+ " [-q] - quiet logging - no interest reception/data generation messages\n"
" [-h] - print help and exit\n\n";
exit(1);
@@ -196,6 +200,12 @@
}
void
+ setQuietLogging()
+ {
+ m_hasQuietLogging = true;
+ }
+
+ void
signalHandler()
{
logStatistics();
@@ -368,7 +378,8 @@
logLine += ", LocalID=" +
boost::lexical_cast<std::string>(m_trafficPatterns[patternId].m_nInterestsReceived);
logLine += ", Name=" + m_trafficPatterns[patternId].m_name;
- m_logger.log(logLine, true, false);
+ if (!m_hasQuietLogging)
+ m_logger.log(logLine, true, false);
if (m_trafficPatterns[patternId].m_contentDelay > time::milliseconds(-1))
usleep(m_trafficPatterns[patternId].m_contentDelay.count() * 1000);
if (m_contentDelay > time::milliseconds(-1))
@@ -440,6 +451,7 @@
KeyChain m_keyChain;
std::string m_programName;
bool m_hasError;
+ bool m_hasQuietLogging;
std::string m_instanceId;
time::milliseconds m_contentDelay;
int m_nRegistrationsFailed;
@@ -460,7 +472,7 @@
std::srand(std::time(0));
ndn::NdnTrafficServer ndnTrafficServer(argv[0]);
int option;
- while ((option = getopt(argc, argv, "hc:d:")) != -1) {
+ while ((option = getopt(argc, argv, "hqc:d:")) != -1) {
switch (option) {
case 'h':
ndnTrafficServer.usage();
@@ -471,6 +483,9 @@
case 'd':
ndnTrafficServer.setContentDelay(atoi(optarg));
break;
+ case 'q':
+ ndnTrafficServer.setQuietLogging();
+ break;
default:
ndnTrafficServer.usage();
break;