Merge "Add tcpdump for debugging"
diff --git a/acts/framework/acts/controllers/iperf_client.py b/acts/framework/acts/controllers/iperf_client.py
index 80a8410..f6ec3f4 100644
--- a/acts/framework/acts/controllers/iperf_client.py
+++ b/acts/framework/acts/controllers/iperf_client.py
@@ -259,7 +259,6 @@
Returns:
The iperf result file path.
"""
- iperf_output = ''
try:
if not iperf_binary:
logging.debug('No iperf3 binary specified. '
@@ -279,6 +278,6 @@
full_out_path = self._get_full_file_path(tag)
with open(full_out_path, 'w') as out_file:
- out_file.write('\n'.join(iperf_output))
+ out_file.write('\n'.join(clean_out))
return full_out_path
diff --git a/acts/framework/acts/controllers/iperf_server.py b/acts/framework/acts/controllers/iperf_server.py
index f8048b9..d2ac30b 100755
--- a/acts/framework/acts/controllers/iperf_server.py
+++ b/acts/framework/acts/controllers/iperf_server.py
@@ -144,7 +144,6 @@
The value of the throughput in the appropriate units.
"""
speed_divisor = 1
- print(self.reporting_speed_units)
if self.reporting_speed_units[1:].lower() == 'bytes':
speed_divisor = speed_divisor * BITS_IN_BYTE
if self.reporting_speed_units[0:1].lower() == 'k':
@@ -244,8 +243,8 @@
"""
if not self._has_data():
return None
- instantaneous_rates = self.instantaneous_rates[
- iperf_ignored_interval:-1]
+ instantaneous_rates = self.instantaneous_rates[iperf_ignored_interval:
+ -1]
avg_rate = math.fsum(instantaneous_rates) / len(instantaneous_rates)
sqd_deviations = ([(rate - avg_rate)**2
for rate in instantaneous_rates])
@@ -302,7 +301,7 @@
Note: If the directory for the file path does not exist, it will be
created.
- Args:s
+ Args:
tag: The tag passed in to the server run.
"""
out_dir = self.log_path
diff --git a/acts/tests/google/net/ApfCountersTest.py b/acts/tests/google/net/ApfCountersTest.py
index b8df3ed..d603a1f 100755
--- a/acts/tests/google/net/ApfCountersTest.py
+++ b/acts/tests/google/net/ApfCountersTest.py
@@ -26,6 +26,7 @@
import copy
import os
import random
+import threading
import time
WifiEnums = wutils.WifiEnums
@@ -37,6 +38,8 @@
LIFETIME_FRACTION = 6
LIFETIME = 180
INTERVAL = 2
+APF_THRESHOLD = 150 * 1024
+MONITOR_TRAFFIC = threading.Lock()
class ApfCountersTest(WifiBaseTest):
@@ -74,14 +77,18 @@
self.tcpdump_pid = None
def setup_test(self):
+ self.dut.adb.shell("pm disable com.android.vending")
self.tcpdump_pid = start_tcpdump(self.dut, self.test_name)
def teardown_test(self):
+ self.dut.adb.shell("pm enable com.android.vending")
stop_tcpdump(self.dut, self.tcpdump_pid, self.test_name)
def on_fail(self, test_name, begin_time):
self.dut.take_bug_report(test_name, begin_time)
self.dut.cat_adb_log(test_name, begin_time)
+ if MONITOR_TRAFFIC.locked():
+ self.stop_monitor_rx_traffic_in_bytes()
def teardown_class(self):
if "AccessPoint" in self.user_params:
@@ -105,6 +112,53 @@
self.dut.log.info("RA Count %s:" % ra_count)
return ra_count
+ def _monitor_rx_traffic_in_bytes(self,
+ threshold=APF_THRESHOLD,
+ interval_second=INTERVAL):
+ """ Monitor if traffic over threshold that will disable apf.
+
+ Args:
+ threshold: the traffic that will disable apf
+ interval_second: the interval time to report
+ """
+ rx_bytes = self.dut.droid.getTotalRxBytes()
+ if MONITOR_TRAFFIC.locked():
+ self.dut.log.info("Start monitor traffic in the background.")
+ while MONITOR_TRAFFIC.locked():
+ time.sleep(interval_second)
+ rx_bytes_update = self.dut.droid.getTotalRxBytes()
+ rx_traffic = rx_bytes_update - rx_bytes
+ if rx_traffic > threshold:
+ self.log.warning("rx traffic : %s byte in %s second(s)" %
+ (rx_traffic, interval_second))
+ else:
+ self.log.debug(
+ "rx traffic over threshold, %s byte in %s second(s)" %
+ (rx_traffic, interval_second))
+ rx_bytes = rx_bytes_update
+
+ def start_monitor_rx_traffic_in_bytes(self):
+ """ Start thread for monitor traffic
+
+ Returns:
+ t : thread for monitor traffic
+ """
+ MONITOR_TRAFFIC.acquire()
+ t = threading.Thread(
+ target=self._monitor_rx_traffic_in_bytes, args=())
+ t.start()
+ return t
+
+ def stop_monitor_rx_traffic_in_bytes(self, thread=None):
+ """ Stop thread for monitor traffic
+
+ Args:
+ thread: thread for monitor traffic
+ """
+ if thread:
+ thread.join()
+ MONITOR_TRAFFIC.release()
+
""" Tests """
@test_tracker_info(uuid="bc8d3f27-582a-464a-be30-556f07b77ee1")
@@ -117,6 +171,9 @@
for the next 30 seconds (1/6th of RA lifetime)
3. The next RA packets should be accepted
"""
+
+ monitor_t = self.start_monitor_rx_traffic_in_bytes()
+
# get mac address of the dut
ap = self.access_points[0]
wifi_network = copy.deepcopy(self.wpapsk_5g)
@@ -124,7 +181,7 @@
wutils.connect_to_wifi_network(self.dut, wifi_network)
mac_addr = self.dut.droid.wifiGetConnectionInfo()['mac_address']
self.log.info("mac_addr %s" % mac_addr)
- time.sleep(30) # wait 30 sec before sending RAs
+ time.sleep(30) # wait 30 sec before sending RAs
# get the current ra count
ra_count = self._get_icmp6intype134()
@@ -160,6 +217,8 @@
"Device did not accept new RA after 1/6th time "
"interval. Device dropped a valid RA in sequence.")
+ self.stop_monitor_rx_traffic_in_bytes(monitor_t)
+
@test_tracker_info(uuid="d2a0aff0-048c-475f-9bba-d90d8d9ebae3")
def test_IPv6_RA_with_RTT(self):
"""Test if the device filters IPv6 RA packets with different re-trans time
@@ -178,7 +237,7 @@
wutils.connect_to_wifi_network(self.dut, self.wpapsk_5g)
mac_addr = self.dut.droid.wifiGetConnectionInfo()['mac_address']
self.log.info("mac_addr %s" % mac_addr)
- time.sleep(30) # wait 30 sec before sending RAs
+ time.sleep(30) # wait 30 sec before sending RAs
# get the current ra count
ra_count = self._get_icmp6intype134()