tools.cc File Reference

#include <math.h>
#include "tools.hh"

Include dependency graph for tools.cc:

Go to the source code of this file.

Functions

void DiffPrint (int msg_debug_level, const char *fmt,...)
void DiffPrintWithTime (int msg_debug_level, const char *fmt,...)
int GetRand ()
void GetTime (struct timeval *tv)
void SetSeed (struct timeval *tv)

Variables

int global_debug_level = DEBUG_DEFAULT


Function Documentation

void DiffPrint int  msg_debug_level,
const char *  fmt,
  ...
 

Definition at line 93 of file tools.cc.

References global_debug_level.

Referenced by LearnedCostTable::addEntry(), HeuristicValueTable::addEntry(), DiffusionRouting::addFilter(), AllocateBuffer(), RmstFilter::cleanUpRmst(), CopyAttrs(), NR::createNR(), RoundIdEntry::deleteExpiredGradients(), RoutingEntry::deleteExpiredRoundIds(), RoundIdEntry::deleteExpiredSinks(), RoundIdEntry::deleteGradient(), Rmst::delHole(), DiffusionCoreAgent::DiffusionCoreAgent(), DiffusionRouting::DiffusionRouting(), DiffusionRouting::filterKeepaliveTimeout(), DiffusionCoreAgent::filterTimeout(), OnePhasePullFilter::forwardData(), RoutingEntry::getNeighborFromFlow(), TagFilter::getNodeId(), GetTime(), GradientFilter::GradientFilter(), GradientFilter::gradientTimeout(), OnePhasePullFilter::gradientTimeout(), GradientFilter::interestTimeout(), OnePhasePullFilter::interestTimeout(), DiffusionRouting::interestTimeout(), IOLog::IOLog(), DiffusionRouting::isPushData(), LogFilter::LogFilter(), GradientFilter::messageTimeout(), OnePhasePullFilter::messageTimeout(), DiffusionCoreAgent::neighborsTimeout(), OnePhasePullFilter::OnePhasePullFilter(), GeoLocation::output(), Region::output(), GearSenderApp::parseCommandLine(), GearReceiverApp::parseCommandLine(), DiffApp::parseCommandLine(), PrintAttrs(), PrintTime(), DiffusionCoreAgent::processControlMessage(), DiffusionRouting::processControlMessage(), RmstFilter::processCtrlMessage(), RmstFilter::processExpReq(), TagFilter::ProcessMessage(), SrcRtFilter::ProcessMessage(), RmstFilter::processMessage(), LogFilter::ProcessMessage(), GradientFilter::processNewMessage(), OnePhasePullFilter::processNewMessage(), GradientFilter::processOldMessage(), OnePhasePullFilter::processOldMessage(), RmstFilter::processTimer(), DiffusionRouting::publish(), GearSenderApp::readGeographicCoordinates(), GearReceiverApp::readGeographicCoordinates(), TagFilter::recv(), SrcRtFilter::recv(), PushReceiverApp::recv(), OnePhasePullFilter::recv(), LogFilter::recv(), GearSenderApp::recv(), GearReceiverApp::recv(), TPPPingSenderApp::recv(), TPPPingReceiverApp::recv(), OPPPingSenderApp::recv(), OPPPingReceiverApp::recv(), DiffusionCoreAgent::recvMessage(), GradientFilter::reinforcementTimeout(), OnePhasePullFilter::reinforcementTimeout(), DiffusionCoreAgent::restoreOriginalHeader(), RmstFilter::RmstFilter(), TagFilter::run(), SrcRtFilter::run(), RmstFilter::run(), PushSenderApp::run(), LogFilter::run(), GearSenderApp::run(), TPPPingSenderApp::run(), OPPPingSenderApp::run(), DiffusionRouting::send(), RmstFilter::sendAckToSource(), RmstFilter::sendContToSource(), GradientFilter::sendDisinterest(), OnePhasePullFilter::sendDisinterest(), RmstFilter::sendExpReqUpstream(), DiffusionCoreAgent::sendMessage(), GradientFilter::sendPositiveReinforcement(), DiffusionRouting::sendRmst(), RmstFilter::sendRmstToSink(), RmstFilter::setupNak(), SrcRtFilter::SrcRtFilter(), DiffusionRouting::subscribe(), GradientFilter::subscriptionTimeout(), OnePhasePullFilter::subscriptionTimeout(), Rmst::syncHoleMap(), RmstFilter::syncLocalCache(), TagFilter::TagFilter(), DiffusionCoreAgent::timeToStop(), UnpackAttrs(), GearSenderApp::usage(), GearReceiverApp::usage(), DiffusionCoreAgent::usage(), and DiffApp::usage().

