Development Complete, README File To Be Updated
diff --git a/NDNTrafficServer.sample.conf b/NDNTrafficServer.sample.conf
new file mode 100644
index 0000000..2bdfb24
--- /dev/null
+++ b/NDNTrafficServer.sample.conf
@@ -0,0 +1,20 @@
+#

+#Name

+#

+#ContentType

+#

+#FreshnessPeriod

+#

+#ContentBytes

+#Content

+#

+##########

+#Name=/example

+#ContentType=1

+#ContentBytes=10

+##########

+Name=/example/A

+ContentType=0

+FreshnessPeriod=0

+Content=NoData

+##########

diff --git a/ndn-traffic-client.cpp b/ndn-traffic-client.cpp
index 6df1ed1..b617b1c 100644
--- a/ndn-traffic-client.cpp
+++ b/ndn-traffic-client.cpp
@@ -10,8 +10,8 @@
 #include <fstream>

 #include <vector>

 #include <boost/asio.hpp>

-#include <boost/filesystem.hpp>

 #include <boost/bind.hpp>

+#include <boost/filesystem.hpp>

 #include <boost/date_time/posix_time/posix_time.hpp>

 

 #include <ndn-cpp-dev/face.hpp>

@@ -34,7 +34,10 @@
   shutdownLogger()

   {

     if (logFile_.is_open())

+    {

+      log("Terminating Logging Operations" , true, true);

       logFile_.close();

+    }

   }

 

   static std::string

