aboutsummaryrefslogtreecommitdiffstats
path: root/ui/cli/tap-rlcltestat.c
diff options
context:
space:
mode:
authorMartin Mathieson <martin.r.mathieson@googlemail.com>2012-07-06 01:52:09 +0000
committerMartin Mathieson <martin.r.mathieson@googlemail.com>2012-07-06 01:52:09 +0000
commit4c647041d442350fa96d204b4ab0a62bda39d446 (patch)
tree380f8de04d670b0509983cae65161bacb751e057 /ui/cli/tap-rlcltestat.c
parent217514e5658a60a85342881e3f313c1ce69bc56d (diff)
Take yet more care not to be dividing by zero when calculating the bit
rate of the channel/UE. Times four... svn path=/trunk/; revision=43578
Diffstat (limited to 'ui/cli/tap-rlcltestat.c')
-rw-r--r--ui/cli/tap-rlcltestat.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ui/cli/tap-rlcltestat.c b/ui/cli/tap-rlcltestat.c
index 085e51ea89..ab334dd18b 100644
--- a/ui/cli/tap-rlcltestat.c
+++ b/ui/cli/tap-rlcltestat.c
@@ -284,9 +284,16 @@ rlc_lte_stat_packet(void *phs, packet_info *pinfo, epan_dissect_t *edt _U_,
/* Calculate and return a bandwidth figure, in Mbs */
static float calculate_bw(nstime_t *start_time, nstime_t *stop_time, guint32 bytes)
{
+ /* Can only calculate bandwidth if have time delta */
if (memcmp(start_time, stop_time, sizeof(nstime_t)) != 0) {
float elapsed_ms = (((float)stop_time->secs - (float)start_time->secs) * 1000) +
(((float)stop_time->nsecs - (float)start_time->nsecs) / 1000000);
+
+ /* Only really meaningful if have a few frames spread over time...
+ For now at least avoid dividing by something very close to 0.0 */
+ if (elapsed_ms < 2.0) {
+ return 0.0;
+ }
return ((bytes * 8) / elapsed_ms) / 1000;
}
else {
@@ -296,7 +303,6 @@ static float calculate_bw(nstime_t *start_time, nstime_t *stop_time, guint32 byt
-
/* (Re)draw RLC stats */
static void
rlc_lte_stat_draw(void *phs)