summaryrefslogtreecommitdiffstats
path: root/nfvbench/packet_stats.py
diff options
context:
space:
mode:
authorahothan <ahothan@cisco.com>2018-12-07 15:05:06 -0800
committerahothan <ahothan@cisco.com>2018-12-07 15:44:57 -0800
commited1df5da8e6468ec7a0e25a853fe803bfc0af3f6 (patch)
tree273b40d578a62eded8898e190c10080a09cfedf0 /nfvbench/packet_stats.py
parent8eaf1fcc4b2b3678d62ddb081f0d912fdc92bc20 (diff)
NFVBENCH-118 VxLAN fixed rate: Trex far end port Rx counters are incorrect
Change-Id: If3d0b199f4b97f8610dea360cb9e70fabec06601 Signed-off-by: ahothan <ahothan@cisco.com>
Diffstat (limited to 'nfvbench/packet_stats.py')
-rw-r--r--nfvbench/packet_stats.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/nfvbench/packet_stats.py b/nfvbench/packet_stats.py
index 16dc965..4b9eac5 100644
--- a/nfvbench/packet_stats.py
+++ b/nfvbench/packet_stats.py
@@ -47,8 +47,13 @@ class InterfaceStats(object):
self.device = device
self.shared = shared
# RX and TX counters for this interface
+ # A None value can be set to mean that the data is not available
self.tx = 0
self.rx = 0
+ # This is a special field to hold an optional total rx count that is only
+ # used for column aggregation to compute a total intertface stats
+ # Set to non zero to be picked by the add interface stats method for rx total
+ self.rx_total = None
def get_packet_count(self, direction):
"""Get packet count for given direction.
@@ -79,8 +84,17 @@ class InterfaceStats(object):
def add_if_stats(self, if_stats):
"""Add another ifstats to this instance."""
- self.tx += if_stats.tx
- self.rx += if_stats.rx
+ def added_counter(old_value, new_value_to_add):
+ if new_value_to_add:
+ if old_value is None:
+ return new_value_to_add
+ return old_value + new_value_to_add
+ return old_value
+
+ self.tx = added_counter(self.tx, if_stats.tx)
+ self.rx = added_counter(self.rx, if_stats.rx)
+ # Add special rx total value if set
+ self.rx = added_counter(self.rx, if_stats.rx_total)
def update_stats(self, tx, rx, diff):
"""Update stats for this interface.