doc+src: More reorganization and fixing of README
Change-Id: I8ff2dcdabd78f38cc0d5b826883121a9444ef664
This commit is contained in:
@@ -1,37 +1,51 @@
|
||||
Traffic Generator For NDN (ndn-traffic)
|
||||
=======================================
|
||||
Traffic Generator For NDN (ndn-traffic-generator)
|
||||
=================================================
|
||||
|
||||
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
|
||||
to configure various parameters.
|
||||
Sample configuration files are provided which include instructions on how
|
||||
to configure various parameters.
|
||||
|
||||
This is an application tool developed over ndn-cpp APIs for TLV packet
|
||||
based communication over NDN configured network. The NDN network has to
|
||||
be first created with 'ndnx' and 'ndnd-tlv'. This is followed by environment
|
||||
security setup with 'ndn-cpp-security-tools'. The application also requires
|
||||
installation of ndn-cpp and CPP boost libraries. The installations need to
|
||||
follow a strict order as the ndnd
|
||||
## Prerequisites ##
|
||||
|
||||
To run the following must be ensured(FOLLOW ORDER STRICTLY)
|
||||
Compiling and running ndn-traffic-generator requires the following dependencies:
|
||||
|
||||
1. Install ndnx (install all necessary dependencies)
|
||||
2. Install CPP Boost Library > 1.47
|
||||
1. C++ Boost Libraries version >= 1.48
|
||||
|
||||
On Ubuntu 12.04:
|
||||
|
||||
sudo apt-get install libboost1.48-all-dev
|
||||
|
||||
3. Install ndn-cpp-dev (install all necessary dependencies except boost)
|
||||
4. Install ndnd-tlv install all necessary dependencies except boost)
|
||||
5. Install and Configure Security Environment with ndn-cpp-security-tools
|
||||
On Ubuntu 13.10 and later
|
||||
|
||||
sudo apt-get install libboost-all-dev
|
||||
|
||||
On OSX with macports
|
||||
|
||||
sudo port install boost
|
||||
|
||||
On OSX with brew
|
||||
|
||||
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
|
||||
(http://www.boost.org)
|
||||
|
||||
2. ndn-cpp-dev library (https://github.com/named-data/ndn-cpp-dev)
|
||||
|
||||
For detailed installation instructions refer to
|
||||
https://github.com/named-data/ndn-cpp-dev/blob/master/INSTALL.md and/or
|
||||
https://github.com/named-data/ndn-cpp-dev
|
||||
|
||||
3. NDN forwarding daemon (https://github.com/named-data/NFD)
|
||||
|
||||
-----------------------------------------------------
|
||||
|
||||
## 1. Compile And Installation Instructions: ##
|
||||
|
||||
git clone git://github.com/jeraldabraham/ndn-traffic ndn-traffic
|
||||
cd ndn-traffic
|
||||
./waf configure
|
||||
./waf configure
|
||||
./waf
|
||||
sudo ./waf install
|
||||
|
||||
@@ -57,26 +71,21 @@ To run the following must be ensured(FOLLOW ORDER STRICTLY)
|
||||
|
||||
__ON MACHINE #1__
|
||||
|
||||
Start the ndnd-tlv daemon
|
||||
|
||||
ndnd-tlv-start
|
||||
(NDN forwarding daemon should be running)
|
||||
|
||||
Start traffic server
|
||||
|
||||
ndntrafficserver NDNTrafficServer.conf
|
||||
ndn-traffic-server ndn-traffic-server.conf
|
||||
|
||||
__ON MACHINE #2__
|
||||
|
||||
Start the ndnd-tlv daemon
|
||||
|
||||
ndnd-tlv-start
|
||||
(NDN forwarding daemon should be running)
|
||||
|
||||
Start the traffic client
|
||||
|
||||
ndntraffic NDNTrafficClient.conf
|
||||
|
||||
ndn-traffic ndn-traffic-client.conf
|
||||
|
||||
|
||||
* These tools need not be used together and can be used individually as well.
|
||||
* Please refer sample configuration files provided for details on how to create your own.
|
||||
* Use command line options shown above to adjust traffic configuration.
|
||||
|
||||
|
||||
@@ -47,3 +47,4 @@ TrafficPercentage=50
|
||||
Name=/example/B
|
||||
ExpectedContent=BBBBBBBB
|
||||
##########
|
||||
|
||||
@@ -33,3 +33,4 @@ Content=AAAAAAAA
|
||||
Name=/example/B
|
||||
Content=BBBBBBBB
|
||||
##########
|
||||
|
||||
@@ -84,14 +84,16 @@ public:
|
||||
std::cout << "Log File Initialized: " << logFilename << std::endl;
|
||||
else
|
||||
{
|
||||
std::cout << "ERROR - Unable To Initialize A Log File At: " << m_logLocation << std::endl
|
||||
std::cout << "ERROR - Unable To Initialize A Log File At: "
|
||||
<< m_logLocation << std::endl
|
||||
<< "Using Default Output For Logging." << std::endl;
|
||||
m_logLocation = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Environment Variable NDN_TRAFFIC_LOGFOLDER Should Be A Folder." << std::endl
|
||||
std::cout << "Environment Variable NDN_TRAFFIC_LOGFOLDER Should Be A Folder."
|
||||
<< std::endl
|
||||
<< "Using Default Output For Logging." << std::endl;
|
||||
m_logLocation = "";
|
||||
}
|
||||
@@ -28,8 +28,7 @@ namespace ndn {
|
||||
class NdnTrafficClient
|
||||
{
|
||||
public:
|
||||
|
||||
NdnTrafficClient( char* programName )
|
||||
NdnTrafficClient(char* programName)
|
||||
: m_logger("NDNTrafficClient")
|
||||
, ioService_(new boost::asio::io_service)
|
||||
, face_(ioService_)
|
||||
@@ -51,7 +50,6 @@ public:
|
||||
class InterestTrafficConfiguration
|
||||
{
|
||||
public:
|
||||
|
||||
InterestTrafficConfiguration()
|
||||
{
|
||||
trafficPercentage = -1;
|
||||
@@ -79,7 +77,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
printTrafficConfiguration( Logger& logger )
|
||||
printTrafficConfiguration(Logger& logger)
|
||||
{
|
||||
std::string detail;
|
||||
detail = "";
|
||||
@@ -121,7 +119,7 @@ public:
|
||||
}
|
||||
|
||||
bool
|
||||
extractParameterValue( std::string detail, std::string& parameter, std::string& value )
|
||||
extractParameterValue(const std::string& detail, std::string& parameter, std::string& value)
|
||||
{
|
||||
int i;
|
||||
std::string allowedCharacters = ":/+._-%";
|
||||
@@ -136,7 +134,8 @@ public:
|
||||
if (i == detail.length())
|
||||
return false;
|
||||
i++;
|
||||
while ((std::isalnum(detail[i]) || allowedCharacters.find(detail[i]) != std::string::npos) && i < detail.length())
|
||||
while ((std::isalnum(detail[i]) || allowedCharacters.find(detail[i]) != std::string::npos) &&
|
||||
i < detail.length())
|
||||
{
|
||||
value += detail[i];
|
||||
i++;
|
||||
@@ -147,7 +146,7 @@ public:
|
||||
}
|
||||
|
||||
bool
|
||||
processConfigurationDetail( std::string detail, Logger& logger, int lineNumber )
|
||||
processConfigurationDetail(const std::string& detail, Logger& logger, int lineNumber)
|
||||
{
|
||||
std::string parameter, value;
|
||||
if (extractParameterValue(detail, parameter, value))
|
||||
@@ -185,11 +184,13 @@ public:
|
||||
else if (parameter == "ExpectedContent")
|
||||
expectedContent = value;
|
||||
else
|
||||
logger.log("Line "+toString(lineNumber)+" \t- Invalid Parameter='"+parameter+"'", false, true);
|
||||
logger.log("Line "+toString(lineNumber) +
|
||||
" \t- Invalid Parameter='"+parameter+"'", false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.log("Line "+toString(lineNumber)+" \t- Improper Traffic Configuration Line- "+detail, false, true);
|
||||
logger.log("Line "+toString(lineNumber) +
|
||||
" \t- Improper Traffic Configuration Line- "+detail, false, true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -223,8 +224,7 @@ public:
|
||||
double totalInterestRoundTripTime;
|
||||
int contentInconsistencies;
|
||||
std::string expectedContent;
|
||||
|
||||
};
|
||||
}; // class InterestTrafficConfiguration
|
||||
|
||||
int
|
||||
getDefaultInterestLifetime()
|
||||
@@ -233,7 +233,7 @@ public:
|
||||
}
|
||||
|
||||
static std::string
|
||||
toString( int integerValue )
|
||||
toString(int integerValue)
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << integerValue;
|
||||
@@ -241,7 +241,7 @@ public:
|
||||
}
|
||||
|
||||
static std::string
|
||||
toString( double doubleValue )
|
||||
toString(double doubleValue)
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << doubleValue;
|
||||
@@ -249,7 +249,7 @@ public:
|
||||
}
|
||||
|
||||
static int
|
||||
toInteger( std::string stringValue )
|
||||
toInteger(const std::string& stringValue)
|
||||
{
|
||||
int integerValue;
|
||||
std::stringstream stream(stringValue);
|
||||
@@ -324,57 +324,64 @@ public:
|
||||
double loss, average, inconsistency;
|
||||
|
||||
m_logger.log("\n\n== Interest Traffic Report ==\n", false, true);
|
||||
m_logger.log("Total Traffic Pattern Types = "+toString((int)trafficPattern_.size()), false, true);
|
||||
m_logger.log("Total Interests Sent = "+toString(totalInterestSent_), false, true);
|
||||
m_logger.log("Total Responses Received = "+toString(totalInterestReceived_), false, true);
|
||||
m_logger.log("Total Traffic Pattern Types = " + toString((int)trafficPattern_.size()), false, true);
|
||||
m_logger.log("Total Interests Sent = " + toString(totalInterestSent_), false, true);
|
||||
m_logger.log("Total Responses Received = " + toString(totalInterestReceived_), false, true);
|
||||
if (totalInterestSent_ > 0)
|
||||
loss = (totalInterestSent_-totalInterestReceived_)*100.0/totalInterestSent_;
|
||||
else
|
||||
loss = 0;
|
||||
m_logger.log("Total Interest Loss = "+toString(loss)+"%", false, true);
|
||||
m_logger.log("Total Interest Loss = " + toString(loss)+"%", false, true);
|
||||
if (totalInterestReceived_ > 0)
|
||||
{
|
||||
average = totalInterestRoundTripTime_/totalInterestReceived_;
|
||||
inconsistency = contentInconsistencies_*100.0/totalInterestReceived_;
|
||||
}
|
||||
{
|
||||
average = totalInterestRoundTripTime_/totalInterestReceived_;
|
||||
inconsistency = contentInconsistencies_*100.0/totalInterestReceived_;
|
||||
}
|
||||
else
|
||||
{
|
||||
average = 0;
|
||||
inconsistency = 0;
|
||||
}
|
||||
m_logger.log("Total Data Inconsistency = "+toString(inconsistency)+"%", false, true);
|
||||
m_logger.log("Total Round Trip Time = "+toString(totalInterestRoundTripTime_)+"ms", false, true);
|
||||
m_logger.log("Average Round Trip Time = "+toString(average)+"ms\n", false, true);
|
||||
{
|
||||
average = 0;
|
||||
inconsistency = 0;
|
||||
}
|
||||
m_logger.log("Total Data Inconsistency = " + toString(inconsistency)+"%", false, true);
|
||||
m_logger.log("Total Round Trip Time = " +
|
||||
toString(totalInterestRoundTripTime_)+"ms", false, true);
|
||||
m_logger.log("Average Round Trip Time = " + toString(average)+"ms\n", false, true);
|
||||
|
||||
for (patternId=0; patternId<trafficPattern_.size(); patternId++)
|
||||
{
|
||||
m_logger.log("Traffic Pattern Type #"+toString(patternId+1), false, true);
|
||||
m_logger.log("Traffic Pattern Type #" + toString(patternId+1), false, true);
|
||||
trafficPattern_[patternId].printTrafficConfiguration(m_logger);
|
||||
m_logger.log("Total Interests Sent = "+toString(trafficPattern_[patternId].totalInterestSent), false, true);
|
||||
m_logger.log("Total Responses Received = "+toString(trafficPattern_[patternId].totalInterestReceived), false, true);
|
||||
m_logger.log("Total Interests Sent = " +
|
||||
toString(trafficPattern_[patternId].totalInterestSent), false, true);
|
||||
m_logger.log("Total Responses Received = " +
|
||||
toString(trafficPattern_[patternId].totalInterestReceived), false, true);
|
||||
if (trafficPattern_[patternId].totalInterestSent > 0)
|
||||
{
|
||||
loss = (trafficPattern_[patternId].totalInterestSent-trafficPattern_[patternId].totalInterestReceived);
|
||||
loss = (trafficPattern_[patternId].totalInterestSent -
|
||||
trafficPattern_[patternId].totalInterestReceived);
|
||||
loss *= 100.0;
|
||||
loss /= trafficPattern_[patternId].totalInterestSent;
|
||||
}
|
||||
else
|
||||
loss = 0;
|
||||
m_logger.log("Total Interest Loss = "+toString(loss)+"%", false, true);
|
||||
m_logger.log("Total Interest Loss = " + toString(loss)+"%", false, true);
|
||||
if (trafficPattern_[patternId].totalInterestReceived > 0)
|
||||
{
|
||||
average = trafficPattern_[patternId].totalInterestRoundTripTime/trafficPattern_[patternId].totalInterestReceived;
|
||||
inconsistency = trafficPattern_[patternId].contentInconsistencies;
|
||||
inconsistency = inconsistency*100.0/trafficPattern_[patternId].totalInterestReceived;
|
||||
}
|
||||
{
|
||||
average = (trafficPattern_[patternId].totalInterestRoundTripTime /
|
||||
trafficPattern_[patternId].totalInterestReceived);
|
||||
inconsistency = trafficPattern_[patternId].contentInconsistencies;
|
||||
inconsistency = inconsistency * 100.0 / trafficPattern_[patternId].totalInterestReceived;
|
||||
}
|
||||
else
|
||||
{
|
||||
average = 0;
|
||||
inconsistency = 0;
|
||||
}
|
||||
m_logger.log("Total Data Inconsistency = "+toString(inconsistency)+"%", false, true);
|
||||
m_logger.log("Total Round Trip Time = "+toString(trafficPattern_[patternId].totalInterestRoundTripTime)+"ms", false, true);
|
||||
m_logger.log("Average Round Trip Time = "+toString(average)+"ms\n", false, true);
|
||||
{
|
||||
average = 0;
|
||||
inconsistency = 0;
|
||||
}
|
||||
m_logger.log("Total Data Inconsistency = " + toString(inconsistency)+"%", false, true);
|
||||
m_logger.log("Total Round Trip Time = " +
|
||||
toString(trafficPattern_[patternId].totalInterestRoundTripTime)+"ms",
|
||||
false, true);
|
||||
m_logger.log("Average Round Trip Time = " + toString(average)+"ms\n", false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +418,8 @@ public:
|
||||
while (getline(patternFile, patternLine) && std::isalpha(patternLine[0]))
|
||||
{
|
||||
lineNumber++;
|
||||
if (!interestData.processConfigurationDetail(patternLine, m_logger, lineNumber))
|
||||
if (!interestData.processConfigurationDetail(patternLine,
|
||||
m_logger, lineNumber))
|
||||
{
|
||||
skipLine = true;
|
||||
break;
|
||||
@@ -431,7 +439,8 @@ public:
|
||||
patternFile.close();
|
||||
if (!checkTrafficPatternCorrectness())
|
||||
{
|
||||
m_logger.log("ERROR - Traffic Configuration Provided Is Not Proper- " + configurationFile_, false, true);
|
||||
m_logger.log("ERROR - Traffic Configuration Provided Is Not Proper- " +
|
||||
configurationFile_, false, true);
|
||||
m_logger.shutdownLogger();
|
||||
exit(1);
|
||||
}
|
||||
@@ -445,7 +454,8 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
m_logger.log("ERROR - Unable To Open Traffic Configuration File: " + configurationFile_, false, true);
|
||||
m_logger.log("ERROR - Unable To Open Traffic Configuration File: " +
|
||||
configurationFile_, false, true);
|
||||
m_logger.shutdownLogger();
|
||||
exit(1);
|
||||
}
|
||||
@@ -462,14 +472,16 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
m_logger.log("ERROR - Traffic Configuration File Is Not A Regular File: " + configurationFile_, false, true);
|
||||
m_logger.log("ERROR - Traffic Configuration File Is Not A Regular File: " +
|
||||
configurationFile_, false, true);
|
||||
m_logger.shutdownLogger();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_logger.log("ERROR - Traffic Configuration File Does Not Exist: " + configurationFile_, false, true);
|
||||
m_logger.log("ERROR - Traffic Configuration File Does Not Exist: " +
|
||||
configurationFile_, false, true);
|
||||
m_logger.shutdownLogger();
|
||||
exit(1);
|
||||
}
|
||||
@@ -543,19 +555,19 @@ public:
|
||||
totalInterestReceived_++;
|
||||
trafficPattern_[patternId].totalInterestReceived++;
|
||||
if (trafficPattern_[patternId].expectedContent != "")
|
||||
{
|
||||
receivedContent = (char*)(data.getContent().value());
|
||||
receivedContentLength = data.getContent().value_size();
|
||||
receivedContent = receivedContent.substr(0, receivedContentLength);
|
||||
if (receivedContent != trafficPattern_[patternId].expectedContent)
|
||||
{
|
||||
contentInconsistencies_++;
|
||||
trafficPattern_[patternId].contentInconsistencies++;
|
||||
logLine += ", IsConsistent=No";
|
||||
receivedContent = (char*)(data.getContent().value());
|
||||
receivedContentLength = data.getContent().value_size();
|
||||
receivedContent = receivedContent.substr(0, receivedContentLength);
|
||||
if (receivedContent != trafficPattern_[patternId].expectedContent)
|
||||
{
|
||||
contentInconsistencies_++;
|
||||
trafficPattern_[patternId].contentInconsistencies++;
|
||||
logLine += ", IsConsistent=No";
|
||||
}
|
||||
else
|
||||
logLine += ", IsConsistent=Yes";
|
||||
}
|
||||
else
|
||||
logLine += ", IsConsistent=Yes";
|
||||
}
|
||||
else
|
||||
logLine += ", IsConsistent=NotChecked";
|
||||
m_logger.log(logLine, true, false);
|
||||
@@ -622,7 +634,8 @@ public:
|
||||
if (trafficPattern_[patternId].maxSuffixComponents >= 0)
|
||||
interest.setMaxSuffixComponents(trafficPattern_[patternId].maxSuffixComponents);
|
||||
Exclude exclude;
|
||||
if (trafficPattern_[patternId].excludeBefore != "" && trafficPattern_[patternId].excludeAfter != "")
|
||||
if (trafficPattern_[patternId].excludeBefore != "" &&
|
||||
trafficPattern_[patternId].excludeAfter != "")
|
||||
{
|
||||
exclude.excludeRange(name::Component(trafficPattern_[patternId].excludeAfter),
|
||||
name::Component(trafficPattern_[patternId].excludeBefore));
|
||||
@@ -638,20 +651,24 @@ public:
|
||||
exclude.excludeAfter(name::Component(trafficPattern_[patternId].excludeAfter));
|
||||
interest.setExclude(exclude);
|
||||
}
|
||||
if (trafficPattern_[patternId].excludeBeforeBytes > 0 && trafficPattern_[patternId].excludeAfterBytes > 0)
|
||||
if (trafficPattern_[patternId].excludeBeforeBytes > 0 &&
|
||||
trafficPattern_[patternId].excludeAfterBytes > 0)
|
||||
{
|
||||
exclude.excludeRange(name::Component(getRandomByteString(trafficPattern_[patternId].excludeAfterBytes)),
|
||||
name::Component(getRandomByteString(trafficPattern_[patternId].excludeBeforeBytes)));
|
||||
exclude.excludeRange(
|
||||
name::Component(getRandomByteString(trafficPattern_[patternId].excludeAfterBytes)),
|
||||
name::Component(getRandomByteString(trafficPattern_[patternId].excludeBeforeBytes)));
|
||||
interest.setExclude(exclude);
|
||||
}
|
||||
else if (trafficPattern_[patternId].excludeBeforeBytes > 0)
|
||||
{
|
||||
exclude.excludeBefore(name::Component(getRandomByteString(trafficPattern_[patternId].excludeBeforeBytes)));
|
||||
exclude.excludeBefore(
|
||||
name::Component(getRandomByteString(trafficPattern_[patternId].excludeBeforeBytes)));
|
||||
interest.setExclude(exclude);
|
||||
}
|
||||
else if (trafficPattern_[patternId].excludeAfterBytes > 0)
|
||||
{
|
||||
exclude.excludeAfter(name::Component(getRandomByteString(trafficPattern_[patternId].excludeAfterBytes)));
|
||||
exclude.excludeAfter(
|
||||
name::Component(getRandomByteString(trafficPattern_[patternId].excludeAfterBytes)));
|
||||
interest.setExclude(exclude);
|
||||
}
|
||||
|
||||
@@ -677,26 +694,28 @@ public:
|
||||
if (trafficPattern_[patternId].scope >= 0)
|
||||
interest.setScope(trafficPattern_[patternId].scope);
|
||||
if (trafficPattern_[patternId].interestLifetime >= 0)
|
||||
interest.setInterestLifetime(time::milliseconds(trafficPattern_[patternId].interestLifetime));
|
||||
interest.setInterestLifetime(
|
||||
time::milliseconds(trafficPattern_[patternId].interestLifetime));
|
||||
else
|
||||
interest.setInterestLifetime(time::milliseconds(getDefaultInterestLifetime()));
|
||||
interest.setInterestLifetime(
|
||||
time::milliseconds(getDefaultInterestLifetime()));
|
||||
try {
|
||||
totalInterestSent_++;
|
||||
trafficPattern_[patternId].totalInterestSent++;
|
||||
boost::posix_time::ptime sentTime;
|
||||
sentTime = boost::posix_time::microsec_clock::local_time();
|
||||
face_.expressInterest(interest,
|
||||
func_lib::bind( &NdnTrafficClient::onData,
|
||||
this, boost::ref(face_),
|
||||
_1, _2, totalInterestSent_,
|
||||
trafficPattern_[patternId].totalInterestSent,
|
||||
patternId,
|
||||
sentTime),
|
||||
func_lib::bind( &NdnTrafficClient::onTimeout,
|
||||
this, boost::ref(face_),
|
||||
_1, totalInterestSent_,
|
||||
trafficPattern_[patternId].totalInterestSent,
|
||||
patternId));
|
||||
bind( &NdnTrafficClient::onData,
|
||||
this, boost::ref(face_),
|
||||
_1, _2, totalInterestSent_,
|
||||
trafficPattern_[patternId].totalInterestSent,
|
||||
patternId,
|
||||
sentTime),
|
||||
bind( &NdnTrafficClient::onTimeout,
|
||||
this, boost::ref(face_),
|
||||
_1, totalInterestSent_,
|
||||
trafficPattern_[patternId].totalInterestSent,
|
||||
patternId));
|
||||
std::string logLine;
|
||||
logLine = "";
|
||||
logLine += "Sending Interest - PatternType="+toString(patternId+1);
|
||||
@@ -706,10 +725,10 @@ public:
|
||||
m_logger.log(logLine, true, false);
|
||||
deadlineTimer->expires_at(deadlineTimer->expires_at() +
|
||||
boost::posix_time::millisec(interestInterval_));
|
||||
deadlineTimer->async_wait(boost::bind(&NdnTrafficClient::generateTraffic,
|
||||
this,
|
||||
boost::asio::placeholders::error,
|
||||
deadlineTimer));
|
||||
deadlineTimer->async_wait(bind(&NdnTrafficClient::generateTraffic,
|
||||
this,
|
||||
boost::asio::placeholders::error,
|
||||
deadlineTimer));
|
||||
}
|
||||
catch (std::exception &e) {
|
||||
m_logger.log("ERROR: "+(std::string)e.what(), true, true);
|
||||
@@ -721,10 +740,10 @@ public:
|
||||
{
|
||||
deadlineTimer->expires_at(deadlineTimer->expires_at() +
|
||||
boost::posix_time::millisec(interestInterval_));
|
||||
deadlineTimer->async_wait(boost::bind(&NdnTrafficClient::generateTraffic,
|
||||
this,
|
||||
boost::asio::placeholders::error,
|
||||
deadlineTimer));
|
||||
deadlineTimer->async_wait(bind(&NdnTrafficClient::generateTraffic,
|
||||
this,
|
||||
boost::asio::placeholders::error,
|
||||
deadlineTimer));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -733,15 +752,15 @@ public:
|
||||
initialize()
|
||||
{
|
||||
boost::asio::signal_set signalSet(*ioService_, SIGINT, SIGTERM);
|
||||
signalSet.async_wait(boost::bind(&NdnTrafficClient::signalHandler, this));
|
||||
signalSet.async_wait(bind(&NdnTrafficClient::signalHandler, this));
|
||||
m_logger.initializeLog(instanceId_);
|
||||
initializeTrafficConfiguration();
|
||||
boost::asio::deadline_timer deadlineTimer(*ioService_,
|
||||
boost::posix_time::millisec(interestInterval_));
|
||||
deadlineTimer.async_wait(boost::bind(&NdnTrafficClient::generateTraffic,
|
||||
this,
|
||||
boost::asio::placeholders::error,
|
||||
&deadlineTimer));
|
||||
deadlineTimer.async_wait(bind(&NdnTrafficClient::generateTraffic,
|
||||
this,
|
||||
boost::asio::placeholders::error,
|
||||
&deadlineTimer));
|
||||
try {
|
||||
face_.processEvents();
|
||||
}
|
||||
@@ -21,8 +21,7 @@ namespace ndn {
|
||||
class NdnTrafficServer
|
||||
{
|
||||
public:
|
||||
|
||||
NdnTrafficServer( char* programName )
|
||||
NdnTrafficServer(char* programName)
|
||||
: m_logger("NDNTrafficServer")
|
||||
, ioService_(new boost::asio::io_service)
|
||||
, face_(ioService_)
|
||||
@@ -40,7 +39,6 @@ public:
|
||||
class DataTrafficConfiguration
|
||||
{
|
||||
public:
|
||||
|
||||
DataTrafficConfiguration()
|
||||
{
|
||||
name = "";
|
||||
@@ -52,7 +50,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
printTrafficConfiguration( Logger& logger )
|
||||
printTrafficConfiguration(Logger& logger)
|
||||
{
|
||||
std::string detail;
|
||||
detail = "";
|
||||
@@ -73,7 +71,8 @@ public:
|
||||
|
||||
|
||||
bool
|
||||
extractParameterValue( std::string detail, std::string& parameter, std::string& value )
|
||||
extractParameterValue(const std::string& detail,
|
||||
std::string& parameter, std::string& value)
|
||||
{
|
||||
int i;
|
||||
std::string allowedCharacters = ":/+._-%";
|
||||
@@ -88,7 +87,9 @@ public:
|
||||
if (i == detail.length())
|
||||
return false;
|
||||
i++;
|
||||
while ((std::isalnum(detail[i]) || allowedCharacters.find(detail[i]) != std::string::npos) && i < detail.length())
|
||||
while ((std::isalnum(detail[i]) ||
|
||||
allowedCharacters.find(detail[i]) != std::string::npos) &&
|
||||
i < detail.length())
|
||||
{
|
||||
value += detail[i];
|
||||
i++;
|
||||
@@ -99,7 +100,8 @@ public:
|
||||
}
|
||||
|
||||
bool
|
||||
processConfigurationDetail( std::string detail, Logger& logger, int lineNumber )
|
||||
processConfigurationDetail(const std::string& detail,
|
||||
Logger& logger, int lineNumber)
|
||||
{
|
||||
std::string parameter, value;
|
||||
if (extractParameterValue(detail, parameter, value))
|
||||
@@ -115,11 +117,13 @@ public:
|
||||
else if (parameter == "Content")
|
||||
content = value;
|
||||
else
|
||||
logger.log("Line "+toString(lineNumber)+" \t- Invalid Parameter='"+parameter+"'", false, true);
|
||||
logger.log("Line "+toString(lineNumber)+
|
||||
" \t- Invalid Parameter='"+parameter+"'", false, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.log("Line "+toString(lineNumber)+" \t- Improper Traffic Configuration Line- "+detail, false, true);
|
||||
logger.log("Line "+toString(lineNumber)+
|
||||
" \t- Improper Traffic Configuration Line- "+detail, false, true);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -147,7 +151,7 @@ public:
|
||||
}
|
||||
|
||||
static std::string
|
||||
toString( int integerValue )
|
||||
toString(int integerValue)
|
||||
{
|
||||
std::stringstream stream;
|
||||
stream << integerValue;
|
||||
@@ -155,7 +159,7 @@ public:
|
||||
}
|
||||
|
||||
static int
|
||||
toInteger( std::string stringValue )
|
||||
toInteger(std::string stringValue)
|
||||
{
|
||||
int integerValue;
|
||||
std::stringstream stream(stringValue);
|
||||
@@ -185,7 +189,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setContentDelayTime( int contentDelayTime )
|
||||
setContentDelayTime(int contentDelayTime)
|
||||
{
|
||||
if (contentDelayTime < 0)
|
||||
usage();
|
||||
@@ -193,7 +197,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
setConfigurationFile( char* configurationFile )
|
||||
setConfigurationFile(char* configurationFile)
|
||||
{
|
||||
configurationFile_ = configurationFile;
|
||||
}
|
||||
@@ -213,13 +217,17 @@ public:
|
||||
{
|
||||
int patternId;
|
||||
m_logger.log("\n\n== Interest Traffic Report ==\n", false, true);
|
||||
m_logger.log("Total Traffic Pattern Types = "+toString((int)trafficPattern_.size()), false, true);
|
||||
m_logger.log("Total Interests Received = "+toString(totalInterestReceived_), false, true);
|
||||
m_logger.log("Total Traffic Pattern Types = " +
|
||||
toString((int)trafficPattern_.size()), false, true);
|
||||
m_logger.log("Total Interests Received = " +
|
||||
toString(totalInterestReceived_), false, true);
|
||||
|
||||
for (patternId=0; patternId<trafficPattern_.size(); patternId++)
|
||||
{
|
||||
m_logger.log("\nTraffic Pattern Type #"+toString(patternId+1), false, true);
|
||||
trafficPattern_[patternId].printTrafficConfiguration(m_logger);
|
||||
m_logger.log("Total Interests Received = "+toString(trafficPattern_[patternId].totalInterestReceived)+"\n", false, true);
|
||||
m_logger.log("Total Interests Received = " +
|
||||
toString(trafficPattern_[patternId].totalInterestReceived)+"\n", false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,7 +284,8 @@ public:
|
||||
patternFile.close();
|
||||
if (!checkTrafficPatternCorrectness())
|
||||
{
|
||||
m_logger.log("ERROR - Traffic Configuration Provided Is Not Proper- " + configurationFile_, false, true);
|
||||
m_logger.log("ERROR - Traffic Configuration Provided Is Not Proper- " +
|
||||
configurationFile_, false, true);
|
||||
m_logger.shutdownLogger();
|
||||
exit(1);
|
||||
}
|
||||
@@ -290,7 +299,8 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
m_logger.log("ERROR - Unable To Open Traffic Configuration File: " + configurationFile_, false, true);
|
||||
m_logger.log("ERROR - Unable To Open Traffic Configuration File: " +
|
||||
configurationFile_, false, true);
|
||||
m_logger.shutdownLogger();
|
||||
exit(1);
|
||||
}
|
||||
@@ -307,21 +317,23 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
m_logger.log("ERROR - Traffic Configuration File Is Not A Regular File: " + configurationFile_, false, true);
|
||||
m_logger.log("ERROR - Traffic Configuration File Is Not A Regular File: " +
|
||||
configurationFile_, false, true);
|
||||
m_logger.shutdownLogger();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_logger.log("ERROR - Traffic Configuration File Does Not Exist: " + configurationFile_, false, true);
|
||||
m_logger.log("ERROR - Traffic Configuration File Does Not Exist: " +
|
||||
configurationFile_, false, true);
|
||||
m_logger.shutdownLogger();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static std::string
|
||||
getRandomByteString( int randomSize )
|
||||
getRandomByteString(int randomSize)
|
||||
{
|
||||
int i;
|
||||
std::string characterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw0123456789";
|
||||
@@ -332,7 +344,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
onInterest( const Name& name, const Interest& interest, int patternId )
|
||||
onInterest(const Name& name, const Interest& interest, int patternId)
|
||||
{
|
||||
std::string content, logLine;
|
||||
content = "";
|
||||
@@ -361,7 +373,7 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
onRegisterFailed( const ndn::Name& prefix, const std::string& reason, int patternId )
|
||||
onRegisterFailed(const ndn::Name& prefix, const std::string& reason, int patternId)
|
||||
{
|
||||
std::string logLine;
|
||||
logLine = "";
|
||||
@@ -382,15 +394,15 @@ public:
|
||||
initializeTrafficConfiguration();
|
||||
|
||||
int patternId;
|
||||
for (patternId=0; patternId<trafficPattern_.size(); patternId++ )
|
||||
for (patternId=0; patternId<trafficPattern_.size(); patternId++)
|
||||
{
|
||||
face_.setInterestFilter( trafficPattern_[patternId].name,
|
||||
func_lib::bind( &NdnTrafficServer::onInterest,
|
||||
this, _1, _2,
|
||||
patternId),
|
||||
func_lib::bind( &NdnTrafficServer::onRegisterFailed,
|
||||
this, _1, _2,
|
||||
patternId));
|
||||
face_.setInterestFilter(trafficPattern_[patternId].name,
|
||||
bind(&NdnTrafficServer::onInterest,
|
||||
this, _1, _2,
|
||||
patternId),
|
||||
bind(&NdnTrafficServer::onRegisterFailed,
|
||||
this, _1, _2,
|
||||
patternId));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -403,7 +415,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
KeyChain keyChain_;
|
||||
std::string programName_;
|
||||
std::string instanceId_;
|
||||
@@ -415,12 +426,12 @@ private:
|
||||
Face face_;
|
||||
std::vector<DataTrafficConfiguration> trafficPattern_;
|
||||
int totalInterestReceived_;
|
||||
|
||||
};
|
||||
|
||||
} // namespace ndn
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
int
|
||||
main(int argc, char* argv[])
|
||||
{
|
||||
int option;
|
||||
ndn::NdnTrafficServer ndnTrafficServer (argv[0]);
|
||||
@@ -1,25 +1,29 @@
|
||||
# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
|
||||
VERSION='0.3'
|
||||
NAME="ndn-traffic"
|
||||
VERSION='0.1'
|
||||
NAME="ndn-traffic-generator"
|
||||
|
||||
def options(opt):
|
||||
opt.load('compiler_cxx')
|
||||
opt.load('compiler_cxx gnu_dirs')
|
||||
|
||||
def configure(conf):
|
||||
conf.load("compiler_cxx")
|
||||
conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'], uselib_store='NDN_CPP', mandatory=True)
|
||||
conf.load("compiler_cxx gnu_dirs")
|
||||
conf.check_cfg(package='libndn-cpp-dev', args=['--cflags', '--libs'],
|
||||
uselib_store='NDN_CPP', mandatory=True)
|
||||
|
||||
def build (bld):
|
||||
bld.program (
|
||||
features = 'cxx',
|
||||
target = 'ndntraffic',
|
||||
source = 'ndn-traffic-client.cpp',
|
||||
target = 'ndn-traffic',
|
||||
source = 'src/ndn-traffic-client.cpp',
|
||||
use = 'NDN_CPP',
|
||||
)
|
||||
|
||||
bld.program (
|
||||
features = 'cxx',
|
||||
target = 'ndntrafficserver',
|
||||
source = 'ndn-traffic-server.cpp',
|
||||
target = 'ndn-traffic-server',
|
||||
source = 'src/ndn-traffic-server.cpp',
|
||||
use = 'NDN_CPP',
|
||||
)
|
||||
|
||||
bld.install_files('${SYSCONFDIR}/ndn', ['ndn-traffic-client.conf.sample',
|
||||
'ndn-traffic-server.conf.sample'])
|
||||
|
||||
Reference in New Issue
Block a user