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) {