TPPPingSenderApp Class Reference

#include <2pp_ping_sender.hh>

Inheritance diagram for TPPPingSenderApp:

DiffApp Collaboration diagram for TPPPingSenderApp:

Collaboration graph
[legend]

Detailed Description

Definition at line 67 of file 2pp_ping_sender.hh.

Public Member Functions

void recv (NRAttrVec *data, NR::handle my_handle)
void run ()
 TPPPingSenderApp (int argc, char **argv)
virtual ~TPPPingSenderApp ()

Protected Member Functions

void parseCommandLine (int argc, char **argv)
void usage (char *s)

Protected Attributes

char * config_file_
u_int16_t diffusion_port_
NRdr_

Private Member Functions

handle setupPublication ()
handle setupSubscription ()

Private Attributes

NRSimpleAttribute< int > * counterAttr_
NRAttrVec data_attr_
int last_seq_sent_
EventTimelastEventTime_
TPPPingSenderReceivemr_
int num_subscriptions_
handle pubHandle_
handle subHandle_
NRSimpleAttribute< void * > * timeAttr_


Constructor & Destructor Documentation

TPPPingSenderApp::TPPPingSenderApp int  argc,
char **  argv
 

Definition at line 238 of file 2pp_ping_sender.cc.

References NR::createNR().

00240 {
00241   last_seq_sent_ = 0;
00242   num_subscriptions_ = 0;
00243 
00244   mr_ = new TPPPingSenderReceive(this);
00245 
00246 #ifndef NS_DIFFUSION
00247   parseCommandLine(argc, argv);
00248   dr_ = NR::createNR(diffusion_port_);
00249 #endif // NS_DIFFUSION
00250 }

Here is the call graph for this function:

virtual TPPPingSenderApp::~TPPPingSenderApp  )  [inline, virtual]
 

Definition at line 77 of file 2pp_ping_sender.hh.

00078   {
00079     // Nothing to do
00080   };


Member Function Documentation

void DiffApp::parseCommandLine int  argc,
char **  argv
[protected, inherited]
 

Reimplemented in GearReceiverApp, and GearSenderApp.

Definition at line 76 of file diffapp.cc.

References DiffApp::config_file_, DEBUG_ALWAYS, DEFAULT_DIFFUSION_PORT, DiffPrint(), DiffApp::diffusion_port_, global_debug_level, optarg, and DiffApp::usage().

Referenced by GeoRoutingFilter::GeoRoutingFilter(), GradientFilter::GradientFilter(), OnePhasePullFilter::OnePhasePullFilter(), RmstFilter::RmstFilter(), RmstSink::RmstSink(), and SrcRtFilter::SrcRtFilter().

00077 {
00078   u_int16_t diff_port = DEFAULT_DIFFUSION_PORT;
00079   int debug_level;
00080   int opt;
00081 
00082   config_file_ = NULL;
00083   opterr = 0;
00084 
00085   while (1){
00086     opt = getopt(argc, argv, "f:hd:p:");
00087     switch (opt){
00088 
00089     case 'p':
00090 
00091       diff_port = (u_int16_t) atoi(optarg);
00092       if ((diff_port < 1024) || (diff_port >= 65535)){
00093     DiffPrint(DEBUG_ALWAYS, "Error: Diffusion port must be between 1024 and 65535 !\n");
00094     exit(-1);
00095       }
00096 
00097       break;
00098 
00099     case 'h':
00100 
00101       usage(argv[0]);
00102 
00103       break;
00104 
00105     case 'd':
00106 
00107       debug_level = atoi(optarg);
00108 
00109       if (debug_level < 1 || debug_level > 10){
00110     DiffPrint(DEBUG_ALWAYS, "Error: Debug level outside range or missing !\n");
00111     usage(argv[0]);
00112       }
00113 
00114       global_debug_level = debug_level;
00115 
00116       break;
00117 
00118     case 'f':
00119 
00120       if (!strncasecmp(optarg, "-", 1)){
00121     DiffPrint(DEBUG_ALWAYS, "Error: Parameter missing !\n");
00122     usage(argv[0]);
00123       }
00124 
00125       config_file_ = strdup(optarg);
00126 
00127       break;
00128 
00129     case '?':
00130 
00131       DiffPrint(DEBUG_ALWAYS,
00132         "Error: %c isn't a valid option or its parameter is missing !\n", optopt);
00133       usage(argv[0]);
00134 
00135       break;
00136 
00137     case ':':
00138 
00139       DiffPrint(DEBUG_ALWAYS, "Parameter missing !\n");
00140       usage(argv[0]);
00141 
00142       break;
00143 
00144     }
00145 
00146     if (opt == -1)
00147       break;
00148   }
00149 
00150   diffusion_port_ = diff_port;
00151 }

Here is the call graph for this function:

