iperfUtility: add udp rx bandwidth scan

This commit is contained in:
laokaiyao
2021-08-25 13:31:34 +08:00
parent 8d18a9c614
commit 04970fe487
5 changed files with 31 additions and 21 deletions

View File

@@ -129,7 +129,7 @@ example_test_002:
- ESP32 - ESP32
- Example_ShieldBox_Basic - Example_ShieldBox_Basic
example_test_enternet: example_test_ethernet:
extends: .example_test_esp32_template extends: .example_test_esp32_template
tags: tags:
- ESP32 - ESP32

View File

@@ -353,7 +353,7 @@ static esp_err_t emac_esp32_init(esp_eth_mac_t *mac)
} }
ESP_GOTO_ON_FALSE(to < emac->sw_reset_timeout_ms / 10, ESP_ERR_TIMEOUT, err, TAG, "reset timeout"); ESP_GOTO_ON_FALSE(to < emac->sw_reset_timeout_ms / 10, ESP_ERR_TIMEOUT, err, TAG, "reset timeout");
/* set smi clock */ /* set smi clock */
emac_hal_set_csr_clock_range(&emac->hal, esp_clk_apb_freq() / 1e6); emac_hal_set_csr_clock_range(&emac->hal, esp_clk_apb_freq());
/* reset descriptor chain */ /* reset descriptor chain */
emac_hal_reset_desc_chain(&emac->hal); emac_hal_reset_desc_chain(&emac->hal);
/* init mac registers by default */ /* init mac registers by default */

View File

