1

I am trying to compute the distance between two mobile nodes in veins and i am using the following method

  WaveShortMessage * pos = new WaveShortMessage();
                Coord senderPosition = pos->getSenderPos();
                Coord receiverPosition = traci->getPositionAt(simTime());
                double distance = senderPosition.distance(receiverPosition);

I want to know if this is the correct method for computing distance between two nodes and if the given distance is in meters or centimeters because the value it returns is very large so i'm assuming that it is in centimeter. Thanks in advance.

1 Answers1

0

Yes, the Coord::distance method is the right one to call for calculating how far away two points are.

Note, though, that you are not initializing the sender position before reading it. This way, you are likely getting random values when trying to read

Christoph Sommer
  • 6,893
  • 1
  • 17
  • 35
  • Thankyou so much for your response. yes i got your point I'm trying to implement different flooding techniques actually the problem is in sender position i am getting the position of the node that is generating the message but besides that i also want to know the position of the node that is rebroadcasting the message. Do you know how i can do that? – Muddasar Raza Sep 20 '17 at 12:18
  • If you believe your original question has been answered and you would like to ask a different one, kindly open a new question. If your original question has not been answered feel free to ask for clarification – Christoph Sommer Sep 20 '17 at 12:20
  • It has been answered i will open a new question. Thanks – Muddasar Raza Sep 20 '17 at 12:25