00094 {
00095   va_list ap;
00096 
00097   va_start(ap, fmt);
00098 
00099   if (global_debug_level >= msg_debug_level){
00100     // Print message
00101     vfprintf(stderr, fmt, ap);
00102     fflush(NULL);
00103   }
00104 
00105   va_end(ap);
00106 }

void DiffPrintWithTime int  msg_debug_level,
const char *  fmt,
  ...
 

Definition at line 108 of file tools.cc.

References GetTime(), and global_debug_level.

Referenced by GeoRoutingFilter::beaconTimeout(), GeoRoutingFilter::estimateCost(), GeoRoutingFilter::findNextHop(), GeoRoutingFilter::floodInsideRegion(), GeoRoutingFilter::GeoRoutingFilter(), GeoRoutingFilter::getNodeLocation(), GeoRoutingFilter::messageTimeout(), GeoRoutingFilter::neighborTimeout(), GeoRoutingFilter::postProcessFilter(), GeoRoutingFilter::preProcessFilter(), GeoRoutingFilter::preProcessMessage(), GeoRoutingFilter::recv(), GeoRoutingFilter::run(), GeoRoutingFilter::sendNeighborRequest(), GeoRoutingFilter::stripOutHeader(), and GeoRoutingFilter::updateNeighbor().

00109 {
00110   struct timeval tv;
00111   va_list ap;
00112 
00113   va_start(ap, fmt);
00114 
00115   if (global_debug_level >= msg_debug_level){
00116     // Get time
00117     GetTime(&tv);
00118 
00119     // Print Time
00120     fprintf(stderr, "%ld.%06ld : ", tv.tv_sec, tv.tv_usec);
00121     // Print message
00122     vfprintf(stderr, fmt, ap);
00123     fflush(NULL);
00124   }
00125 
00126   va_end(ap);
00127 }

Here is the call graph for this function:

int GetRand  ) 
 

Definition at line 84 of file tools.cc.

References Random::random().

Referenced by GeoRoutingFilter::broadcastHeuristicValue(), DiffusionCoreAgent::DiffusionCoreAgent(), DiffusionRouting::DiffusionRouting(), GeoRoutingFilter::GeoRoutingFilter(), GradientFilter::GradientFilter(), DiffusionRouting::interestTimeout(), OnePhasePullFilter::OnePhasePullFilter(), GeoRoutingFilter::preProcessFilter(), GradientFilter::processNewMessage(), OnePhasePullFilter::processNewMessage(), EventQueue::randDelay(), GeoRoutingFilter::sendNeighborRequest(), GradientFilter::sendPositiveReinforcement(), DiffusionRouting::sendRmst(), and DiffusionRouting::subscribe().

00085 {
00086 #ifdef NS_DIFFUSION
00087   return (Random::random());
00088 #else
00089   return (rand());
00090 #endif // NS_DIFFUSION
00091 }

Here is the call graph for this function:

void GetTime struct timeval *  tv  ) 
 

Definition at line 55 of file tools.cc.

References Scheduler::clock(), DEBUG_NEVER, DiffPrint(), Scheduler::instance(), and sec.

