summaryrefslogtreecommitdiff
path: root/ui/cli/tap-macltestat.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-macltestat.c
parent217514e5658a60a85342881e3f313c1ce69bc56d (diff)
downloadwireshark-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/cli/tap-macltestat.c')
-rw-r--r--ui/cli/tap-macltestat.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ui/cli/tap-macltestat.c b/ui/cli/tap-macltestat.c
index af230da51f..cf2df41e09 100644
--- a/ui/cli/tap-macltestat.c
+++ b/ui/cli/tap-macltestat.c
@@ -395,9 +395,16 @@ mac_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 {
@@ -406,6 +413,7 @@ static float calculate_bw(nstime_t *start_time, nstime_t *stop_time, guint32 byt
}
+
/* Output the accumulated stats */
static void
mac_lte_stat_draw(void *phs)