Skip to content

Commit

Permalink
fix(examples/iperf): added sequential numberring of Tx'ed datagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
kostaond authored and nachiketkukade committed Sep 22, 2023
1 parent e9d442d commit e7b1716
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/common_components/iperf/include/iperf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions examples/common_components/iperf/iperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,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;
Expand All @@ -161,6 +163,7 @@ static void socket_send(int send_socket, struct sockaddr_storage dest_addr, uint
int err = 0;

buffer = s_iperf_ctrl.buffer;
pkt_id_p = (int32_t *)s_iperf_ctrl.buffer;
want_send = s_iperf_ctrl.buffer_len;
iperf_start_report();

Expand All @@ -184,6 +187,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++;
}
if (s_iperf_ctrl.cfg.type == IPERF_IP_TYPE_IPV6) {
actual_send = sendto(send_socket, buffer, want_send, 0, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr_in6));
} else if (s_iperf_ctrl.cfg.type == IPERF_IP_TYPE_IPV4) {
Expand Down

0 comments on commit e7b1716

Please sign in to comment.