- Home Page of ProjectGuideline.com ›
- Forums ›
- Questions Asked by Students and Scholars ›
- How to use node's coordinates in AODV packets in NS-2?
I need to add a new field(location [x,y]) to Hello packets in AODV. I define nodes location by random function in TCL. now I want to use their location in C++. what should I do exactly?
Simply you need to add your custom fields in packet header structure of ns-2 and use it in your code.
In packet.h modify the structure hdr_cmn as follows :
struct hdr_cmn {
enum dir_t { DOWN= -1, NONE= 0, UP= 1 };
packet_t ptype_; // packet type (see above)
int size_; // simulated packet size
int uid_; // unique id
int error_; // error flag
int errbitcnt_; // # of corrupted bits jahn
int fecsize_;
double ts_; // timestamp: for q-delay measurement
int iface_; // receiving interface (label)
dir_t direction_; // direction: 0=none, 1=up, -1=down
x; // the node’s x location
y; // the node’s y location
….
….
}
After that you can access that x and y values from any packet that you are creating of using.
For example, before transmitting a packet you may store the x and y location of the node in the packet header structure and then send it.
If a node which receives a packet wan to know the location from which that packet originated, then it can also read it from the received packet header.