Getting Node Position and Energy in NS2
It has been really long time since my last post my and I am back. Finally, I could make little time to write this post. I believe such information is available in elsewhere. But, I also believe explaining simple method of obtaining node position and current remaining energy would help a lot of people. I strongly suggest scanning the code of WFRP before reading the post further.
Alright, lets get on the work. First you have to include mobilenode.h (located in NSROOT/ns-2.xx/common/ ) into wfrp.h file. Add following line after #include <cmu-trace.h>
#include <mobilenode.h>
We have to make little more modifications to wfrp.h, thus change the lines from 119 to 122 (wfrp.h) as below
// Node Location double posx; // position x; double posy; // position y; // Remaining Energy double iEnergy;
At line 153 (wfrp.h) add following code
// Energy Management void update_energy(); // This node; MobileNode *iNode;
Now we are going to update actual node position and energy. Add following code to line 147 of wfrp.cc :
//initialize energy iEnergy = 0; // Get pointer to the node iNode = (MobileNode *) (Node::get_node_by_address(index));
In above code get_node_by_address(nsaddr_t id) is located in $NSROOT/ns-2.xx/common/node.h, which obtains pointer to the node according to given address. The class Node contains various information about node, including energy model, location, speed, neighbors, etc.
Update the wfrp.cc code from the line 530 as below
void
WFRP::update_position() {
iNode->update_position();
posx = iNode->X();
posy = iNode->Y();
#ifdef DEBUG
printf("U (%.6f): UPDATE POSITION, for Node %d, X: %.4f and Y : %.4f \n", CURRENT_TIME, index, posx, posy);
#endif
}
void
WFRP:: update_energy() {
iEnergy = iNode->energy_model()->energy();
#ifdef DEBUG
printf("U (%.6f): UPDATE ENERGY, for Node %d, Energy %.4f \n", CURRENT_TIME, index, iEnergy);
#endif
}
First routine (update_position) updates the position at request time and puts X and Y position to posx, posy respectively. Note, iNode->update_position() routine is in $NSROOT/ns-2.xx/common/mobilenode.cc. You may also obtain node's current speed, radio range, and Z position.
Second routine (update_energy) gets nodes current remaining energy and puts it to iEnergy. For information refer to $NSROOT/ns-2.xx/mobile/energy-model.cc.
After completing modification just re-make. For location based routing protocols this might very useful. Leave comments here if you have any problems with the code.
Note : energyModel must be set in TCL file, in order to obtain node's energy or energy model related information.
Multipath Routing in Wireless Sensor Networks
- Highly-Resilient, Energy-Efficient Multipath Routing in Wireless Sensor Networks 2001
- Multipath Virtual Sink Architecture for Wireless Sensor Networks 2006
- Label-based Multipath Routing (LMR) in Wireless Sensor Networks 2004
- Node-Disjoint Parallel Multi-Path Routing in Wireless Sensor Networks 2005
- Minimum Energy Disjoint Path Routing in Wireless Ad-Hoc Networks (Mobicom 2003)
- RELIABLE ENERGY AWARE ROUTING IN WIRELESS SENSOR NETWORKS 2007
- Reliable Splitted Multipath Routing for Wireless Sensor Networks 2004
- Towards Efficient Routing in Wireless Sensor Networks PPT
- A Dependable Multipath Routing Protocol in Wireless Sensor Networks 2006
- An energy-efficient multipath routing algorithm for wireless sensor networks 2003
- A Scalable Priority-Based Multi-Path Routing Protocol for Wireless Sensor Networks 2005 (Missing)
- Reliable Transfer on Wireless Sensor Networks 2004
- MRC: Multiplicative-increase/additive-decrease Multipath Routing In Wireless Sensor Networks 2004
- An Energy-Efficient Multipath Routing Protocol for Wireless Sensor Networks 2006
- The energy-robustness tradeoff for routing in wireless sensor networks 2003
- INSENS: Intrusion-Tolerant Routing in Wireless Sensor Networks 2003
- Optimal Multi-sink Positioning and Energy-Efficient Routing in Wireless Sensor Networks 2005
- Multi-objective Mobile Agent Routing in Wireless Sensor Networks 2005
- Meshed multipath routing with selective forwarding: an efficient strategy in wireless sensor networks 2003
- A priority-based multi-path routing protocol for sensor networks 2004
- Energy-Efficient Multipath Routing in Wireless Sensor Networks (Missing)
- Energy Efficient Routing with Guaranteed Delivery in Wireless Sensor Networks 2003
- Multipath Routing in Sensor Networks
- Multipath Routing for Data Dissemination in Energy Efficient Sensor Networks.
- MidHopRoute: a multiple path routing framework for load balancing with service differentiation in wireless sensor networks 2006 (missing)
- A Fault-tolerant Multipath Routing Protocol in Wireless Sensor Networks 2004
- Minimizing Latency in Wireless Sensor Networks - A Survey
- Reducing Congestion Effects in Wireless Networks by Multipath Routing 2006
- Multi-path delivery with selective quality along different paths(missing)
- H-SPREAD: A hybrid multipath scheme for secure and reliable data (missing)
- MIMO Techniques in Cluster-Based Wireless Sensor Networks 2006
- Efficient Routing from Multiple Sources to Multiple Sinks in Wireless Sensor Networks 2007
- Multi Mobile Agent Deployment in Wireless Sensor Networks
- A Low-Latency Routing Protocol for Wireless Sensor Networks
- A Fault-Tolerant Routing Algorithm for Wireless Sensor Networks
- PSGR: Priority-based Stateless Geo-Routing in Wireless Sensor Networks 2005
- DISJOINT AND BRAIDED MULTIPATH ROUTING FOR WIRELESS SENSOR NETWORKS 2005
- Trade-Off between Traffic Overhead and Reliability in Multipath Routing for Wireless Sensor Networks 2003
- Energy-balancing multipath routing protocol for wireless sensor networks 2006
- Spatial energy balancing through proactive multipath routing in wireless multihop networks 2007
- Disjoint multipath routing using colored trees 2007
- A Power Balanced Multipath Routing Protocol inWireless Ad-Hoc Sensor Networks 2006
- Multipath Disjoint Routing Algorithm for Ad Hoc Wireless Sensor Networks 2005
- A distributed admission control system for MANET environments supporting multipath routing protocols 2007
- An Energy-Efficient Hierarchical Multiple-Choice Routing Path Protocol for Wireless Sensor Networks 2006
- A Novel Multipath Disjoint Routing to Support Ad Hoc Wireless Sensor Networks 2006
- Performance evaluation: Node-disjointness-based multipath routing for mobile ad hoc networks 2004
- Routing & performance modelling: Multipath routing and multiple description coding in ad-hoc networks: a simulation study 2004
- Reliable Multipath Information Dissemination via Label Forwarding in Wireless Sensor Networks 2006
- MMSPEED: Multipath Multi-SPEED Protocol for QoS Guarantee of Reliability and Timeliness in Wireless Sensor Networks 2006
- Performance of multipath routing for on-demand protocols in mobile ad hoc networks 2001
- Routing optimizations: Minimum energy disjoint path routing in wireless ad-hoc networks 2003
- Multipath Fresnel Zone Routing for Wireless Ad Hoc Networks (2004)
- A Survey on Dependable Routing in Sensor Networks, Ad hoc Networks, and Cellular Networks 2004