1. 前置测试:
2. 优化结果
在评估1的基础上,基于udp client和udp server例程,通过优化程序和配置,将wifi udp下的吞吐性能从10Mbps提高到30Mbps,在暗室环境下,吞吐性能可达到58Mbps。
测试结果:
I (18405) wifi:AP's beacon interval = 102400 us, DTIM period = 1
W (18573) wifi:<ba-add>idx:0 (ifx:0, 08:1f:71:58:8a:78), tid:0, ssn:4, winSize:64
I (19972) esp_netif_handlers: example_connect: sta ip: 192.168.5.11, mask: 255.255.255.0, gw: 192.168.5.1
I (19973) example_connect: Got IPv4 event: Interface "example_connect: sta" address: 192.168.5.11
I (19981) example_connect: Connected to example_connect: sta
I (19988) example_connect: - IPv4 address: 192.168.5.11
I (19994) example: Socket created, sending to 192.168.5.10:31188
UDP Test:Server IP:192.168.5.10, Port:31188!
Interval Recved Bytes Bandwidth
Interval Bandwidth
000 - 001 6.91 MB 55.29 Mbps
001 - 002 7.49 MB 59.95 Mbps
002 - 003 7.55 MB 60.40 Mbps
003 - 004 7.72 MB 61.77 Mbps
004 - 005 7.43 MB 59.45 Mbps
005 - 006 7.27 MB 58.16 Mbps
006 - 007 6.91 MB 55.26 Mbps
007 - 008 7.10 MB 56.81 Mbps
008 - 009 7.27 MB 58.13 Mbps
009 - 010 7.44 MB 59.49 Mbps
010 - 011 7.26 MB 58.06 Mbps
011 - 012 6.73 MB 53.85 Mbps
012 - 013 7.37 MB 58.97 Mbps
013 - 014 7.12 MB 56.98 Mbps
014 - 015 7.30 MB 58.41 Mbps
015 - 016 7.28 MB 58.23 Mbps
016 - 017 7.85 MB 62.80 Mbps
017 - 018 7.52 MB 60.13 Mbps
018 - 019 7.31 MB 58.47 Mbps
019 - 020 7.50 MB 60.00 Mbps
020 - 021 7.31 MB 58.48 Mbps
021 - 022 7.07 MB 56.57 Mbps
022 - 023 7.10 MB 56.80 Mbps
023 - 024 7.41 MB 59.28 Mbps
024 - 025 7.33 MB 58.62 Mbps
025 - 026 7.25 MB 57.99 Mbps
026 - 027 7.39 MB 59.13 Mbps
027 - 028 6.79 MB 54.33 Mbps
028 - 029 7.40 MB 59.19 Mbps
029 - 030 7.33 MB 58.64 Mbps
030 - 031 7.40 MB 59.21 Mbps
031 - 032 7.40 MB 59.19 Mbps
032 - 033 7.63 MB 61.06 Mbps
033 - 034 7.15 MB 57.16 Mbps
034 - 035 7.66 MB 61.25 Mbps
035 - 036 7.45 MB 59.59 Mbps
036 - 037 6.97 MB 55.76 Mbps
037 - 038 7.21 MB 57.66 Mbps
038 - 039 7.37 MB 58.94 Mbps
039 - 040 7.25 MB 57.99 Mbps
040 - 041 7.37 MB 58.94 Mbps
041 - 042 7.50 MB 60.02 Mbps
042 - 043 7.25 MB 58.02 Mbps
043 - 044 7.07 MB 56.52 Mbps
044 - 045 7.23 MB 57.87 Mbps
045 - 046 7.29 MB 58.33 Mbps
046 - 047 7.55 MB 60.40 Mbps
047 - 048 7.30 MB 58.37 Mbps
048 - 049 7.35 MB 58.80 Mbps
049 - 050 7.34 MB 58.75 Mbps
050 - 051 7.67 MB 61.38 Mbps
051 - 052 7.05 MB 56.40 Mbps
052 - 053 7.42 MB 59.37 Mbps
053 - 054 7.57 MB 60.56 Mbps
054 - 055 7.02 MB 56.14 Mbps
055 - 056 7.13 MB 57.05 Mbps
056 - 057 7.76 MB 62.12 Mbps
057 - 058 7.15 MB 57.16 Mbps
058 - 059 7.55 MB 60.41 Mbps
059 - 060 7.62 MB 60.98 Mbps
[UDP DOWN LINK TEST]
Start:1970-01-01 00:01:19, End:1970-01-01 00:01:19, Elapsed time:60s
Upload bytes:439.38 MB, Rate:58.58 Mbps
I (15984) wifi:AP's beacon interval = 102400 us, DTIM period = 1
W (16611) wifi:<ba-add>idx:0 (ifx:0, 08:1f:71:58:8a:78), tid:0, ssn:2, winSize:64
I (17482) esp_netif_handlers: example_connect: sta ip: 192.168.5.10, mask: 255.255.255.0, gw: 192.168.5.1
I (17482) example_connect: Got IPv4 event: Interface "example_connect: sta" address: 192.168.5.10
I (17491) example_connect: Connected to example_connect: sta
I (17497) example_connect: - IPv4 address: 192.168.5.10
I (17503) example: Socket created
I (17507) example: Socket bound, port 31188
Interval Bandwidth
000 - 001 5.78 MB 46.21 Mbps
001 - 002 5.95 MB 47.56 Mbps
002 - 003 5.67 MB 45.33 Mbps
003 - 004 5.83 MB 46.66 Mbps
004 - 005 6.24 MB 49.94 Mbps
005 - 006 6.27 MB 50.14 Mbps
006 - 007 6.47 MB 51.79 Mbps
007 - 008 6.32 MB 50.54 Mbps
008 - 009 6.05 MB 48.36 Mbps
009 - 010 6.16 MB 49.27 Mbps
010 - 011 6.21 MB 49.65 Mbps
011 - 012 5.78 MB 46.22 Mbps
012 - 013 5.97 MB 47.80 Mbps
013 - 014 6.32 MB 50.58 Mbps
014 - 015 6.07 MB 48.53 Mbps
015 - 016 6.18 MB 49.42 Mbps
016 - 017 5.89 MB 47.12 Mbps
017 - 018 6.09 MB 48.72 Mbps
018 - 019 6.27 MB 50.18 Mbps
019 - 020 5.99 MB 47.90 Mbps
020 - 021 6.11 MB 48.91 Mbps
021 - 022 6.40 MB 51.17 Mbps
022 - 023 6.24 MB 49.92 Mbps
023 - 024 6.08 MB 48.62 Mbps
024 - 025 6.12 MB 49.00 Mbps
025 - 026 6.31 MB 50.46 Mbps
026 - 027 6.22 MB 49.73 Mbps
027 - 028 6.44 MB 51.48 Mbps
028 - 029 6.21 MB 49.72 Mbps
029 - 030 6.24 MB 49.95 Mbps
030 - 031 6.15 MB 49.19 Mbps
031 - 032 6.08 MB 48.65 Mbps
032 - 033 5.93 MB 47.43 Mbps
033 - 034 6.31 MB 50.46 Mbps
034 - 035 6.13 MB 49.05 Mbps
035 - 036 6.19 MB 49.52 Mbps
036 - 037 6.53 MB 52.25 Mbps
037 - 038 6.37 MB 50.99 Mbps
038 - 039 6.18 MB 49.40 Mbps
039 - 040 6.39 MB 51.14 Mbps
040 - 041 6.03 MB 48.25 Mbps
041 - 042 6.10 MB 48.81 Mbps
042 - 043 6.36 MB 50.92 Mbps
043 - 044 6.32 MB 50.55 Mbps
044 - 045 6.33 MB 50.64 Mbps
045 - 046 6.26 MB 50.10 Mbps
046 - 047 5.99 MB 47.92 Mbps
047 - 048 6.39 MB 51.12 Mbps
048 - 049 6.25 MB 50.02 Mbps
049 - 050 6.25 MB 50.00 Mbps
050 - 051 6.02 MB 48.20 Mbps
051 - 052 6.49 MB 51.96 Mbps
052 - 053 6.00 MB 47.98 Mbps
053 - 054 6.21 MB 49.71 Mbps
054 - 055 6.36 MB 50.87 Mbps
055 - 056 6.35 MB 50.79 Mbps
056 - 057 5.85 MB 46.81 Mbps
057 - 058 6.39 MB 51.12 Mbps
058 - 059 6.15 MB 49.21 Mbps
059 - 060 6.04 MB 48.33 Mbps
060 - 061 25.02 KB 200.19 Kbps
061 - 062 0.00 KB 0.00 Kbps
062 - 063 0.00 KB 0.00 Kbps
063 - 064 0.00 KB 0.00 Kbps
064 - 065 0.00 KB 0.00 Kbps
065 - 066 0.00 KB 0.00 Kbps
066 - 067 0.00 KB 0.00 Kbps
067 - 068 0.00 KB 0.00 Kbps
068 - 069 0.00 KB 0.00 Kbps
069 - 070 0.00 KB 0.00 Kbps
E (90005) example: recvfrom failed: errno 11
3. 优化配置项
esp32相关配置如下:
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=16
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=64
CONFIG_ESP32_WIFI_RX_BA_WIN=32
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=65534
CONFIG_LWIP_TCP_WND_DEFAULT=65534
CONFIG_LWIP_TCP_RECVMBOX_SIZE=64
CONFIG_LWIP_UDP_RECVMBOX_SIZE=64
CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=4096
CONFIG_TCP_SND_BUF_DEFAULT=65534
CONFIG_TCP_WND_DEFAULT=65534
CONFIG_TCP_RECVMBOX_SIZE=64
CONFIG_UDP_RECVMBOX_SIZE=64 # 影响巨大
代码优化:
- 客户端
当sendto函数发送的字节数和实际发送成功的字节数不匹配时,增加errno = ENOMEM错误的处理,增加vTaskDelay延时。int actual_send = sendto(sockfd, tx_buffer, sizeof(tx_buffer), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
if (actual_send != sizeof(tx_buffer)) {
err = iperf_get_socket_error_code(sockfd);
if (err == ENOMEM) {
vTaskDelay(delay);
continue;
} else {
ESP_LOGE(TAG, "udp client send abort: err=%d", err);
}
} else {
// 统计发送的字节数
total_send_bytes += sizeof(tx_buffer);
send_bytes += sizeof(tx_buffer);
}
相关博文:
|