From 3f7433ae5dbe66d0ccc598ba980178de172c11f9 Mon Sep 17 00:00:00 2001
From: Zanting <zanting>
Date: Wed, 20 Apr 2016 14:43:01 +0000
Subject: [PATCH] Packet rate scripts for ARTS-0

---
 .../tb/sh/em2_packet_rate.py                  | 35 +++++++++++++++++++
 .../tb/sh/p4p1_packet_rate.py                 | 35 +++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100644 applications/arts/designs/arts_unb1_sc1_bf_offload/tb/sh/em2_packet_rate.py
 create mode 100644 applications/arts/designs/arts_unb1_sc1_bf_offload/tb/sh/p4p1_packet_rate.py

diff --git a/applications/arts/designs/arts_unb1_sc1_bf_offload/tb/sh/em2_packet_rate.py b/applications/arts/designs/arts_unb1_sc1_bf_offload/tb/sh/em2_packet_rate.py
new file mode 100644
index 0000000000..ea146890f0
--- /dev/null
+++ b/applications/arts/designs/arts_unb1_sc1_bf_offload/tb/sh/em2_packet_rate.py
@@ -0,0 +1,35 @@
+import subprocess
+import time
+
+########################################################################
+# Execute ifconfig twice with a one second interval to find the number 
+# of packets received per second.
+########################################################################
+
+cmd = 'ifconfig'
+args = 'em2'
+
+cmd_output = []
+rx_packets_str = []
+rx_packets = []
+rx_bytes_str = []
+rx_bytes = []
+
+for i in range(2):
+    p = subprocess.Popen([cmd, args], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    out, err = p.communicate()
+    cmd_output.append(out)
+    time.sleep(1)
+
+for i in range(2):
+    string_list = cmd_output[i].split()    
+    rx_packets_str.append(string_list[17])
+    rx_bytes_str.append(string_list[19])
+    rx_packets.append(int(rx_packets_str[i])) #.split(':')[1]))
+    rx_bytes.append(int(rx_bytes_str[i])) #.split(':')[1]))
+
+packets_per_second = rx_packets[1]-rx_packets[0]
+gigabits_per_second = (float(rx_bytes[1]-rx_bytes[0])*8)/1000000000
+print '\n', packets_per_second, 'packets per second'
+print gigabits_per_second, 'Gbps\n'
+
diff --git a/applications/arts/designs/arts_unb1_sc1_bf_offload/tb/sh/p4p1_packet_rate.py b/applications/arts/designs/arts_unb1_sc1_bf_offload/tb/sh/p4p1_packet_rate.py
new file mode 100644
index 0000000000..22644ee5a7
--- /dev/null
+++ b/applications/arts/designs/arts_unb1_sc1_bf_offload/tb/sh/p4p1_packet_rate.py
@@ -0,0 +1,35 @@
+import subprocess
+import time
+
+########################################################################
+# Execute ifconfig twice with a one second interval to find the number 
+# of packets received per second.
+########################################################################
+
+cmd = 'ifconfig'
+args = 'p4p1'
+
+cmd_output = []
+rx_packets_str = []
+rx_packets = []
+rx_bytes_str = []
+rx_bytes = []
+
+for i in range(2):
+    p = subprocess.Popen([cmd, args], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    out, err = p.communicate()
+    cmd_output.append(out)
+    time.sleep(1)
+
+for i in range(2):
+    string_list = cmd_output[i].split()    
+    rx_packets_str.append(string_list[17])
+    rx_bytes_str.append(string_list[19])
+    rx_packets.append(int(rx_packets_str[i])) #.split(':')[1]))
+    rx_bytes.append(int(rx_bytes_str[i])) #.split(':')[1]))
+
+packets_per_second = rx_packets[1]-rx_packets[0]
+gigabits_per_second = (float(rx_bytes[1]-rx_bytes[0])*8)/1000000000
+print '\n', packets_per_second, 'packets per second'
+print gigabits_per_second, 'Gbps\n'
+
-- 
GitLab