Reputation: 161
I had developed ping utility similar to the ping example available in UnetStack1.3 (/samples/ping
) to ping a remote node over a multi-hop link, but unable to calculate the Round Trip Time (RTT), when I transmit ping packet using routing agent with static route information added to routing table using RouteDiscoveryNtf
as there is no timing information avaiable in upper layer notifications (DatagramNtf
or DatagramDeliveryNtf
or DatagramFailureNtf
).
Calculation of round trip time is the difference of rxtime
and txtime
available with TxFrameNtf
and RxFrameNtf
as implemented in clousure (fshrc.groovy
) in the ping example.
I also tried analyzing the ping utility implemented in UnetStack3, but unable to makeout. Please let me know how the RTT is calculated.
Upvotes: 2
Views: 410
Reputation: 2280
Here's a simplified version of the implementation of the ping
command in UnetStack3:
def ping(int n, int m = 3, long timeout = 30000) {
println "PING $n"
AgentID router = agentForService(Services.ROUTING)
int p = 0
m.times { count ->
def t0 = currentTimeMillis()
router << new DatagramReq(to: n, reliability: true)
def ntf = receive({
it instanceof DatagramDeliveryNtf || it instanceof DatagramFailureNtf
}, timeout)
def t = currentTimeMillis()-t0
if (ntf == null || ntf instanceof DatagramFailureNtf) {
println "Request timeout for seq $count"
} else {
p++
println "Response from $n: seq=$count rthops=2 time=$t ms"
}
delay(5000)
}
println "$m packets transmitted, $p packets received, ${Math.round(100*(m-p)/m)}% packet loss"
}
Upvotes: 1