we can create our own function which returns the residual energy while running the simulation For example :
double AODV::get_energy(nsaddr_t addr) // edited by me { Node* thisnode = Node::get_node_by_address(addr); double energy ; energy = thisnode->energy_model()->energy(); //printf(“energy of node %d at time %f is %f\n”,ra_addr_,CURRENT_TIME,energy); return energy; }
get_energy() takes id of the node as argument and returns a double value
the above code is definition of get_energy() function in AODV in aodv.cc routing protocol file , one can define it in there concerned routing protocol file.