Referenced by RoutingEntry::addGradient(), AgentEntry::AgentEntry(), AttributeEntry::AttributeEntry(), GeoRoutingFilter::beaconTimeout(), GeoRoutingFilter::checkNeighbors(), DataNeighborEntry::DataNeighborEntry(), RoundIdEntry::deleteExpiredGradients(), RoutingEntry::deleteExpiredRoundIds(), RoundIdEntry::deleteExpiredSinks(), DiffPrintWithTime(), DiffusionCoreAgent::DiffusionCoreAgent(), DiffusionRouting::DiffusionRouting(), DiffusionStats::DiffusionStats(), EventQueue::eqNextTimer(), EventQueue::eqTopInPast(), FilterEntry::FilterEntry(), DiffusionCoreAgent::filterTimeout(), GeoRoutingFilter::GeoRoutingFilter(), GradientEntry::GradientEntry(), GradientFilter::GradientFilter(), GradientFilter::gradientTimeout(), HandleEntry::HandleEntry(), DiffusionStats::ignoreEvent(), NeighborEntry::NeighborEntry(), DiffusionCoreAgent::neighborsTimeout(), GeoRoutingFilter::neighborTimeout(), OnePhasePullFilter::OnePhasePullFilter(), OPPGradientEntry::OPPGradientEntry(), GeoRoutingFilter::preProcessFilter(), DiffusionStats::printStats(), DiffusionCoreAgent::processControlMessage(), RmstFilter::processTimer(), Rmst::putHole(), RmstSrcReceive::recv(), RmstSnkReceive::recv(), PushReceiverApp::recv(), GearReceiverApp::recv(), TPPPingReceiverApp::recv(), OPPPingReceiverApp::recv(), IOLog::recvPacket(), RoundIdEntry::RoundIdEntry(), RoutingEntry::RoutingEntry(), PushSenderApp::run(), GearSenderApp::run(), TPPPingSenderApp::run(), OPPPingSenderApp::run(), DiffusionRouting::send(), GeoRoutingFilter::sendNeighborRequest(), IOLog::sendPacket(), EventQueue::setDelay(), SinkEntry::SinkEntry(), SubscriptionEntry::SubscriptionEntry(), GradientFilter::subscriptionTimeout(), OnePhasePullFilter::subscriptionTimeout(), RmstFilter::syncLocalCache(), TimerManager::TimerManager(), TppRoutingEntry::TppRoutingEntry(), GradientFilter::updateAgent(), GradientFilter::updateGradient(), GeoRoutingFilter::updateNeighbor(), and RoundIdEntry::updateSink().

00056 {
00057 #ifdef NS_DIFFUSION
00058   double time;
00059   long sec, usec;
00060 
00061   time = Scheduler::instance().clock();
00062   // sec = lrint (time);
00063   sec = (long) rint (time);
00064   // usec = lrint ((time - sec) * 1000000);
00065   usec = (long) rint ((time - sec) * 1000000);
00066   tv->tv_sec = sec;
00067   tv->tv_usec = usec;
00068   DiffPrint(DEBUG_NEVER, "tv->sec = %ld, tv->usec = %ld\n", tv->tv_sec, tv->tv_usec);
00069 #else
00070   gettimeofday(tv, NULL);
00071 #endif // NS_DIFFUSION
00072 }

Here is the call graph for this function:

void SetSeed struct timeval *  tv  ) 
 

Definition at line 74 of file tools.cc.

Referenced by DiffusionCoreAgent::DiffusionCoreAgent(), DiffusionRouting::DiffusionRouting(), GeoRoutingFilter::GeoRoutingFilter(), GradientFilter::GradientFilter(), OnePhasePullFilter::OnePhasePullFilter(), and TimerManager::TimerManager().

00075 {
00076 #ifdef NS_DIFFUSION
00077   // Don't need to do anything since NS's RNG is seeded using
00078   // otcl proc ns-random <seed>
00079 #else
00080   srand(tv->tv_usec);
00081 #endif // NS_DIFFUSION
00082 }


Variable Documentation

int global_debug_level = DEBUG_DEFAULT
 

Definition at line 53 of file tools.cc.

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


Generated on Tue Mar 6 17:01:28 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6