I don't know what you exactly mean... Energy is a dynamic value. It
decreases throughout the simulation process.

If you just want to know the energy value, you can find it in the trace file
after the simulation... Almost every line of packet log contains the energy
details at that time.

In my code, I would like to get the real time energy value during runtime.
I use the following code to get the pointer to the EnergyModel and then call
its energy() function to get the real time energy during runtime.

Tcl& tcl = Tcl::instance();
    //exec tcl command to get netif_
    sprintf(tcl.buffer(), "$node_(%d) set netif_(0)", node_id);
    tcl.eval();
    //lookup and find the network interface
    netif_ = (WirelessPhy *) TclObject::lookup(tcl.result());
    if (netif_ == 0) {
        fprintf(stderr, "Agent: lookup netif_ failed.\n");
    } else {
        energy_model = (EnergyModel *) (netif_->node()->energy_model());
        cout << "energy: " << energy_model->energy() << endl;
    }


On Thu, Mar 25, 2010 at 3:33 AM, deepika jayakodi <deep_...@yahoo.co.in>wrote:

> hi
>
> i am implementing a project using ns2 and require some help. i want to
> extract the energy value of each node in my tcl script. i have used the
> enrgy model but am not able to find how to access energy value of a node.
>
> thanks in advance..
>
>
> ------------------------------
> Your Mail works best with the New Yahoo Optimized IE8. Get it 
> NOW!<http://in.rd.yahoo.com/tagline_ie8_new/*http://downloads.yahoo.com/in/internetexplorer/>
> .
>

Reply via email to