Viewing 0 reply threads
You must be logged in to reply to this topic.
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.
You must be logged in to reply to this topic.
Discuss Through WhatsApp