@@ -118,7 +121,7 @@
 {

 public:

 

-  NdnTrafficClient( char* programName ) : ioService_(new boost::asio::io_service), face_(ioService_)

+  NdnTrafficClient( char* programName ) : ioService_(new boost::asio::io_service), face_(ioService_), keyChain_()

   {

     std::srand(std::time(0));

     instanceId_ = toString(std::rand());

@@ -133,11 +136,6 @@
     totalInterestRoundTripTime_ = 0;

   }

 

-  NdnTrafficClient()

-  : keyChain_()

-  {

-  }

-

   class InterestTrafficConfiguration

   {

   public:

@@ -158,7 +156,7 @@
       mustBeFresh = -1;

       nonceDuplicationPercentage = -1;

       scope = -1;

-      interestLifetime = getDefaultInterestLifetime();

+      interestLifetime = -1;

       totalInterestSent = 0;

       totalInterestReceived = 0;

       minimumInterestRoundTripTime = std::numeric_limits<double>::max();

@@ -166,12 +164,6 @@
       totalInterestRoundTripTime = 0;

     }

 

-    int

-    getDefaultInterestLifetime()

-    {

-      return 4000;

-    }

-

     void

     printTrafficConfiguration( Logger& logger )

     {

@@ -181,13 +173,13 @@
         detail += "TrafficPercentage="+toString(trafficPercentage)+", ";

       if (name != "")

         detail += "Name="+name+", ";

-      if (nameAppendBytes>0)

+      if (nameAppendBytes > 0)

         detail += "NameAppendBytes="+toString(nameAppendBytes)+", ";

-      if (nameAppendSequenceNumber>0)

+      if (nameAppendSequenceNumber > 0)

         detail += "NameAppendSequenceNumber="+toString(nameAppendSequenceNumber)+", ";

-      if (minSuffixComponents>0)

+      if (minSuffixComponents >= 0)

         detail += "MinSuffixComponents="+toString(minSuffixComponents)+", ";

-      if (maxSuffixComponents>0)

+      if (maxSuffixComponents >= 0)

         detail += "MaxSuffixComponents="+toString(maxSuffixComponents)+", ";

       if (excludeBefore != "")

         detail += "ExcludeBefore="+excludeBefore+", ";

@@ -197,15 +189,15 @@
         detail += "ExcludeBeforeBytes="+toString(excludeBeforeBytes)+", ";

       if (excludeAfterBytes > 0)

         detail += "ExcludeAfterBytes="+toString(excludeAfterBytes)+", ";

-      if (childSelector > 0)

+      if (childSelector >= 0)

         detail += "ChildSelector="+toString(childSelector)+", ";

-      if (mustBeFresh > 0)

+      if (mustBeFresh >= 0)

         detail += "MustBeFresh="+toString(mustBeFresh)+", ";

       if (nonceDuplicationPercentage > 0)

         detail += "NonceDuplicationPercentage="+toString(nonceDuplicationPercentage)+", ";

-      if (scope > 0)

+      if (scope >= 0)

         detail += "Scope="+toString(scope)+", ";

-      if (interestLifetime > 0)

+      if (interestLifetime >= 0)

         detail += "InterestLifetime="+toString(interestLifetime)+", ";

       if (detail.length() >= 0)

         detail = detail.substr(0, detail.length()-2);

@@ -314,6 +306,12 @@
 

   };

 

+  int

+  getDefaultInterestLifetime()

+  {

+    return 4000;

+  }

+

   static std::string

   toString( int integerValue )

   {

@@ -322,6 +320,14 @@
     return stream.str();

   }

 

+  static std::string

+  toString( double doubleValue )

+  {

+    std::stringstream stream;

+    stream << doubleValue;

+    return stream.str();

+  }

+

   static int

   toInteger( std::string stringValue )

   {

@@ -379,9 +385,56 @@
     logger_.shutdownLogger();

     face_.shutdown();

     ioService_.reset();

+    logStatistics();

     exit(1);

   }

 

+  void

+  logStatistics()

+  {

+    int patternId;

+    double loss, average;

+

+    logger_.log("\n\n== Interest Traffic Report ==\n", false, true);

+    logger_.log("Total Traffic Pattern Types = "+toString((int)trafficPattern_.size()), false, true);

+    logger_.log("Total Interests Sent        = "+toString(totalInterestSent_), false, true);

+    logger_.log("Total Responses Received    = "+toString(totalInterestReceived_), false, true);

+    if (totalInterestSent_ > 0)

+      loss = (totalInterestSent_-totalInterestReceived_)*100.0/totalInterestSent_;

+    else

+      loss = 0;

+    logger_.log("Total Interest Loss         = "+toString(loss)+"%", false, true);

+    if (totalInterestReceived_ > 0)

+      average = totalInterestRoundTripTime_/totalInterestReceived_;

+    else

+      average = 0;

+    logger_.log("Total Round Trip Time       = "+toString(totalInterestRoundTripTime_)+"ms", false, true);

+    logger_.log("Average Round Trip Time     = "+toString(average)+"ms\n", false, true);

+

+    for (patternId=0; patternId<trafficPattern_.size(); patternId++)

+    {

+      logger_.log("Traffic Pattern Type #"+toString(patternId+1), false, true);

+      trafficPattern_[patternId].printTrafficConfiguration(logger_);

+      logger_.log("Total Interests Sent        = "+toString(trafficPattern_[patternId].totalInterestSent), false, true);

+      logger_.log("Total Responses Received    = "+toString(trafficPattern_[patternId].totalInterestReceived), false, true);

+      if (trafficPattern_[patternId].totalInterestSent > 0)

+      {

+        loss = (trafficPattern_[patternId].totalInterestSent-trafficPattern_[patternId].totalInterestReceived);

+        loss *= 100.0;

+        loss /= trafficPattern_[patternId].totalInterestSent;

+      }

+      else

+        loss = 0;

+      logger_.log("Total Interest Loss         = "+toString(loss)+"%", false, true);

+      if (trafficPattern_[patternId].totalInterestReceived > 0)

+        average = trafficPattern_[patternId].totalInterestRoundTripTime/trafficPattern_[patternId].totalInterestReceived;

+      else

+        average = 0;

+      logger_.log("Total Round Trip Time       = "+toString(trafficPattern_[patternId].totalInterestRoundTripTime)+"ms", false, true);

+      logger_.log("Average Round Trip Time     = "+toString(average)+"ms\n", false, true);

+    }

+  }

+

   bool

   checkTrafficPatternCorrectness()

   {

@@ -439,8 +492,13 @@
         logger_.shutdownLogger();

         exit(1);

       }

-      for (patternId = 0; patternId < trafficPattern_.size(); patternId++)

+      logger_.log("Traffic Configuration File Processing Completed\n", true, false);

+      for (patternId=0; patternId<trafficPattern_.size(); patternId++)

+      {

+        logger_.log("Traffic Pattern Type #"+toString(patternId+1), false, false);

         trafficPattern_[patternId].printTrafficConfiguration(logger_);

+        logger_.log("", false, false);

+      }

     }

     else

     {

@@ -547,6 +605,8 @@
       trafficPattern_[patternId].maximumInterestRoundTripTime = roundTripTime;

     totalInterestRoundTripTime_ += roundTripTime;

     trafficPattern_[patternId].totalInterestRoundTripTime += roundTripTime;

+    if (totalInterestSent_ == interestCount_)

+      signalHandler();

   }

 

   void

