Tuesday, September 20, 2011

NS2 Mobility Model

Mobility models

Node mobility in MIRACLE is ruled by two classes named BMPosition and GMPosition, derived from Position class. The former utilizes a Basic Movement (BM) model and the latter uses a Gauss-Markov (GM) model.
These models are those we provide with the MIRACLE release, but you can feel free to create your own!

The Basic Movement model moves nodes in uniform straightforward way. Nodes are moved by setting their destination by using the Tcl command setdest, which accepts as inputs the coordinates of the destination and the speed (in meters per second) of the node. The true position of the node is updated only when needed, e.g. when the destination is changed or a calculation (as freespace attenuation or upon a getPosition() call) is requested by an external module. In this model no control is added about borders of simulation field, so this means that a node, reached the setdest coordinates, will move in that direction and will not stop since a new destination is set.

The GMPosition Model is more complex than the previous one. In this case, nodes perform direction changes autonomously and a control of the behavior at borders is provided. Nodes adopting this mobility model requires mean direction (in radians) and a mean speed as inputs.
Speed and direction are calculated form mean values given as inputs multiplicating them by a random value, according to the following law (the law for direction is the same):

speed_ = (alpha_*speed_) + (((1.0-alpha_))*speedMean_) +
+ (sqrt(1.0-pow(alpha_,2.0))*Gaussian());

As could be seen, the current (in this case) speed is calculated from previous value of speed and the mean speed, given as input. The incidence of the mean value is controlled by the alpha parameter, which assumes values between 0 and 1. So the variations of speed are due to the ``old'' current speed and a random value provided by the Gaussian() function. It must be noticed that even if speedMean_ is 0, the current speed could be non-zero. As in the previous model, position update is calculated when needed, but in this case every step from previous update is computed (because a gaussian walk is made of several gaussian steps). The time resolution of each step is provided by the updateTime_ variable.

There are four different behaviors for nodes reaching boundaries. These are REBOUNCE, HARDWALL, SPHERIC and THOROIDAL. In the first case the node rebounces on the border line, it means that if at least one of the coordinates exceeds the x or y field width it will be carried back in the field by a value equal to the difference between the exceeding coordinate and the field maximal coordinate. For example, if the simulation field is 100 meters wide and the new coordinate is 102 meters, then rebounce algo will carry back coordinate to 98 which is 100 - (102 - 100).
The HARDWALL behavior expects that the node stops its movement at the border of the field, if trepassed. In case of SPHERIC behavior the node will be put on the other side of the field, like an overflow. In the last case, THOROIDAL, the node is put at the centre of the field.


  1. I am in a trouble can you give me some idea to create a directional antenna based DMAC simulation in NS2.

  2. Hey,
    Do have any sample Mobiltiy Model NS-2 Code, so that it can help me with my project...
    Awaitung ur reply


  3. Congratulations for your blog. I have a question,I need to export a SUMO file to ns2, so i used the traceExporter and the that returns 3 files(mobility.tcl, activity.tcl an config.tcl)but I don't know how to load these files to ns2; this is the bug generated in cygwin:
    $ns mobility.tcl
    can't read "ns_": no such variable
    while executing
    "$ns_at 0.0 "$node_(672) setdest 244.36 370.95 0.0""

    Please help me...thanks

    1. did u resolved your problem?could help me ??thans very much..

    2. i have the same problem as you, did you resolved it?

  4. hello sir.

    how to calculate congestion level on AODV?
    help me, please.....

    best regard

  5. hello sir,
    how to make dynamic or random movement of node in the detection of intruder

    1. did you solve your problem..? can u help me please

    2. Hi

      Can i help you yes we can do the dynamic movement


Thanks for using my blog any queries or help please email to clickprasan@gmail.com . Please be careful from spammers .do not reply to any other email address other than mentioned above