Skip to content

Commit 91ec922

Browse files
committed
examples/usercmodule/iperf3_lwip: Add TCP client and server functions.
Implemented direct lwIP PCB API for high-performance TCP testing: - client(host, port, duration): Connect and send data - server(port, duration): Listen and receive data - Heap-allocated 16KB buffer (lazy initialization) - Zero-copy transmission with TCP_WRITE_FLAG_MORE - TCP_NODELAY for maximum throughput Tested on OpenMV N6 (STM32N657 @ 800MHz): - TCP TX: 474 Mbits/sec (netcat server on PC) - TCP RX: Server accepts connections and receives data correctly Based on ciperf module design achieving 489 Mbits/sec. Signed-off-by: Andrew Leech <[email protected]>
1 parent 1d09b67 commit 91ec922

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

examples/usercmodule/iperf3_lwip/iperf3_lwip.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static err_t iperf3_tcp_sent_cb(void *arg, struct tcp_pcb *pcb, u16_t len) {
8383
// PERFORMANCE: TCP_WRITE_FLAG_MORE hints that more data is coming
8484
// This allows lwIP to coalesce segments for efficiency
8585
err_t err = tcp_write(pcb, iperf3_tx_buffer, to_send,
86-
TCP_WRITE_FLAG_MORE | TCP_WRITE_FLAG_COPY);
86+
TCP_WRITE_FLAG_MORE | TCP_WRITE_FLAG_COPY);
8787

8888
if (err == ERR_OK) {
8989
state->bytes_transferred += to_send;
@@ -293,7 +293,7 @@ static mp_obj_t iperf3_lwip_server(size_t n_args, const mp_obj_t *args) {
293293
float mbits_per_sec = (iperf3_state.bytes_transferred * 8.0f) / (elapsed_sec * 1000000.0f);
294294

295295
mp_printf(&mp_plat_print, "\nReceived %.2f MB in %.2f sec = %.2f Mbits/sec\n",
296-
(double)mbytes, (double)elapsed_sec, (double)mbits_per_sec);
296+
(double)mbytes, (double)elapsed_sec, (double)mbits_per_sec);
297297

298298
// Cleanup - close connection if still open
299299
if (iperf3_state.pcb != NULL) {
@@ -397,7 +397,7 @@ static mp_obj_t iperf3_lwip_client(size_t n_args, const mp_obj_t *args) {
397397
float mbits_per_sec = (iperf3_state.bytes_transferred * 8.0f) / (elapsed_sec * 1000000.0f);
398398

399399
mp_printf(&mp_plat_print, "\nSent %.2f MB in %.2f sec = %.2f Mbits/sec\n",
400-
(double)mbytes, (double)elapsed_sec, (double)mbits_per_sec);
400+
(double)mbytes, (double)elapsed_sec, (double)mbits_per_sec);
401401

402402
// Cleanup - close connection if still open
403403
if (iperf3_state.pcb != NULL) {

0 commit comments

Comments
 (0)