mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-31 00:23:50 +00:00
Return an error code if ping didn't hear any responses, always log statistics
This commit is contained in:
parent
bae1ab310c
commit
481dc9218d
@ -819,6 +819,8 @@ int app_mdp_ping(int argc, const char *const *argv, struct command_line_option *
|
||||
if (cli_arg(argc, argv, o, "count", &count, NULL, "0") == -1)
|
||||
return -1;
|
||||
|
||||
// assume we wont hear any responses
|
||||
int ret=-1;
|
||||
int icount=atoi(count);
|
||||
|
||||
overlay_mdp_frame mdp;
|
||||
@ -906,6 +908,7 @@ int app_mdp_ping(int argc, const char *const *argv, struct command_line_option *
|
||||
mdp.packetTypeAndFlags&MDP_NOSIGN?"":" SIGNED");
|
||||
// TODO Put duplicate pong detection here so that stats work properly.
|
||||
rx_count++;
|
||||
ret=0;
|
||||
rx_ms+=delay;
|
||||
if (rx_mintime>delay||rx_mintime==-1) rx_mintime=delay;
|
||||
if (delay>rx_maxtime) rx_maxtime=delay;
|
||||
@ -919,8 +922,14 @@ int app_mdp_ping(int argc, const char *const *argv, struct command_line_option *
|
||||
}
|
||||
}
|
||||
now=gettime_ms();
|
||||
if (servalShutdown) {
|
||||
if (servalShutdown)
|
||||
break;
|
||||
}
|
||||
sequence_number++;
|
||||
timeout=now+1000;
|
||||
}
|
||||
|
||||
{
|
||||
float rx_stddev=0;
|
||||
float rx_mean=rx_ms*1.0/rx_count;
|
||||
int samples=rx_count;
|
||||
@ -938,17 +947,9 @@ int app_mdp_ping(int argc, const char *const *argv, struct command_line_option *
|
||||
printf("round-trip min/avg/max/stddev%s = %lld/%.3f/%lld/%.3f ms\n",
|
||||
(samples<rx_count)?" (stddev calculated from last 1024 samples)":"",
|
||||
rx_mintime,rx_mean,rx_maxtime,rx_stddev);
|
||||
|
||||
}
|
||||
overlay_mdp_client_done();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
sequence_number++;
|
||||
timeout=now+1000;
|
||||
}
|
||||
|
||||
overlay_mdp_client_done();
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int app_config_set(int argc, const char *const *argv, struct command_line_option *o)
|
||||
|
Loading…
x
Reference in New Issue
Block a user