Project

General

Profile

Actions

Bug #3504

closed

ndnping prints meaningless stats on SIGQUIT if no packets were received

Added by Davide Pesavento over 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Start date:
Due date:
% Done:

100%

Estimated time:
1.50 h

Description

$ ndnping /foo
PING /foo
timeout from /foo: seq=8527235899119463658
timeout from /foo: seq=8527235899119463659
timeout from /foo: seq=8527235899119463660
^\0/3 packets, 100% loss, min/avg/max/mdev = 1.79769e+308/-nan/0/-nan ms
timeout from /foo: seq=8527235899119463661
timeout from /foo: seq=8527235899119463662
^C
--- /foo ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 0 ms

There are in fact two issues here. One is that Statistics::printSummary() prints garbage when nReceived is zero. It should simply skip the min/avg/max/mdev part in that case (operator<< already has a similar check, and ping(8) does the same).

The second problem is that StatisticsCollector::computeStatistics() divides by zero if m_nReceived is zero. This is a floating point division by zero, so on most platforms the result will be infinity or NaN, but on others it can generate an exception and terminate the program. There should be a check against this, or we should do the division only if std::numeric_limits<double>::traps is false.

Actions

Also available in: Atom PDF