diff options
author | Martin Mathieson <martin.r.mathieson@googlemail.com> | 2012-07-06 01:52:09 +0000 |
---|---|---|
committer | Martin Mathieson <martin.r.mathieson@googlemail.com> | 2012-07-06 01:52:09 +0000 |
commit | 4c647041d442350fa96d204b4ab0a62bda39d446 (patch) | |
tree | 380f8de04d670b0509983cae65161bacb751e057 /ui/gtk/rlc_lte_stat_dlg.c | |
parent | 217514e5658a60a85342881e3f313c1ce69bc56d (diff) | |
download | wireshark-4c647041d442350fa96d204b4ab0a62bda39d446.tar.gz |
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/gtk/rlc_lte_stat_dlg.c')
-rw-r--r-- | ui/gtk/rlc_lte_stat_dlg.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ui/gtk/rlc_lte_stat_dlg.c b/ui/gtk/rlc_lte_stat_dlg.c index 943a5a560f..f08abb8d2b 100644 --- a/ui/gtk/rlc_lte_stat_dlg.c +++ b/ui/gtk/rlc_lte_stat_dlg.c @@ -574,9 +574,16 @@ static void invalidate_channel_iters(rlc_lte_stat_t *hs) /* 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 { @@ -585,7 +592,6 @@ static float calculate_bw(nstime_t *start_time, nstime_t *stop_time, guint32 byt } - /* Draw the channels table according to the current UE selection */ static void rlc_lte_channels(rlc_lte_ep_t *rlc_stat_ep, rlc_lte_stat_t *hs) { |