void TPPPingSenderApp::recv NRAttrVec data,
NR::handle  my_handle
 

Definition at line 100 of file 2pp_ping_sender.cc.

References DEBUG_ALWAYS, DiffPrint(), NRAttribute::DISINTEREST_CLASS, NRSimpleAttribute< T >::getVal(), NRAttribute::INTEREST_CLASS, NRClassAttr, and num_subscriptions_.

Referenced by TPPPingSenderReceive::recv().

00101 {
00102   NRSimpleAttribute<int> *nrclass = NULL;
00103 
00104   nrclass = NRClassAttr.find(data);
00105 
00106   if (!nrclass){
00107     DiffPrint(DEBUG_ALWAYS, "Received a BAD packet !\n");
00108     return;
00109   }
00110 
00111   switch (nrclass->getVal()){
00112 
00113   case NRAttribute::INTEREST_CLASS:
00114 
00115     DiffPrint(DEBUG_ALWAYS, "Received an Interest message !\n");
00116     num_subscriptions_++;
00117     break;
00118 
00119   case NRAttribute::DISINTEREST_CLASS:
00120 
00121     DiffPrint(DEBUG_ALWAYS, "Received a Disinterest message !\n");
00122     num_subscriptions_--;
00123     break;
00124 
00125   default:
00126 
00127     DiffPrint(DEBUG_ALWAYS, "Received an unknown message (%d)!\n", nrclass->getVal());
00128     break;
00129 
00130   }
00131 }

Here is the call graph for this function:

void TPPPingSenderApp::run  )  [virtual]
 

Implements DiffApp.

Definition at line 168 of file 2pp_ping_sender.cc.

References AppCounterAttr, counterAttr_, data_attr_, DEBUG_ALWAYS, DiffPrint(), DiffApp::dr_, GetTime(), NRSimpleAttribute< void * >::getVal(), NRAttribute::IS, last_seq_sent_, lastEventTime_, num_subscriptions_, pubHandle_, EventTime::seconds_, NR::send(), SEND_DATA_INTERVAL, setupPublication(), setupSubscription(), NRSimpleAttribute< T >::setVal(), subHandle_, TimeAttr, timeAttr_, and EventTime::useconds_.

Referenced by main().

00169 {
00170   struct timeval tmv;
00171 #ifndef NS_DIFFUSION
00172   int retval;
00173 #endif // !NS_DIFFUSION
00174 
00175 #ifdef INTERACTIVE
00176   char input;
00177   fd_set FDS;
00178 #endif // INTERATIVE
00179 
00180   // Setup publication and subscription
00181   subHandle_ = setupSubscription();
00182   pubHandle_ = setupPublication();
00183 
00184   // Create time attribute
00185   GetTime(&tmv);
00186   lastEventTime_ = new EventTime;
00187   lastEventTime_->seconds_ = tmv.tv_sec;
00188   lastEventTime_->useconds_ = tmv.tv_usec;
00189   timeAttr_ = TimeAttr.make(NRAttribute::IS, (void *) &lastEventTime_,
00190                 sizeof(EventTime));
00191   data_attr_.push_back(timeAttr_);
00192 
00193   // Change pointer to point to attribute's payload
00194   delete lastEventTime_;
00195   lastEventTime_ = (EventTime *) timeAttr_->getVal();
00196 
00197   // Create counter attribute
00198   counterAttr_ = AppCounterAttr.make(NRAttribute::IS, last_seq_sent_);
00199   data_attr_.push_back(counterAttr_);
00200 
00201 #ifndef NS_DIFFUSION
00202   // Main thread will send ping probes
00203   while(1){
00204 #ifdef INTERACTIVE
00205     FD_SET(0, &FDS);
00206     fprintf(stdout, "Press <Enter> to send a ping probe...");
00207     fflush(NULL);
00208     select(1, &FDS, NULL, NULL, NULL);
00209     input = getc(stdin);
00210 #else
00211     sleep(SEND_DATA_INTERVAL);
00212 #endif // INTERACTIVE
00213 
00214     // Send data packet if we have active subscriptions
00215     if (num_subscriptions_ > 0){
00216       // Update time in the packet
00217       GetTime(&tmv);
00218       lastEventTime_->seconds_ = tmv.tv_sec;
00219       lastEventTime_->useconds_ = tmv.tv_usec;
00220 
00221       // Send data probe
00222       DiffPrint(DEBUG_ALWAYS, "Node%d: Sending Data %d\n", ((DiffusionRouting *)dr_)->getNodeId(), last_seq_sent_);
00223       retval = dr_->send(pubHandle_, &data_attr_);
00224 
00225       // Update counter
00226       last_seq_sent_++;
00227       counterAttr_->setVal(last_seq_sent_);
00228     }
00229   }
00230 #else
00231   send();
00232 #endif // !NS_DIFFUSION
00233 }

