Changes to support ndn-cpp-dev -> ndn-cxx renaming and adding quiet
logging option (-q)
Change-Id: Ifd28ec81d49e75191abd25788ef35c2125d456b1
diff --git a/README.md b/README.md
index 118fdf6..0cc48b8 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
Traffic Generator For NDN (ndn-traffic-generator)
=================================================
-This tool is designed to generate interest and data traffic in an NDN network.
+This tool is designed to generate Interest and Data traffic in an NDN network.
The client and server tool accept traffic configuration files which can be
used to specify the pattern of NDN traffic that is required to be generated.
Sample configuration files are provided which include instructions on how
@@ -13,34 +13,34 @@
1. C++ Boost Libraries version >= 1.48 <http://www.boost.org>
-On Ubuntu 12.04:
+ On Ubuntu 12.04:
- sudo apt-get install libboost1.48-all-dev
+ sudo apt-get install libboost1.48-all-dev
-On Ubuntu 13.10 and later
+ On Ubuntu 13.10 and later
- sudo apt-get install libboost-all-dev
+ sudo apt-get install libboost-all-dev
-On OSX with macports
+ On OSX with macports
- sudo port install boost
+ sudo port install boost
-On OSX with brew
+ On OSX with brew
- brew install boost
+ brew install boost
On other platforms Boost Libraries can be installed from the packaged version for the
distribution, if the version matches requirements, or compiled from source
-2. ndn-cpp-dev library <https://github.com/named-data/ndn-cpp-dev>
+2. ndn-cxx library <https://github.com/named-data/ndn-cxx>
-For detailed installation instructions, please refer README file
+ For detailed installation instructions, please refer README file
3. NDN forwarding daemon <https://github.com/named-data/NFD>
-----------------------------------------------------
-## 1. Compile And Installation Instructions: ##
+## 1. Compile & Installation Instructions: ##
./waf configure
./waf
@@ -48,21 +48,23 @@
## 2. Tool Run Instructions & Command Line Options: ##
- Usage: ndntrafficserver [options] <Traffic_Configuration_File>
- Respond to Interest as per provided Traffic Configuration File
- Multiple Prefixes can be configured for handling.
+ Usage: ndn-traffic-server [options] <traffic_configuration_file>
+ Respond to Interest as per provided traffic configuration file
+ Multiple prefixes can be configured for handling.
Set environment variable NDN_TRAFFIC_LOGFOLDER for redirecting output to a log.
[-d interval] - set delay before responding to interest in milliseconds
[-c count] - specify maximum number of interests to be satisfied
- [-h] - print help and exit
+ [-q] - quiet logging - no interest reception/data generation messages
+ [-h] - print help and exit
- Usage: ndntraffic [options] <Traffic_Configuration_File>
- Generate Interest Traffic as per provided Traffic Configuration File
+ Usage: ndn-traffic [options] <traffic_configuration_file>
+ Generate Interest traffic as per provided traffic configuration file
Interests are continuously generated unless a total number is specified.
Set environment variable NDN_TRAFFIC_LOGFOLDER for redirecting output to a log.
[-i interval] - set interest generation interval in milliseconds (default 1000 milliseconds)
- [-c count] - set total number of interests to be generated
- [-h] - print help and exit
+ [-c count] - set total number of interests to be generated
+ [-q] - quiet logging - no interest reception/data generation messages
+ [-h] - print help and exit
## 3. Sample Run Instructions ##
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;
diff --git a/wscript b/wscript
index 946b472..c421719 100644
--- a/wscript
+++ b/wscript
@@ -1,28 +1,28 @@
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
VERSION='0.1'
-NAME="ndn-traffic-generator"
+APPNAME="ndn-traffic-generator"
def options(opt):
opt.load('compiler_cxx gnu_dirs')
def configure(conf):
conf.load("compiler_cxx gnu_dirs")
- conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'],
- uselib_store='NDN_CPP', mandatory=True)
+ conf.check_cfg(package='libndn-cxx', args=['--cflags', '--libs'],
+ uselib_store='NDN_CXX', mandatory=True)
-def build (bld):
- bld.program (
- features = 'cxx',
- target = 'ndn-traffic',
- source = 'src/ndn-traffic-client.cpp',
- use = 'NDN_CPP',
+def build(bld):
+ bld.program(
+ features='cxx',
+ target='ndn-traffic',
+ source='src/ndn-traffic-client.cpp',
+ use='NDN_CXX',
)
- bld.program (
- features = 'cxx',
- target = 'ndn-traffic-server',
- source = 'src/ndn-traffic-server.cpp',
- use = 'NDN_CPP',
+ bld.program(
+ features='cxx',
+ target='ndn-traffic-server',
+ source='src/ndn-traffic-server.cpp',
+ use='NDN_CXX',
)
bld.install_files('${SYSCONFDIR}/ndn', ['ndn-traffic-client.conf.sample',