1. Create two ping agents and attach them to the nodes between which the Round Trip Time is to be calculated.
2. When ping packet is received the recv{} procedure is called
The member variable ‘node_’ of the base class ‘Agent’ is used to get the node id for the node to which the agent is attached and the variable rtt gives the Round Trip Time.
This article is taken from my old blog.