aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--ui/cli/tap-macltestat.c8
-rw-r--r--ui/cli/tap-rlcltestat.c8
-rw-r--r--ui/gtk/mac_lte_stat_dlg.c8
-rw-r--r--ui/gtk/rlc_lte_stat_dlg.c8
4 files changed, 29 insertions, 3 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)
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)
diff --git a/ui/gtk/mac_lte_stat_dlg.c b/ui/gtk/mac_lte_stat_dlg.c
index a7ebc6eea9..35381b1266 100644
--- a/ui/gtk/mac_lte_stat_dlg.c
+++ b/ui/gtk/mac_lte_stat_dlg.c
@@ -23,7 +23,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -625,9 +624,16 @@ static void mac_lte_ue_details(mac_lte_ep_t *mac_stat_ep, mac_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 {
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)
{