NFVBENCH-163: Add gratuitous ARP in case of L3 router mode
[nfvbench.git] / nfvbench / traffic_client.py
index ae8af8d..c349289 100755 (executable)
@@ -1069,6 +1069,9 @@ class TrafficClient(object):
                    'theoretical_tx_rate_bps': stats['theoretical_tx_rate_bps'],
                    'theoretical_tx_rate_pps': stats['theoretical_tx_rate_pps']}
 
+        if self.config.periodic_gratuitous_arp:
+            retDict['garp_total_tx_rate'] = stats['garp_total_tx_rate']
+
         tx_keys = ['total_pkts', 'total_pkt_bytes', 'pkt_rate', 'pkt_bit_rate']
         rx_keys = tx_keys + ['dropped_pkts']
 
@@ -1367,12 +1370,25 @@ class TrafficClient(object):
         for idx, key in enumerate(["direction-forward", "direction-reverse"]):
             tx_rate = results["stats"][str(idx)]["tx"]["total_pkts"] / self.config.duration_sec
             rx_rate = results["stats"][str(1 - idx)]["rx"]["total_pkts"] / self.config.duration_sec
+
+            orig_rate = self.run_config['rates'][idx]
+            if self.config.periodic_gratuitous_arp:
+                orig_rate['rate_pps'] = float(
+                    orig_rate['rate_pps']) - self.config.gratuitous_arp_pps
+
             r[key] = {
-                "orig": self.__convert_rates(self.run_config['rates'][idx]),
+                "orig": self.__convert_rates(orig_rate),
                 "tx": self.__convert_rates({'rate_pps': tx_rate}),
                 "rx": self.__convert_rates({'rate_pps': rx_rate})
             }
 
+        if self.config.periodic_gratuitous_arp:
+            r['garp-direction-total'] = {
+                "orig": self.__convert_rates({'rate_pps': self.config.gratuitous_arp_pps * 2}),
+                "tx": self.__convert_rates({'rate_pps': results["stats"]["garp_total_tx_rate"]}),
+                "rx": self.__convert_rates({'rate_pps': 0})
+            }
+
         total = {}
         for direction in ['orig', 'tx', 'rx']:
             total[direction] = {}
@@ -1380,6 +1396,7 @@ class TrafficClient(object):
                 total[direction][unit] = sum([float(x[direction][unit]) for x in list(r.values())])
 
         r['direction-total'] = total
+
         return r
 
     def insert_interface_stats(self, pps_list):