How to get x and y position and speed of the mobile nodes in NS2 ?

C++ part :

double xpos = 0.0;
double ypos = 0.0;
double zval = 0.0;
int node_speed = 0;
MobileNode *iNode;
iNode = (MobileNode*) (Node::get_node_by_address(index));
((MobileNode *) iNode)->getLoc(&xpos,&ypos,&zpos);
printf(“Position of %d, X=%f, Y=%f, Z=%f \n “, index, xpos, ypos, zpos);;
node_speed = ((MobileNode *) iNode)->speed();
printf(“Node %d, Speed=%d \n”, index, node_speed);