Here is the call graph for this function:

handle TPPPingSenderApp::setupPublication  )  [private]
 

Definition at line 151 of file 2pp_ping_sender.cc.

References ClearAttrs(), NRAttribute::DATA_CLASS, DiffApp::dr_, NRAttribute::IS, LatitudeAttr, LongitudeAttr, NRAlgorithmAttr, NRClassAttr, NR::publish(), TargetAttr, and NRAttribute::TWO_PHASE_PULL_ALGORITHM.

Referenced by run().

00152 {
00153   NRAttrVec attrs;
00154 
00155   attrs.push_back(NRClassAttr.make(NRAttribute::IS, NRAttribute::DATA_CLASS));
00156   attrs.push_back(NRAlgorithmAttr.make(NRAttribute::IS, NRAttribute::TWO_PHASE_PULL_ALGORITHM));
00157   attrs.push_back(LatitudeAttr.make(NRAttribute::IS, 60.00));
00158   attrs.push_back(LongitudeAttr.make(NRAttribute::IS, 54.00));
00159   attrs.push_back(TargetAttr.make(NRAttribute::IS, "F117A"));
00160 
00161   handle h = dr_->publish(&attrs);
00162 
00163   ClearAttrs(&attrs);
00164 
00165   return h;
00166 }

Here is the call graph for this function:

handle TPPPingSenderApp::setupSubscription  )  [private]
 

Definition at line 133 of file 2pp_ping_sender.cc.

References ClearAttrs(), NRAttribute::DATA_CLASS, DiffApp::dr_, NRAttribute::IS, LatitudeAttr, LongitudeAttr, mr_, NRAttribute::NE, NRAttribute::NODE_LOCAL_SCOPE, NRAlgorithmAttr, NRClassAttr, NRScopeAttr, NR::subscribe(), TargetAttr, and NRAttribute::TWO_PHASE_PULL_ALGORITHM.

Referenced by run().

00134 {
00135   NRAttrVec attrs;
00136 
00137   attrs.push_back(NRClassAttr.make(NRAttribute::NE, NRAttribute::DATA_CLASS));
00138   attrs.push_back(NRAlgorithmAttr.make(NRAttribute::IS, NRAttribute::TWO_PHASE_PULL_ALGORITHM));
00139   attrs.push_back(NRScopeAttr.make(NRAttribute::IS, NRAttribute::NODE_LOCAL_SCOPE));
00140   attrs.push_back(TargetAttr.make(NRAttribute::IS, "F117A"));
00141   attrs.push_back(LatitudeAttr.make(NRAttribute::IS, 60.00));
00142   attrs.push_back(LongitudeAttr.make(NRAttribute::IS, 54.00));
00143 
00144   handle h = dr_->subscribe(&attrs, mr_);
00145 
00146   ClearAttrs(&attrs);
00147 
00148   return h;
00149 }

Here is the call graph for this function:

void DiffApp::usage char *  s  )  [protected, inherited]
 

Reimplemented in GearReceiverApp, and GearSenderApp.

Definition at line 66 of file diffapp.cc.

References DEBUG_ALWAYS, and DiffPrint().

Referenced by DiffApp::parseCommandLine().

00066                           {
00067   DiffPrint(DEBUG_ALWAYS, "Usage: %s [-d debug] [-p port] [-f file] [-h]\n\n", s);
00068   DiffPrint(DEBUG_ALWAYS, "\t-d - Sets debug level (0-10)\n");
00069   DiffPrint(DEBUG_ALWAYS, "\t-p - Uses port 'port' to talk to diffusion\n");
00070   DiffPrint(DEBUG_ALWAYS, "\t-f - Specifies a config file\n");
00071   DiffPrint(DEBUG_ALWAYS, "\t-h - Prints this information\n");
00072   DiffPrint(DEBUG_ALWAYS, "\n");
00073   exit(0);
00074 }

Here is the call graph for this function:


Field Documentation

char* DiffApp::config_file_ [protected, inherited]
 

Definition at line 79 of file diffapp.hh.

Referenced by GearSenderApp::parseCommandLine(), GearReceiverApp::parseCommandLine(), and DiffApp::parseCommandLine().

NRSimpleAttribute<int>* TPPPingSenderApp::counterAttr_ [private]
 

Definition at line 96 of file 2pp_ping_sender.hh.

Referenced by run().

NRAttrVec TPPPingSenderApp::data_attr_ [private]
 

Definition at line 94 of file 2pp_ping_sender.hh.

Referenced by run().

u_int16_t DiffApp::diffusion_port_ [protected, inherited]
 

Definition at line 78 of file diffapp.hh.