@@ -142,15 +142,15 @@ void emac_hal_init(emac_hal_context_t *hal, void *descriptors,
void emac_hal_set_csr_clock_range(emac_hal_context_t *hal, int freq) void emac_hal_set_csr_clock_range(emac_hal_context_t *hal, int freq)
{ {
/* Tell MAC system clock Frequency in MHz, which will determine the frequency range of MDC(1MHz~2.5MHz) */ /* Tell MAC system clock Frequency in MHz, which will determine the frequency range of MDC(1MHz~2.5MHz) */
if (freq >= 20 && freq < 35) { if (freq >= 20000000 && freq < 35000000) {
emac_ll_set_csr_clock_division(hal->mac_regs, 2); // CSR clock/16 emac_ll_set_csr_clock_division(hal->mac_regs, 2); // CSR clock/16
} else if (freq >= 35 && freq < 60) { } else if (freq >= 35000000 && freq < 60000000) {
emac_ll_set_csr_clock_division(hal->mac_regs, 3); // CSR clock/26 emac_ll_set_csr_clock_division(hal->mac_regs, 3); // CSR clock/26
} else if (freq >= 60 && freq < 100) { } else if (freq >= 60000000 && freq < 100000000) {
emac_ll_set_csr_clock_division(hal->mac_regs, 0); // CSR clock/42 emac_ll_set_csr_clock_division(hal->mac_regs, 0); // CSR clock/42
} else if (freq >= 100 && freq < 150) { } else if (freq >= 100000000 && freq < 150000000) {
emac_ll_set_csr_clock_division(hal->mac_regs, 1); // CSR clock/62 emac_ll_set_csr_clock_division(hal->mac_regs, 1); // CSR clock/62
} else if (freq >= 150 && freq < 250) { } else if (freq >= 150000000 && freq < 250000000) {
emac_ll_set_csr_clock_division(hal->mac_regs, 4); // CSR clock/102 emac_ll_set_csr_clock_division(hal->mac_regs, 4); // CSR clock/102
} else { } else {
emac_ll_set_csr_clock_division(hal->mac_regs, 5); // CSR clock/124 emac_ll_set_csr_clock_division(hal->mac_regs, 5); // CSR clock/124

View File

@@ -10,8 +10,13 @@ CONFIG_PARTITION_TABLE_FILENAME="partitions_example.csv"
CONFIG_FREERTOS_USE_TRACE_FACILITY=y CONFIG_FREERTOS_USE_TRACE_FACILITY=y
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
# Run FreeRTOS only on the first core
CONFIG_FREERTOS_UNICORE=y
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
# Disable watch dog
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT=n CONFIG_ESP_TASK_WDT=n
CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=n CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=n

View File

@@ -14,7 +14,7 @@ except ImportError:
pass pass
# configurations # configurations
TEST_TIME = TEST_TIMEOUT = 60 TEST_TIME = TEST_TIMEOUT = 66
WAIT_AP_POWER_ON_TIMEOUT = 90 WAIT_AP_POWER_ON_TIMEOUT = 90
SCAN_TIMEOUT = 3 SCAN_TIMEOUT = 3
SCAN_RETRY_COUNT = 3 SCAN_RETRY_COUNT = 3
@@ -96,6 +96,7 @@ class TestResult(object):
""" """
fall_to_0_recorded = 0 fall_to_0_recorded = 0
throughput_list = [] throughput_list = []
throughput = 0.0
result_list = self.PC_BANDWIDTH_LOG_PATTERN.findall(raw_data) result_list = self.PC_BANDWIDTH_LOG_PATTERN.findall(raw_data)
if not result_list: if not result_list:
# failed to find raw data by PC pattern, it might be DUT pattern # failed to find raw data by PC pattern, it might be DUT pattern
@@ -106,6 +107,7 @@ class TestResult(object):
# this could be summary, ignore this # this could be summary, ignore this
continue continue
throughput_list.append(float(result[2])) throughput_list.append(float(result[2]))
throughput = (throughput if (throughput > float(result[2])) else float(result[2]))
if float(result[2]) == 0 and rssi > self.ZERO_POINT_THRESHOLD \ if float(result[2]) == 0 and rssi > self.ZERO_POINT_THRESHOLD \
and fall_to_0_recorded < 1: and fall_to_0_recorded < 1:
# throughput fall to 0 error. we only record 1 records for one test # throughput fall to 0 error. we only record 1 records for one test
@@ -113,9 +115,7 @@ class TestResult(object):
.format(ap_ssid, att, rssi, result[0], result[1])) .format(ap_ssid, att, rssi, result[0], result[1]))
fall_to_0_recorded += 1 fall_to_0_recorded += 1
if len(throughput_list) > self.THROUGHPUT_QUALIFY_COUNT: if len(throughput_list) < self.THROUGHPUT_QUALIFY_COUNT:
throughput = sum(throughput_list) / len(throughput_list)
else:
throughput = 0.0 throughput = 0.0
if throughput == 0 and rssi > self.ZERO_THROUGHPUT_THRESHOLD: if throughput == 0 and rssi > self.ZERO_THROUGHPUT_THRESHOLD:
@@ -330,6 +330,12 @@ class IperfTestUtility(object):
process = subprocess.Popen(['iperf', '-c', dut_ip, process = subprocess.Popen(['iperf', '-c', dut_ip,
'-t', str(TEST_TIME), '-f', 'm'], '-t', str(TEST_TIME), '-f', 'm'],
stdout=f, stderr=f) stdout=f, stderr=f)
for _ in range(TEST_TIMEOUT):
if process.poll() is not None:
break
time.sleep(1)
else:
process.terminate()
else: else:
self.dut.write('iperf -s -u -i 1 -t {}'.format(TEST_TIME)) self.dut.write('iperf -s -u -i 1 -t {}'.format(TEST_TIME))
# wait until DUT TCP server created # wait until DUT TCP server created
@@ -338,10 +344,9 @@ class IperfTestUtility(object):
except DUT.ExpectTimeout: except DUT.ExpectTimeout:
# compatible with old iperf example binary # compatible with old iperf example binary
Utility.console_log('create iperf udp server fail') Utility.console_log('create iperf udp server fail')
process = subprocess.Popen(['iperf', '-c', dut_ip, '-u', '-b', '100M', for bandwidth in range(50, 101, 5):
'-t', str(TEST_TIME), '-f', 'm'], process = subprocess.Popen(['iperf', '-c', dut_ip, '-u', '-b', str(bandwidth) + 'm',
stdout=f, stderr=f) '-t', str(TEST_TIME / 11), '-f', 'm'], stdout=f, stderr=f)
for _ in range(TEST_TIMEOUT): for _ in range(TEST_TIMEOUT):
if process.poll() is not None: if process.poll() is not None:
break break