@@ -563,6 +623,8 @@
     logLine += ", PatternID="+toString(patternId);

     logLine += ", Name="+interest.getName().toUri();

     logger_.log(logLine, true, false);

+    if (totalInterestSent_ == interestCount_)

+      signalHandler();

   }

 

   void

@@ -575,7 +637,6 @@
       std::srand(std::time(0));

       trafficKey = std::rand() % 100;

       cumulativePercentage = 0;

-      std::cout << trafficKey << std::endl;

       for (patternId=0; patternId<trafficPattern_.size(); patternId++)

       {

         cumulativePercentage += trafficPattern_[patternId].trafficPercentage;

@@ -590,9 +651,9 @@
             trafficPattern_[patternId].nameAppendSequenceNumber++;

           }

           Interest interest(interestName);

-          if (trafficPattern_[patternId].minSuffixComponents > 0)

+          if (trafficPattern_[patternId].minSuffixComponents >= 0)

             interest.setMinSuffixComponents(trafficPattern_[patternId].minSuffixComponents);

-          if (trafficPattern_[patternId].maxSuffixComponents > 0)

+          if (trafficPattern_[patternId].maxSuffixComponents >= 0)

             interest.setMaxSuffixComponents(trafficPattern_[patternId].maxSuffixComponents);

           Exclude exclude;

           if (trafficPattern_[patternId].excludeBefore != "" &&  trafficPattern_[patternId].excludeAfter != "")

@@ -633,7 +694,7 @@
 

           if (trafficPattern_[patternId].mustBeFresh == 0)

             interest.setMustBeFresh(false);

-          else if (trafficPattern_[patternId].mustBeFresh == 1)

