12.07.2015 Views

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 ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

42.1.2 I<strong>ns</strong>erting a Loss ModuleWhen studying a protocol (e.g., SRM error recovery mechanism), it might be useful to study protocol behavior over lossylinks. However, since a session level simul<strong>at</strong>ion scales by abstracting out the internal topology, we need additional mechanismsto i<strong>ns</strong>ert a loss module appropri<strong>at</strong>ely. This subsection describes how one can cre<strong>at</strong>e these loss modules to model errorscenarios.Cre<strong>at</strong>ing a Loss Module Before we can i<strong>ns</strong>ert a loss module in between a source-receiver pair, we have to cre<strong>at</strong>e the lossmodule. Basically, a loss module compares two values to decide whether to drop a packet. <strong>The</strong> first value is obtained everytime when the loss module receives a packet from a r<strong>and</strong>om variable. <strong>The</strong> second value is fixed <strong>and</strong> configured when the lossmodule is cre<strong>at</strong>ed.<strong>The</strong> following code gives an example to cre<strong>at</strong>e a uniform 0.1 loss r<strong>at</strong>e.# cre<strong>at</strong>ing the uniform distribution r<strong>and</strong>om variableset loss_r<strong>and</strong>om_variable [new R<strong>and</strong>omVariable/Uniform]$loss_r<strong>and</strong>om_variable set min_ 0;# set the range of the r<strong>and</strong>om variable$loss_r<strong>and</strong>om_variable set max_ 100set loss_module [new ErrorModel];# cre<strong>at</strong>e the error model$loss_module drop-target [new Agent/Null]$loss_module set r<strong>at</strong>e_ 10 ;# set error r<strong>at</strong>e to 0.1 = 10 / (100 − 0)$loss_module ranvar $loss_r<strong>and</strong>om_variable;# <strong>at</strong>tach r<strong>and</strong>om var. to loss moduleA c<strong>at</strong>alogue of the r<strong>and</strong>om variable distributio<strong>ns</strong> was described earlier (Chapter 25). A more detailed discussion of errormodels was also described earlier in a different chapter (Chapter 13).I<strong>ns</strong>erting a Loss Module A loss module can only be i<strong>ns</strong>erted after the corresponding receiver has joined the group. <strong>The</strong>example code below illustr<strong>at</strong>es how a simul<strong>at</strong>ion script can introduce a loss module.set sessionhelper [$<strong>ns</strong> cre<strong>at</strong>e-session $node $src] ;# keep a h<strong>and</strong>le to the loss module$<strong>ns</strong> <strong>at</strong> 0.1 "$sessionhelper i<strong>ns</strong>ert-depended-loss $loss_module $rcvr"42.2 Architecture<strong>The</strong> purpose of Session-level packet distribution is to speed up simul<strong>at</strong>io<strong>ns</strong> <strong>and</strong> reduce memory co<strong>ns</strong>umption while maintainingreasonable accuracy. <strong>The</strong> first bottleneck observed is the memory co<strong>ns</strong>umption by heavy-weight links <strong>and</strong> nodes.<strong>The</strong>refore, in SessionSim (Simul<strong>at</strong>or for Session-level packet distribution), we keep only minimal amount of st<strong>at</strong>es for links<strong>and</strong> nodes, <strong>and</strong> connect the higher level source <strong>and</strong> receiver applic<strong>at</strong>io<strong>ns</strong> with appropri<strong>at</strong>e delay <strong>and</strong> loss modules. A particularsource in a group sends its d<strong>at</strong>a packets to a replic<strong>at</strong>or th<strong>at</strong> is respo<strong>ns</strong>ible for replic<strong>at</strong>ing the packets for all the receivers.Intermedi<strong>at</strong>e loss <strong>and</strong> delay modules between this replic<strong>at</strong>or <strong>and</strong> the receivers will guarantee the appropri<strong>at</strong>e end-to-end characteristics.To put it another way, a session level simul<strong>at</strong>ion abstracts out the topology, routing <strong>and</strong> queueing delays. Packetsin SessionSim do not get routed. <strong>The</strong>y only follow the established Session.374

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!