Referenced by GeoRoutingFilter::GeoRoutingFilter(), GradientFilter::GradientFilter(), OnePhasePullFilter::OnePhasePullFilter(), GearSenderApp::parseCommandLine(), GearReceiverApp::parseCommandLine(), DiffApp::parseCommandLine(), RmstFilter::RmstFilter(), RmstSink::RmstSink(), and SrcRtFilter::SrcRtFilter().

NR* DiffApp::dr_ [protected, inherited]
 

Definition at line 77 of file diffapp.hh.

Referenced by GeoRoutingFilter::beaconTimeout(), GeoRoutingFilter::broadcastHeuristicValue(), RmstFilter::cleanUpRmst(), GradientFilter::forwardData(), OnePhasePullFilter::forwardData(), GradientFilter::forwardExploratoryData(), GradientFilter::forwardPushExploratoryData(), GeoRoutingFilter::GeoRoutingFilter(), RmstSource::getDr(), RmstSink::getDr(), GeoRoutingFilter::getNodeLocation(), GradientFilter::GradientFilter(), OnePhasePullFilter::gradientTimeout(), GradientFilter::interestTimeout(), OnePhasePullFilter::interestTimeout(), GradientFilter::messageTimeout(), OnePhasePullFilter::messageTimeout(), GeoRoutingFilter::messageTimeout(), OnePhasePullFilter::OnePhasePullFilter(), GeoRoutingFilter::postProcessFilter(), GeoRoutingFilter::preProcessFilter(), RmstFilter::processExpReq(), SrcRtFilter::ProcessMessage(), GradientFilter::processNewMessage(), OnePhasePullFilter::processNewMessage(), GradientFilter::processOldMessage(), OnePhasePullFilter::processOldMessage(), RmstFilter::processTimer(), TagFilter::recv(), SrcRtFilter::recv(), RmstFilter::recv(), PushReceiverApp::recv(), LogFilter::recv(), GearReceiverApp::recv(), TPPPingReceiverApp::recv(), OPPPingReceiverApp::recv(), GradientFilter::reinforcementTimeout(), OnePhasePullFilter::reinforcementTimeout(), RmstFilter::RmstFilter(), RmstSink::RmstSink(), RmstFilter::run(), PushSenderApp::run(), GearSenderApp::run(), GeoRoutingFilter::run(), run(), OPPPingSenderApp::run(), RmstFilter::sendAckToSource(), RmstSource::sendBlob(), RmstFilter::sendContToSource(), RmstFilter::sendExpReqUpstream(), GradientFilter::sendInterest(), OnePhasePullFilter::sendInterest(), GeoRoutingFilter::sendNeighborRequest(), GradientFilter::sendPositiveReinforcement(), RmstFilter::sendRmstToSink(), GradientFilter::setupFilter(), TagFilter::setupFilter(), SrcRtFilter::setupFilter(), RmstFilter::setupFilter(), OnePhasePullFilter::setupFilter(), LogFilter::setupFilter(), RmstSink::setupInterest(), GeoRoutingFilter::setupPostFilter(), GeoRoutingFilter::setupPreFilter(), PushSenderApp::setupPublication(), GearSenderApp::setupPublication(), setupPublication(), OPPPingSenderApp::setupPublication(), RmstSource::setupRmstInterest(), RmstSource::setupRmstPublication(), PushReceiverApp::setupSubscription(), GearSenderApp::setupSubscription(), GearReceiverApp::setupSubscription(), setupSubscription(), TPPPingReceiverApp::setupSubscription(), OPPPingSenderApp::setupSubscription(), OPPPingReceiverApp::setupSubscription(), and SrcRtFilter::SrcRtFilter().

int TPPPingSenderApp::last_seq_sent_ [private]
 

Definition at line 93 of file 2pp_ping_sender.hh.

Referenced by run().

EventTime* TPPPingSenderApp::lastEventTime_ [private]
 

Definition at line 97 of file 2pp_ping_sender.hh.

Referenced by run().

TPPPingSenderReceive* TPPPingSenderApp::mr_ [private]
 

Definition at line 87 of file 2pp_ping_sender.hh.

Referenced by setupSubscription().

int TPPPingSenderApp::num_subscriptions_ [private]
 

Definition at line 92 of file 2pp_ping_sender.hh.

Referenced by recv(), and run().

handle TPPPingSenderApp::pubHandle_ [private]
 

Definition at line 89 of file 2pp_ping_sender.hh.

Referenced by run().

handle TPPPingSenderApp::subHandle_ [private]
 

Definition at line 88 of file 2pp_ping_sender.hh.

Referenced by run().

NRSimpleAttribute<void *>* TPPPingSenderApp::timeAttr_ [private]
 

Definition at line 95 of file 2pp_ping_sender.hh.

Referenced by run().


The documentation for this class was generated from the following files:
Generated on Tue Mar 6 17:34:46 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6