-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
oascigil
committed
Dec 26, 2015
0 parents
commit 29a46c2
Showing
10 changed files
with
2,699 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
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. | ||
|
||
## Prerequisites ## | ||
|
||
Compiling and running ndn-traffic-generator requires the following dependencies: | ||
|
||
1. C++ Boost Libraries version >= 1.48 <http://www.boost.org> | ||
|
||
On Ubuntu 12.04: | ||
|
||
sudo apt-get install libboost1.48-all-dev | ||
|
||
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 | ||
|
||
2. ndn-cxx library <https://github.com/named-data/ndn-cxx> | ||
|
||
For detailed installation instructions, please refer README file | ||
|
||
3. NDN forwarding daemon <https://github.com/named-data/NFD> | ||
|
||
----------------------------------------------------- | ||
|
||
## 1. Compile & Installation Instructions: ## | ||
|
||
./waf configure | ||
./waf | ||
sudo ./waf install | ||
|
||
## 2. Tool Run Instructions & Command Line Options: ## | ||
|
||
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 | ||
[-q] - quiet logging - no interest reception/data generation messages | ||
[-h] - print help and exit | ||
|
||
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 | ||
[-q] - quiet logging - no interest reception/data generation messages | ||
[-h] - print help and exit | ||
|
||
|
||
## 3. Sample Run Instructions ## | ||
|
||
__ON MACHINE #1__ | ||
|
||
(NDN forwarding daemon should be running) | ||
|
||
Start traffic server | ||
|
||
ndn-traffic-server ndn-traffic-server.conf | ||
|
||
__ON MACHINE #2__ | ||
|
||
(NDN forwarding daemon should be running) | ||
|
||
Start the traffic client | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# | ||
#THIS IS A SAMPLE CLIENT INTEREST TRAFFIC CONFIGURATION FILE | ||
# | ||
# * TO BE USED TO GENERATE INTEREST MESSAGES BASED ON A PROBABILITY | ||
# PATTERN. | ||
# * EVERY INIVIDUAL PATTERN DESCRIPTION MUST BE SEPARATED BY ONE | ||
# OR MORE '#' CHARACTERS FOR THE TOOL TO DISTINGUISH THEM | ||
# INDIVIUDALLY | ||
# * THE FOLLOWING PARAMETERS MAY BE ADDED FOR EVERY TRAFFIC PATTERN | ||
# * (Mandatory) NEXT TO A PARAMETER MEANS EVERY PATTERN SHOULD HAVE | ||
# IT FOR BEING CONSIDERED VALID | ||
# (Optional) MEANS OTHERWISE | ||
# * ALSO PROVIDED ARE VALID VALUES POSSIBLE FOR EACH PARAMETER | ||
# * PLEASE ENSURE THAT THE SUM OF TRAFFIC PERCENTAGE FOR ALL PATTERNS | ||
# PROVIDED DOES NOT EXCEED 100 IN ORDER TO MAINTAIN CORRECT BEHAVIOR | ||
# * NNI STANDS FOR NON-NEGATIVE INTEGER | ||
# * RANGE OF POSSIBLE VALUES IS SPECIFIED IN [] | ||
# | ||
# | ||
#(Mandatory) | ||
#TrafficPercentage=NNI [0-100] | ||
#Name=NDN Name | ||
# | ||
#(Optional) | ||
#NameAppendBytes=NNI [>0] | ||
#NameAppendSequenceNumber=NNI [>=0] | ||
#MinSuffixComponents=NNI | ||
#MaxSuffixComponents=NNI | ||
#ExcludeBefore=NDN Name Component | ||
#ExcludeAfter=NDN Name Component | ||
#ExcludeBeforeBytes=NNI [>0] | ||
#ExcludeAfterBytes=NNI [>0] | ||
#ChildSelector=NNI [0-1] | ||
#MustBeFresh=NNI [0-1] | ||
#NonceDuplicationPercentage=NNI [0-100] | ||
#InterestLifetime=NNI [Milliseconds] | ||
#ExpectedContent=String | ||
# | ||
# | ||
########## | ||
TrafficPercentage=50 | ||
Name=/example/A | ||
ExpectedContent=AAAAAAAA | ||
Name=/example/Z | ||
ExpectedContent=ZZZZ | ||
########## | ||
TrafficPercentage=50 | ||
Name=/example/B | ||
ExpectedContent=BBBBBBBB | ||
########## | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# | ||
#THIS IS A SAMPLE SERVER DATA TRAFFIC CONFIGURATION FILE | ||
# | ||
# * TO BE USED TO CONFIGURE RESPONSE TO INTERESTS | ||
# * MULTIPLE SERVER PREFIXES CAN BE CONFIGURED FOR BEING HANDLED | ||
# * EVERY INIVIDUAL PATTERN DESCRIPTION MUST BE SEPARATED BY ONE | ||
# OR MORE '#' CHARACTERS FOR THE TOOL TO DISTINGUISH THEM | ||
# INDIVIUDALLY | ||
# * THE FOLLOWING PARAMETERS MAY BE ADDED FOR EVERY TRAFFIC PATTERN | ||
# * (Mandatory) NEXT TO A PARAMETER MEANS EVERY PATTERN SHOULD HAVE | ||
# IT FOR BEING CONSIDERED VALID | ||
# (Optional) MEANS OTHERWISE | ||
# * ALSO PROVIDED ARE VALID VALUES POSSIBLE FOR EACH PARAMETER | ||
# * NNI STANDS FOR NON-NEGATIVE INTEGER | ||
# * RANGE OF POSSIBLE VALUES IS SPECIFIED IN [] | ||
# | ||
# | ||
#(Mandatory) | ||
#Name=NDN Name | ||
# | ||
# | ||
#(Optional) | ||
#ContentType=NNI [>=0] | ||
#FreshnessPeriod=NNI [Milliseconds] | ||
#ContentBytes=NNI [>0] | ||
#Content=String | ||
#ContentDelay=NNI [Milliseconds] | ||
#SigningInfo=String [Ex: signing with a default certificate of a default key for the identity: `id:/my-identity`] | ||
# | ||
# | ||
########## | ||
Name=/example/A/1 | ||
Content=ZZZZ1 | ||
Name=/example/A/2 | ||
Content=ZZZZ2 | ||
########## | ||
Name=/example/B | ||
Content=BBBBBBBB | ||
########## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ | ||
/** | ||
* Copyright (C) 2014-2015 University of Arizona. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Author: Jerald Paul Abraham <[email protected]> | ||
*/ | ||
|
||
#ifndef NTG_LOGGER_HPP | ||
#define NTG_LOGGER_HPP | ||
|
||
#include <cstdlib> | ||
#include <fstream> | ||
#include <string> | ||
|
||
#include <boost/filesystem.hpp> | ||
#include <boost/date_time/posix_time/posix_time.hpp> | ||
|
||
namespace ndn { | ||
|
||
class Logger | ||
{ | ||
public: | ||
Logger(const std::string& module) | ||
: m_module(module) | ||
{ | ||
} | ||
|
||
void | ||
shutdownLogger() | ||
{ | ||
if (m_logFile.is_open()) | ||
{ | ||
log("Terminating Logging Operations" , true, true); | ||
m_logFile.close(); | ||
} | ||
} | ||
|
||
static std::string | ||
getTimestamp() | ||
{ | ||
boost::posix_time::ptime now; | ||
now = boost::posix_time::second_clock::local_time(); | ||
return to_simple_string(now); | ||
} | ||
|
||
void | ||
log(const std::string& logLine, bool printTime, bool printToConsole) | ||
{ | ||
if (m_logLocation.length() > 0) | ||
{ | ||
if (printTime) | ||
m_logFile << getTimestamp() << " - "; | ||
m_logFile << logLine << std::endl; | ||
m_logFile.flush(); | ||
if (printToConsole) | ||
{ | ||
if (printTime) | ||
std::cout << getTimestamp() << " - "; | ||
std::cout << logLine << std::endl; | ||
} | ||
} | ||
else | ||
{ | ||
if (printTime) | ||
std::cout << getTimestamp() << " - "; | ||
std::cout << logLine << std::endl; | ||
} | ||
} | ||
|
||
void | ||
initializeLog(const std::string& instanceId) | ||
{ | ||
const char* envVar = std::getenv("NDN_TRAFFIC_LOGFOLDER"); | ||
m_logLocation = ""; | ||
if (envVar != nullptr) | ||
m_logLocation = envVar; | ||
|
||
std::string logFilename; | ||
if (boost::filesystem::exists(boost::filesystem::path(m_logLocation))) | ||
{ | ||
if (boost::filesystem::is_directory(boost::filesystem::path(m_logLocation))) | ||
{ | ||
logFilename = m_logLocation + "/" + m_module + "_" + instanceId + ".log"; | ||
m_logFile.open(logFilename.c_str(), std::ofstream::out | std::ofstream::trunc); | ||
if (m_logFile.is_open()) | ||
std::cout << "Log File Initialized: " << logFilename << std::endl; | ||
else | ||
{ | ||
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 | ||
<< "Using Default Output For Logging." << std::endl; | ||
m_logLocation = ""; | ||
} | ||
} | ||
else | ||
{ | ||
std::cout << "Environment Variable NDN_TRAFFIC_LOGFOLDER Not Set." << std::endl | ||
<< "Using Default Output For Logging." << std::endl; | ||
m_logLocation = ""; | ||
} | ||
} | ||
|
||
private: | ||
std::string m_module; | ||
std::string m_logLocation; | ||
std::ofstream m_logFile; | ||
}; | ||
|
||
} // namespace ndn | ||
|
||
#endif // NTG_LOGGER_HPP |
Oops, something went wrong.