summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py13
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py7
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py27
3 files changed, 41 insertions, 6 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index 8da7c411..39d69178 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -156,7 +156,7 @@ class AsyncEventHandler(object):
def handle_async_rx_stats_event (self, data):
- self.client.rx_stats = data
+ self.client.rx_stats.update(data)
# handles an async stats update from the subscriber
@@ -433,13 +433,14 @@ class STLClient(object):
self.global_stats = trex_stl_stats.CGlobalStats(self.connection_info,
- self.server_version,
- self.ports)
+ self.server_version,
+ self.ports)
self.stats_generator = trex_stl_stats.CTRexInfoGenerator(self.global_stats,
- self.ports)
+ self.ports)
+
+ self.rx_stats = trex_stl_stats.CRxStats()
- self.rx_stats = {}
############# private functions - used by the class itself ###########
@@ -745,7 +746,7 @@ class STLClient(object):
stats['total'] = total
- stats['rx_stats'] = copy.deepcopy(self.rx_stats)
+ stats['rx_stats'] = self.rx_stats.get_stats()
return stats
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
index b2843ac3..dc787263 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_packet_builder_scapy.py
@@ -870,6 +870,13 @@ class CScapyTRexPktBuilder(CTrexPktBuilderInterface):
if isinstance(sc, CTRexScRaw):
self._compile_raw(sc)
+ def get_pkt_len (self):
+ if self.pkt:
+ return len(self.pkt)
+ elif self.pkt_raw:
+ return len(self.pkt_raw)
+ else:
+ raise CTRexPacketBuildException(-14, "Packet is empty")
####################################################
# private
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
index 620ccacd..eca7fd7a 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_stats.py
@@ -643,6 +643,33 @@ class CPortStats(CTRexStats):
}
+class CRxStats(object):
+ def __init__(self):
+ self.rx_stats = {}
+
+
+ def update (self, snapshot):
+ self.rx_stats = snapshot
+
+
+ def get_stats (self):
+ stats = {}
+ for user_id, user_id_data in self.rx_stats.iteritems():
+ # ignore non user ID keys
+ try:
+ user_id = int(user_id)
+ except ValueError:
+ continue
+
+ # handle user id
+ stats[user_id] = {}
+ for field, per_port_data in user_id_data.iteritems():
+ stats[user_id][field] = {}
+ for port, value in per_port_data.iteritems():
+ stats[user_id][field][int(port)] = value
+
+ return stats
+
if __name__ == "__main__":
pass