+          else if (trafficPattern_[patternId].mustBeFresh > 0)

             interest.setMustBeFresh(true);

           if (trafficPattern_[patternId].nonceDuplicationPercentage > 0)

           {

@@ -649,8 +710,10 @@
             interest.setNonce(getNewNonce());

           if (trafficPattern_[patternId].scope >= 0)

             interest.setScope(trafficPattern_[patternId].scope);

-          if (trafficPattern_[patternId].interestLifetime > 0)

+          if (trafficPattern_[patternId].interestLifetime >= 0)

             interest.setInterestLifetime(trafficPattern_[patternId].interestLifetime);

+          else

+            interest.setInterestLifetime(getDefaultInterestLifetime());

           try {

             totalInterestSent_++;

             trafficPattern_[patternId].totalInterestSent++;

diff --git a/ndn-traffic-server.cpp b/ndn-traffic-server.cpp
index 4b12510..e059bbe 100644
--- a/ndn-traffic-server.cpp
+++ b/ndn-traffic-server.cpp
@@ -14,25 +14,242 @@
 

 using namespace ndn;

 

+class Logger

+{

+public:

+

+  Logger()

+  {

+    logLocation_ = "";

+  }

+

+  void

+  shutdownLogger()

+  {

+    if (logFile_.is_open())

+    {

+      log("Terminating Logging Operations" , true, true);

+      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( std::string logLine, bool printTime, bool printToConsole )

+  {

+    if( logLocation_.length() > 0 )

+    {

+      if (printTime)

+        logFile_ << getTimestamp() << " - ";

+      logFile_ << logLine << std::endl;

+      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( std::string instanceId )

+  {

+    char* variableValue = std::getenv("NDN_TRAFFIC_LOGFOLDER");

+    std::string logFilename;

+    logLocation_ = "";

+    if (variableValue != NULL)

+      logLocation_ = variableValue;

+    if (boost::filesystem::exists(boost::filesystem::path(logLocation_)))

+    {

+      if (boost::filesystem::is_directory(boost::filesystem::path(logLocation_)))

+      {

+        logFilename = logLocation_+"/NDNTrafficServer_"+instanceId+".log";

+        logFile_.open(logFilename.c_str(), std::ofstream::out | std::ofstream::trunc);

+        if (logFile_.is_open())

+          std::cout << "Log File Initialized: " << logFilename << std::endl;

+        else

+        {

+          std::cout << "ERROR - Unable To Initialize A Log File At: " << logLocation_ << std::endl

+                    << "Using Default Output For Logging." << std::endl;

+          logLocation_ = "";

+        }

+      }

+      else

+      {

+        std::cout << "Environment Variable NDN_TRAFFIC_LOGFOLDER Should Be A Folder." << std::endl

+                  << "Using Default Output For Logging." << std::endl;

+        logLocation_ = "";

+      }

+    }

+    else

+    {

+      std::cout << "Environment Variable NDN_TRAFFIC_LOGFOLDER Not Set." << std::endl

+                << "Using Default Output For Logging." << std::endl;

+      logLocation_ = "";

+    }

+  }

+

+private:

+

+  std::string logLocation_;

+  std::ofstream logFile_;

+

+};

+

+

 class NdnTrafficServer

 {

 public:

 

-  NdnTrafficServer( char* programName ) : ioService_(new boost::asio::io_service), face_(ioService_)

+  NdnTrafficServer( char* programName ) : ioService_(new boost::asio::io_service), face_(ioService_), keyChain_()

   {

-    std::stringstream randomId;

     std::srand(std::time(0));

-    randomId << std::rand();

-    instanceId_ = randomId.str();

+    instanceId_ = toString(std::rand());

     programName_ = programName;

     contentDelayTime_ = getDefaultContentDelayTime();

-    logLocation_ = "";

+    totalRegistrationsFailed_ = 0;

     configurationFile_ = "";

+    totalInterestReceived_ = 0;

   }

 

-  NdnTrafficServer()

-  : keyChain_()

+  class DataTrafficConfiguration

   {

+  public:

+

+    DataTrafficConfiguration()

+    {

+      name = "";

+      contentType = -1;

+      freshnessPeriod = -1;

+      contentBytes = -1;

+      content = "";

+      totalInterestReceived = 0;

+    }

+

+    void

+    printTrafficConfiguration( Logger& logger )

+    {

+      std::string detail;

+      detail = "";

+      if (name != "")

+        detail += "Name="+name+", ";

+      if (contentType >= 0)

+        detail += "ContentType="+toString(contentType)+", ";

+      if (freshnessPeriod >= 0)

+        detail += "FreshnessPeriod="+toString(freshnessPeriod)+", ";

+      if (contentBytes >= 0)

+        detail += "ContentBytes="+toString(contentBytes)+", ";

+      if (content != "")

+        detail += "Content="+content+", ";

+      if (detail.length() >= 0)

+        detail = detail.substr(0, detail.length()-2);

+      logger.log(detail, false, false);

+    }

+

+

+    bool

+    extractParameterValue( std::string detail, std::string& parameter, std::string& value )

+    {

+      int i;

+      std::string allowedCharacters = ":/+._-%";

+      parameter = "";

+      value = "";

+      i = 0;

+      while (detail[i] != '=' && i < detail.length())

+      {

+        parameter += detail[i];

+        i++;

+      }

+      if (i == detail.length())

+        return false;

+      i++;

+      while ((std::isalnum(detail[i]) || allowedCharacters.find(detail[i]) != std::string::npos) && i < detail.length())

+      {

+        value += detail[i];

+        i++;

+      }

+      if(parameter == "" || value == "")

+        return false;

+      return true;

+    }

+

+    bool

+    processConfigurationDetail( std::string detail, Logger& logger, int lineNumber )

+    {

+      std::string parameter, value;

+      if (extractParameterValue(detail, parameter, value))

+      {

+        if (parameter == "Name")

+          name = value;

+        else if (parameter == "ContentType")

+          contentType = toInteger(value);

+        else if (parameter == "FreshnessPeriod")

+          freshnessPeriod = toInteger(value);

+        else if (parameter == "ContentBytes")

+          contentBytes = toInteger(value);

+        else if (parameter == "Content")

+          content = value;

+        else

+          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);

+        return false;

+      }

+      return true;

+    }

+

+    bool

+    checkTrafficDetailCorrectness()

+    {

+      return true;

+    }

+

+    std::string name;

+    int contentType;

+    int freshnessPeriod;

+    int contentBytes;

+    std::string content;

+    int totalInterestReceived;

+

+  };

+

+  std::string

+  getDefaultContent()

+  {

+    return "";

+  }

+

+  static std::string

+  toString( int integerValue )

+  {

+    std::stringstream stream;

+    stream << integerValue;

+    return stream.str();

+  }

+

+  static int

+  toInteger( std::string stringValue )

+  {

+    int integerValue;

+    std::stringstream stream(stringValue);

+    stream >> integerValue;

+    return integerValue;

   }

 

   void

@@ -66,44 +283,174 @@
   void

   signalHandler()

   {

+    logger_.shutdownLogger();

     face_.shutdown();

     ioService_.reset();

+    logStatistics();

     exit(1);

   }

 

   void

-  initializeLog()

+  logStatistics()

   {

-    char* variableValue = std::getenv("NDN_TRAFFIC_LOGFOLDER");

-    if (variableValue != NULL)

-      logLocation_ = variableValue;

-

-    if (boost::filesystem::exists(boost::filesystem::path(logLocation_)))

+    int patternId;

+    logger_.log("\n\n== Interest Traffic Report ==\n", false, true);

+    logger_.log("Total Traffic Pattern Types = "+toString((int)trafficPattern_.size()), false, true);

+    logger_.log("Total Interests Received    = "+toString(totalInterestReceived_), false, true);

+    for (patternId=0; patternId<trafficPattern_.size(); patternId++)

     {

-      if (boost::filesystem::is_directory(boost::filesystem::path(logLocation_)))

+      logger_.log("\nTraffic Pattern Type #"+toString(patternId+1), false, true);

+      trafficPattern_[patternId].printTrafficConfiguration(logger_);

+      logger_.log("Total Interests Received    = "+toString(trafficPattern_[patternId].totalInterestReceived)+"\n", false, true);

+    }

+  }

+

+  bool

+  checkTrafficPatternCorrectness()

+  {

+    return true;

+  }

+

+  void

+  analyzeConfigurationFile()

+  {

+    int patternId;

+    int lineNumber;

+    bool skipLine;

+    std::string patternLine;

+    std::ifstream patternFile;

+    logger_.log("Analyzing Traffic Configuration File: " + configurationFile_, true, true);

+    patternFile.open(configurationFile_.c_str());

+    if (patternFile.is_open())

+    {

+      patternId = 0;

+      lineNumber = 0;

+      while (getline(patternFile, patternLine))

       {

-        logLocation_ += "/NDNTrafficServer_"+instanceId_+".log";

-        std::cout << "Log File Initialized: " << logLocation_ << std::endl;

+        lineNumber++;

+        if (std::isalpha(patternLine[0]))

+        {

+          DataTrafficConfiguration dataData;

+          skipLine = false;

+          patternId++;

+          if (dataData.processConfigurationDetail(patternLine, logger_, lineNumber))

+          {

+            while (getline(patternFile, patternLine) && std::isalpha(patternLine[0]))

+            {

+              lineNumber++;

+              if (!dataData.processConfigurationDetail(patternLine, logger_, lineNumber))

+              {

+                skipLine = true;

+                break;

+              }

+            }

+            lineNumber++;

+          }

+          else

+            skipLine = true;

+          if( !skipLine )

+          {

+            if (dataData.checkTrafficDetailCorrectness())

+              trafficPattern_.push_back(dataData);

+          }

+        }

       }

-      else

+      patternFile.close();

+      if (!checkTrafficPatternCorrectness())

       {

-        std::cout << "Environment Variable NDN_TRAFFIC_LOGFOLDER Should Be A Folder.\n"

-                     "Using Default Output For Logging." << std::endl;

-        logLocation_ = "";

+        logger_.log("ERROR - Traffic Configuration Provided Is Not Proper- " + configurationFile_, false, true);

+        logger_.shutdownLogger();

+        exit(1);

+      }

+      logger_.log("Traffic Configuration File Processing Completed\n", true, false);

+      for (patternId = 0; patternId < trafficPattern_.size(); patternId++)

+      {

+        logger_.log("Traffic Pattern Type #"+toString(patternId+1), false, false);

+        trafficPattern_[patternId].printTrafficConfiguration(logger_);

+        logger_.log("", false, false);

       }

     }

     else

     {

-      std::cout << "Environment Variable NDN_TRAFFIC_LOGFOLDER Not Set.\n"

-                   "Using Default Output For Logging." << std::endl;

-      logLocation_ = "";

+      logger_.log("ERROR - Unable To Open Traffic Configuration File: " + configurationFile_, false, true);

+      logger_.shutdownLogger();

+      exit(1);

     }

   }

 

   void

   initializeTrafficConfiguration()

   {

-    std::cout << "Traffic Configuration File: " << configurationFile_ << std::endl;

+    if (boost::filesystem::exists(boost::filesystem::path(configurationFile_)))

+    {

+      if(boost::filesystem::is_regular_file(boost::filesystem::path(configurationFile_)))

+      {

+        analyzeConfigurationFile();

+      }

+      else

+      {

+        logger_.log("ERROR - Traffic Configuration File Is Not A Regular File: " + configurationFile_, false, true);

+        logger_.shutdownLogger();

+        exit(1);

+      }

+    }

+    else

+    {

+      logger_.log("ERROR - Traffic Configuration File Does Not Exist: " + configurationFile_, false, true);

+      logger_.shutdownLogger();

+      exit(1);

+    }

+  }

+

+  static std::string

+  getRandomByteString( int randomSize )

+  {

+    int i;

+    std::string characterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw0123456789";

+    std::string randomData;

+    for (i=0; i<randomSize; i++)

+      randomData += characterSet[std::rand() % characterSet.length()];

+    return randomData;

+  }

+

+  void

+  onInterest( const Name& name, const Interest& interest, int patternId )

+  {

+    std::string content, logLine;

+    content = "";

+    logLine = "";

+    Data data(interest.getName());

+    if (trafficPattern_[patternId].contentType >= 0)

+      data.setContentType(trafficPattern_[patternId].contentType);

+    if (trafficPattern_[patternId].freshnessPeriod >= 0)

+      data.setFreshnessPeriod(trafficPattern_[patternId].freshnessPeriod);

+    if (trafficPattern_[patternId].contentBytes >= 0)

+      content = getRandomByteString(trafficPattern_[patternId].contentBytes);

+    if (trafficPattern_[patternId].content != "")

+      content = trafficPattern_[patternId].content;

+    data.setContent((const uint8_t*)content.c_str(), content.length());

+    keyChain_.sign(data);

+    totalInterestReceived_++;

+    trafficPattern_[patternId].totalInterestReceived++;

+    logLine += "Interest Received          - PatternID="+toString(patternId);

+    logLine += ", GlobalID="+toString(totalInterestReceived_);

+    logLine += ", LocalID="+toString(trafficPattern_[patternId].totalInterestReceived);

+    logLine += ", Name="+trafficPattern_[patternId].name;

+    logger_.log(logLine, true, false);

+    face_.put(data);

+  }

+

+  void

+  onRegisterFailed( const ndn::Name& prefix, const std::string& reason, int patternId )

+  {

+    std::string logLine;

+    logLine = "";

+    logLine += "Prefix Registration Failed - PatternID="+toString(patternId);

+    logLine += ", Name="+trafficPattern_[patternId].name;

+    logger_.log(logLine, true, true);

+    totalRegistrationsFailed_++;

+    if (totalRegistrationsFailed_ == trafficPattern_.size())

+      signalHandler();

   }

 

   void

@@ -111,20 +458,43 @@
   {

     boost::asio::signal_set signalSet(*ioService_, SIGINT, SIGTERM);

     signalSet.async_wait(boost::bind(&NdnTrafficServer::signalHandler, this));

-    initializeLog();

+    logger_.initializeLog(instanceId_);

     initializeTrafficConfiguration();

+

+    int 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));

+    }

+

+    try {

+      face_.processEvents();

+    }

+    catch(std::exception &e) {

+      logger_.log("ERROR: "+(std::string)e.what(), true, true);

+      logger_.shutdownLogger();

+    }

   }

 

 private:

 

   KeyChain keyChain_;

   std::string programName_;

+  std::string instanceId_;

   int contentDelayTime_;

-  std::string logLocation_;

+  int totalRegistrationsFailed_;

+  Logger logger_;

   std::string configurationFile_;

   ptr_lib::shared_ptr<boost::asio::io_service> ioService_;

   Face face_;

-  std::string instanceId_;

+  std::vector<DataTrafficConfiguration> trafficPattern_;

+  int totalInterestReceived_;

 

 };