From d2e519012ca36a60f15e1c0d789645e14dae7d48 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 10 May 2022 13:50:53 +0200 Subject: [PATCH 1/2] ci: iperf: recognize report results from newer iperf versions The iperf version used in older version of CI docker images had the following output format: [ 3] 0.0-10.0 sec 1.25 MBytes 1.05 Mbits/sec 0.000 ms 0/ 892 (0%) The newer iperf version which was recently included in the container prints more digits after the decimal point: [ 3] 0.0000-10.0148 sec 1.25 MBytes 1.05 Mbits/sec 0.002 ms 0/ 895 (0%) The regular expression to match this line expected a single zero after the decimal point, so the new format no longer matches. The fix is to expect any number of digits in the fractional part. --- .../idf_iperf_test_util/IperfUtility.py | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tools/ci/python_packages/idf_iperf_test_util/IperfUtility.py b/tools/ci/python_packages/idf_iperf_test_util/IperfUtility.py index 979150fbb6..3d622ef16d 100644 --- a/tools/ci/python_packages/idf_iperf_test_util/IperfUtility.py +++ b/tools/ci/python_packages/idf_iperf_test_util/IperfUtility.py @@ -29,7 +29,7 @@ PC_IPERF_TEMP_LOG_FILE = '.tmp_iperf.log' class TestResult(object): """ record, analysis test result and convert data to output format """ - PC_BANDWIDTH_LOG_PATTERN = re.compile(r'(\d+).0\s*-\s*(\d+).0\s+sec\s+[\d.]+\s+MBytes\s+([\d.]+)\s+Mbits/sec') + PC_BANDWIDTH_LOG_PATTERN = re.compile(r'(\d+\.\d+)\s*-\s*(\d+.\d+)\s+sec\s+[\d.]+\s+MBytes\s+([\d.]+)\s+Mbits\/sec') DUT_BANDWIDTH_LOG_PATTERN = re.compile(r'(\d+)-\s+(\d+)\s+sec\s+([\d.]+)\s+Mbits/sec') ZERO_POINT_THRESHOLD = -88 # RSSI, dbm @@ -96,19 +96,22 @@ class TestResult(object): """ fall_to_0_recorded = 0 throughput_list = [] - throughput = 0.0 + max_throughput = 0.0 result_list = self.PC_BANDWIDTH_LOG_PATTERN.findall(raw_data) if not result_list: # failed to find raw data by PC pattern, it might be DUT pattern result_list = self.DUT_BANDWIDTH_LOG_PATTERN.findall(raw_data) for result in result_list: - if int(result[1]) - int(result[0]) != 1: + t_start = float(result[0]) + t_end = float(result[1]) + throughput = float(result[2]) + if int(t_end - t_start) != 1: # this could be summary, ignore this continue - 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 \ + throughput_list.append(throughput) + max_throughput = max(max_throughput, throughput) + if throughput == 0 and rssi > self.ZERO_POINT_THRESHOLD \ and fall_to_0_recorded < 1: # throughput fall to 0 error. we only record 1 records for one test self.error_list.append('[Error][fall to 0][{}][att: {}][rssi: {}]: 0 throughput interval: {}-{}' @@ -116,15 +119,17 @@ class TestResult(object): fall_to_0_recorded += 1 if len(throughput_list) < self.THROUGHPUT_QUALIFY_COUNT: - throughput = 0.0 + self.error_list.append('[Error][Fatal][{}][att: {}][rssi: {}]: Only {} throughput values found, expected at least {}' + .format(ap_ssid, att, rssi, len(throughput_list), self.THROUGHPUT_QUALIFY_COUNT)) + max_throughput = 0.0 - if throughput == 0 and rssi > self.ZERO_THROUGHPUT_THRESHOLD: + if max_throughput == 0 and rssi > self.ZERO_THROUGHPUT_THRESHOLD: self.error_list.append('[Error][Fatal][{}][att: {}][rssi: {}]: No throughput data found' .format(ap_ssid, att, rssi)) - self._save_result(throughput, ap_ssid, att, rssi, heap_size) + self._save_result(max_throughput, ap_ssid, att, rssi, heap_size) - return throughput + return max_throughput def post_analysis(self): # type: () -> None """ From a213f7baf709744525afacb91eab586ec19dde73 Mon Sep 17 00:00:00 2001 From: Ondrej Kosta Date: Wed, 11 May 2022 13:18:07 +0200 Subject: [PATCH 2/2] iperf: added sequential numberring of Tx'ed datagrams --- examples/common_components/iperf/include/iperf.h | 2 +- examples/common_components/iperf/iperf.c | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/common_components/iperf/include/iperf.h b/examples/common_components/iperf/include/iperf.h index 72d2c62b3c..fb8ab754aa 100644 --- a/examples/common_components/iperf/include/iperf.h +++ b/examples/common_components/iperf/include/iperf.h @@ -42,7 +42,7 @@ extern "C" { #define IPERF_REPORT_TASK_PRIORITY 6 #define IPERF_REPORT_TASK_STACK 4096 -#define IPERF_UDP_TX_LEN (1472) +#define IPERF_UDP_TX_LEN (1470) #define IPERF_UDP_RX_LEN (16 << 10) #define IPERF_TCP_TX_LEN (16 << 10) #define IPERF_TCP_RX_LEN (16 << 10) diff --git a/examples/common_components/iperf/iperf.c b/examples/common_components/iperf/iperf.c index b0464f7b1e..5e0c62d12f 100644 --- a/examples/common_components/iperf/iperf.c +++ b/examples/common_components/iperf/iperf.c @@ -142,6 +142,8 @@ static void socket_recv(int recv_socket, struct sockaddr_storage listen_addr, ui static void socket_send(int send_socket, struct sockaddr_storage dest_addr, uint8_t type, int bw_lim) { uint8_t *buffer; + int32_t *pkt_id_p; + int32_t pkt_cnt = 0; int actual_send = 0; int want_send = 0; int period_us = -1; @@ -153,6 +155,7 @@ static void socket_send(int send_socket, struct sockaddr_storage dest_addr, uint const char *error_log = (type == IPERF_TRANS_TYPE_TCP) ? "tcp client send" : "udp client send"; buffer = s_iperf_ctrl.buffer; + pkt_id_p = (int32_t *)s_iperf_ctrl.buffer; want_send = s_iperf_ctrl.buffer_len; iperf_start_report(); @@ -176,7 +179,13 @@ static void socket_send(int send_socket, struct sockaddr_storage dest_addr, uint } prev_time = send_time; } - + *pkt_id_p = htonl(pkt_cnt); // datagrams need to be sequentially numbered + if (pkt_cnt >= INT32_MAX) { + pkt_cnt = 0; + } + else { + pkt_cnt++; + } actual_send = sendto(send_socket, buffer, want_send, 0, (struct sockaddr *)&dest_addr, socklen); if (actual_send != want_send) { if (type == IPERF_TRANS_TYPE_UDP) {