The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...
The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ... The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...
protected:double lastx_;double lasty_;double sum_;};From integrator.cc:Integrator::Integrator() : lastx_(0.), lasty_(0.), sum_(0.){bind("lastx_", &lastx_);bind("lasty_", &lasty_);bind("sum_", &sum_);}void Integrator::set(double x, double y){lastx_ = x;lasty_ = y;sum_ = 0.;}void Integrator::newPoint(double x, double y){sum_ += (x - lastx_) * lasty_;lastx_ = x;lasty_ = y;}int Integrator::command(int argc, const char*const* argv){if (argc == 4) {if (strcmp(argv[1], "newpoint") == 0) {double x = atof(argv[2]);double y = atof(argv[3]);newPoint(x, y);return (TCL_OK);}}return (TclObject::command(argc, argv));}This class provides a base class used by other classes such as QueueMonitor that keep running sums. Each new elementof the running sum is added by the newPoint(x, y) function. After the kth execution of newPoint, the running sum isequal to ∑ ki=1 y i−1(x i − x i−1 ) where x 0 = y 0 = 0 unless lastx_, lasty_, or sum_ are reset via OTcl. Note that a newpoint in the sum can be added either by the C++ member newPoint or the OTcl member newpoint. The use of integralsto compute certain types of averages (e.g. mean queue lengths) is given in (pp. 429–430, [15]).25.4 ns-randomns-randomis an obsolete way to generate random numbers. This information is provided only for backward compatibility.227
ns-random is implemented in ~ns/misc.{cc,h}. When called with no argument, it generates a random number with uniformdistribution between 0 and MAXINT. When an integer argument is provided, it seeds the random generater with the givennumber. A special case is when ns-random 0 is called, it randomly seeds the generator based on current time. This featureis useful to produce non-deterministic results across runs.25.5 Some mathematical-support related objectsINTEGRATOR OBJECTS Integrator Objects support the approximate computation of continuous integrals using discrete sums.The running sum(integral) is computed as: sum_ += [lasty_ * (x lastx_)] where (x, y) is the last element enteredand (lastx_, lasty_) was the element previous to that added to the sum. lastx_ and lasty_ are updated as new elements areadded. The first sample point defaults to (0,0) that can be changed by changing the values of (lastx_,lasty_). $integratornewpoint Add the point (x,y) to the sum. Note that it does not make sense for x to be less than lastx_.There are no configuration parameters specific to this object.State Variables are:lastx_ x-coordinate of the last sample point.lasty_ y-coordinate of the last sample point.sum_ Running sum (i.e. the integral) of the sample points.SAMPLES OBJECT Samples Objects support the computation of mean and variance statistics for a given sample.$samples meanReturns mean of the sample.$samples varianceReturns variance of the sample.$samples cntReturns a count of the sample points considered.$samples resetReset the Samples object to monitor a fresh set of samples.There are no configuration parameters or state variables specific to this object.25.6 Commands at a glanceFollowing is a list of mathematical support related commands commonly used in simulation scripts:set rng [new RNG]This creates a new random number generator.228
- Page 177 and 178: $ns add-isl $ltype $node1 $node2 $b
- Page 179 and 180: $satrouteobject_ compute_routeswher
- Page 181 and 182: This will add an error model to the
- Page 183 and 184: lh_firstnameobj‘‘name’’ is
- Page 185 and 186: from routing agentto Node->entrySat
- Page 187 and 188: $satnode add-isl This method c
- Page 189 and 190: set prop [new Propagation/FreeSpace
- Page 191 and 192: 18.3.2 Using shadowing modelBefore
- Page 193 and 194: Chapter 19Energy Model in nsEnergy
- Page 195 and 196: Chapter 20Directed DiffusionThe dir
- Page 197 and 198: However if we have a large and dens
- Page 199 and 200: yr application in the ns context. T
- Page 201 and 202: value of opt(pre-stop) is usually t
- Page 203 and 204: 21.2 Implementation of XCP in NSIn
- Page 205 and 206: the persistent queue length in the
- Page 207 and 208: Thruput2 0.054024 60000residue_pos_
- Page 209 and 210: Chapter 22DelayBox: Per-Flow Delay
- Page 211 and 212: $ns attach-agent $n_sink $sink# mak
- Page 213 and 214: Chapter 23Changes made to the IEEE
- Page 215 and 216: Part IIISupport214
- Page 217 and 218: endenddocument pargvcPrint out argc
- Page 219 and 220: 24.4.2 Memory Conservation TipsSome
- Page 221 and 222: Chapter 25Mathematical SupportThe s
- Page 223 and 224: set run [lindex $argv 0]}if {$run <
- Page 225 and 226: }$sizeRNG next-substream# print the
- Page 227: protected:RNG* rng_;};Classes deriv
- Page 231 and 232: Chapter 26Trace and Monitoring Supp
- Page 233 and 234: The monitor-queue function is const
- Page 235 and 236: also used to accumulate packet drop
- Page 237 and 238: }name,th->size(),flags,iph->flowid(
- Page 239 and 240: PT_TORA,PT_DSR,PT_AODV,// insert ne
- Page 241 and 242: The QueueMonitor class is not deriv
- Page 243 and 244: $ns_ trace-all This is the command
- Page 245 and 246: Chapter 27Test Suite SupportThe ns
- Page 247 and 248: ... ...}$ns_ at $opt(stop).1 "$self
- Page 249 and 250: Example: To enable debugging in Que
- Page 251 and 252: Chapter 29Unicast RoutingThis secti
- Page 253 and 254: Asymmetric Routing Asymmetric routi
- Page 255 and 256: class RouteLogic This class defines
- Page 257 and 258: — The procedure init-all{} is a g
- Page 259 and 260: Global Actions Once the detailed ac
- Page 261 and 262: This dumps next hop information in
- Page 263 and 264: $ns mrtproto ST;# specify shared tr
- Page 265 and 266: Dense Mode The Dense Mode protocol
- Page 267 and 268: and unique label (id). Thus, “inc
- Page 269 and 270: add-iif{ifid link},add-oif{link if}
- Page 271 and 272: CtrMcastComp is the centralised mul
- Page 273 and 274: $ns_ mrtproto This command specifi
- Page 275 and 276: Chapter 31Network DynamicsThis chap
- Page 277 and 278: v 0.8123 link-up 3 5v 0.8123 link-u
protected:double lastx_;double lasty_;double sum_;};From integr<strong>at</strong>or.cc:Integr<strong>at</strong>or::Integr<strong>at</strong>or() : lastx_(0.), lasty_(0.), sum_(0.){bind("lastx_", &lastx_);bind("lasty_", &lasty_);bind("sum_", &sum_);}void Integr<strong>at</strong>or::set(double x, double y){lastx_ = x;lasty_ = y;sum_ = 0.;}void Integr<strong>at</strong>or::newPoint(double x, double y){sum_ += (x - lastx_) * lasty_;lastx_ = x;lasty_ = y;}int Integr<strong>at</strong>or::comm<strong>and</strong>(int argc, co<strong>ns</strong>t char*co<strong>ns</strong>t* argv){if (argc == 4) {if (strcmp(argv[1], "newpoint") == 0) {double x = <strong>at</strong>of(argv[2]);double y = <strong>at</strong>of(argv[3]);newPoint(x, y);return (TCL_OK);}}return (TclObject::comm<strong>and</strong>(argc, argv));}This class provides a base class used by other classes such as QueueMonitor th<strong>at</strong> keep running sums. Each new elementof the running sum is added by the newPoint(x, y) function. After the kth execution of newPoint, the running sum isequal to ∑ ki=1 y i−1(x i − x i−1 ) where x 0 = y 0 = 0 unless lastx_, lasty_, or sum_ are reset via OTcl. Note th<strong>at</strong> a newpoint in the sum can be added either by the C++ member newPoint or the OTcl member newpoint. <strong>The</strong> use of integralsto compute certain types of averages (e.g. mean queue lengths) is given in (pp. 429–430, [15]).25.4 <strong>ns</strong>-r<strong>and</strong>om<strong>ns</strong>-r<strong>and</strong>omis an obsolete way to gener<strong>at</strong>e r<strong>and</strong>om numbers. This inform<strong>at</strong>ion is provided only for backward comp<strong>at</strong>ibility.227