PAN网速问题 PAN下载速度约30 KB/s,远低于预期

- **芯片型号**:SF32LB58

- **SDK版本**:SiFli SDK 2.4.4

- **参考示例**:SiFli-SDK/example/bt/pan

已排除的原因

  • :white_check_mark: TCP窗口太小(已增大到8KB)

  • :white_check_mark: Sniff模式影响(已测试禁用)

  • :white_check_mark: 应用层缓冲区太小(已增大到8KB)

  • :white_check_mark: CPU让出过于频繁(已测试不让出)

尝试了很多配置,换了不同平台的蓝牙局域网,蓝牙网速一直限制在20kb

Download complete: 2.58 MB in 206 seconds (avg 12.8 KB/s)
CONFIG_RT_LWIP_TCP_SND_BUF=8196    # 8KB发送缓冲区
CONFIG_RT_LWIP_TCP_WND=8196        # 8KB接收窗口
CONFIG_RT_LWIP_PBUF_NUM=16         # pbuf数量
CONFIG_RT_LWIP_TCP_SEG_NUM=40      # TCP段数量
CONFIG_RT_LWIP_TCPTHREAD_MBOX_SIZE=48
CONFIG_RT_LWIP_TCPTHREAD_STACKSIZE=8196
CONFIG_RT_LWIP_ETHTHREAD_STACKSIZE=8196
CONFIG_RT_LWIP_ETHTHREAD_MBOX_SIZE=48
CONFIG_RT_LWIP_USING_MQTT=y
CONFIG_RT_LWIP_USING_WEBSOCKET=y
CONFIG_LWIP_ALTCP=y
CONFIG_LWIP_ALTCP_TLS=y
CONFIG_PKG_USING_MBEDTLS=y
CONFIG_PKG_USING_MBEDTLS_USE_ALL_CERTS=y
CONFIG_PKG_USING_MBEDTLS_USER_CERTS=y
CONFIG_PKG_USING_WEBRTC=y
CONFIG_PKG_USING_WEBCLIENT=y

这是打开了系统的DEBUG日志,对端窗口64154 接收端 received 1432 bytes ,且包与包之间存在较大大约400ms的接收延时 限制了网速

tcp_receive: window update 64154
lwip_recv_tcp: netconn_recv err=0, pbuf=0x2001c4fc
lwip_recv_tcp: buflen=72 recv_left=4018 off=1360
lwip_recv_tcp: deleting pbuf=0x2001c4fc
lwip_recv_tcp: top while sock->lastdata=0x0
lwip_recv_tcp: netconn_recv err=-7, pbuf=0x0
tcp_recved: received 1432 bytes, wnd 8196 (0).
lwip_recvfrom(0):  addr=23.225.33.154 port=80 len=1432
lwip_recvfrom(0, 0x20042246, 3946, 0x0, ..)
lwip_recv_tcp: top while sock->lastdata=0x0
tcpip_thread: PACKET 0x2001eefc
tcp_receive: window update 64154
lwip_recv_tcp: netconn_recv err=0, pbuf=0x2001c4fc
lwip_recv_tcp: buflen=1288 recv_left=3946 off=0
lwip_recv_tcp: deleting pbuf=0x2001c4fc
lwip_recv_tcp: top while sock->lastdata=0x0
lwip_recv_tcp: netconn_recv err=-7, pbuf=0x0
tcp_recved: received 1288 bytes, wnd 8196 (0).
lwip_recvfrom(0):  addr=23.225.33.154 port=80 len=1288
lwip_recvfrom(0, 0x2004274e, 2658, 0x0, ..)
lwip_recv_tcp: top while sock->lastdata=0x0
tcpip_thread: PACKET 0x2001eefc
tcp_receive: window update 64154
lwip_recv_tcp: netconn_recv err=0, pbuf=0x2001c4fc
lwip_recv_tcp: buflen=1360 recv_left=2658 off=0
lwip_recv_tcp: deleting pbuf=0x2001c4fc
lwip_recv_tcp: top while sock->lastdata=0x0
lwip_recv_tcp: netconn_recv err=-7, pbuf=0x0
tcp_recved: received 1360 bytes, wnd 8196 (0).
lwip_recvfrom(0):  addr=23.225.33.154 port=80 len=1360
lwip_recvfrom(0, 0x20042c9e, 1298, 0x0, ..)
tcpip_thread: PACKET 0x2001eefc
tcp_receive: window update 64154
lwip_recv_tcp: top while sock->lastdata=0x0
lwip_recv_tcp: netconn_recv err=0, pbuf=0x2001c4fc
lwip_recv_tcp: buflen=1360 recv_left=1298 off=0
lwip_recv_tcp: lastdata now pbuf=0x2001c4fc
tcpip_thread: PACKET 0x2001eefc
tcp_receive: window update 64154
tcp_recved: received 1298 bytes, wnd 6774 (1422).
lwip_recvfrom(0):  addr=tcpip_thread: PACKET 0x2001eefc
tcp_receive: window update 64154
23.225.33.154 port=80 len=1298
lwip_recvfrom(0, 0x200411b0, 5861, 0x0, ..)
lwip_recv_tcp: top while sock->lastdata=0x2001c4fc
lwip_recv_tcp: buflen=62 recv_left=5861 off=0
lwip_recv_tcp: deleting pbuf=0x2001c4fc
lwip_recv_tcp: top while sock->lastdata=0x0
lwip_recv_tcp: netconn_recv err=0, pbuf=0x2001ac5c
lwip_recv_tcp: buflen=1360 recv_left=5799 off=62
lwip_recv_tcp: deleting pbuf=0x2001ac5c
lwip_recv_tcp: top while sock->lastdata=0x0
lwip_recv_tcp: netconn_recv err=0, pbuf=0x2001bed4
lwip_recv_tcp: buflen=1360 recv_left=4439 off=1422
lwip_recv_tcp: deleting pbuf=0x2001bed4
lwip_recv_tcp: top while sock->lastdata=0x0
lwip_recv_tcp: netconn_recv err=-7, pbuf=0x0
tcp_recved: received 2782 bytes, wnd 8196 (0).
lwip_recvfrom(0):  addr=23.225.33.154 port=80 len=2782
lwip_recvfrom(0, 0x20041c8e, 3079, 0x0, ..)
lwip_recv_tcp: top while sock->lastdata=0x0
tcpip_thread: PACKET 0x2001eefc
tcp_receive: window update 64154
lwip_recv_tcp: netconn_recv err=0, pbuf=0x2001bed4
tcpip_thread: PACKET 0x2001eefc
tcp_receive: window update 64154
lwip_recv_tcp: buflen=1360 recv_left=3079 off=0
tcpip_thread: PACKET 0x2001eefc
tcp_receive: window update 64154
lwip_recv_tcp: deleting pbuf=0x2001bed4
lwip_recv_tcp: top while sock->lastdata=0x0
lwip_recv_tcp: netconn_recv err=0, pbuf=0x2001ac5c
lwip_recv_tcp: buflen=108 recv_left=1719 off=1360
lwip_recv_tcp: deleting pbuf=0x2001ac5c
lwip_recv_tcp: top while sock->lastdata=0x0
lwip_recv_tcp: netconn_recv err=0, pbuf=0x2001c4fc
lwip_recv_tcp: buflen=1252 recv_left=1611 off=1468
lwip_recv_tcp: deleting pbuf=0x2001c4fc
lwip_recv_tcp: top while sock->lastdata=0x0
lwip_recv_tcp: netconn_recv err=-7, pbuf=0x0
tcp_recved: received 2720 bytes, wnd 8196 (0).
lwip_recvfrom(0):  addr=23.225.33.154 port=80 len=2720
lwip_recvfrom(0, 0x2004272e, 359, 0x0, ..)
lwip_recv_tcp: top while sock->lastdata=0x0
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcpip_thread: PACKET 0x2001eefc
tcp_receive: window update 64154
lwip_recv_tcp: netconn_recv err=0, pbuf=0x2001c4fc
lwip_recv_tcp: buflen=359 recv_left=359 off=0
lwip_recv_tcp: deleting pbuf=0x2001c4fc
tcp_recved: received 359 bytes, wnd 8196 (0).
lwip_recvfrom(0):  addr=23.225.33.154 port=80 len=359
[Delay Stats] Avg: 616 ms, Min: 292 ms, Max: 2544 ms, Count: 330

=== Final Delay Statistics ===
Total reads: 330
Average delay: 616 ms
Min delay: 292 ms
Max delay: 2544 ms
==============================

想知道20kb 就已经是最大速度了吗,同时A2DP也处于打开状态 是A2DP限制了网速吗

static int pan_download(int argc, char **argv) {
    const char *url = argv[1];
    const char *output = argv[2];
    
    // 禁用Sniff模式
    bt_interface_set_sniff_enable(0);
    
    // 创建会话(8KB缓冲区)
    struct webclient_session *session = webclient_session_create(8192);
    
    // 发送GET请求
    int resp_status = webclient_get(session, url);
    if (resp_status != 200) {
        goto cleanup;
    }
    
    // 打开输出文件
    int fd = open(output, O_WRONLY | O_CREAT | O_TRUNC, 0666);
    
    // 分配缓冲区(8KB)
    char *buffer = rt_malloc(8192);
    
    // 下载数据(不让出CPU)
    while (1) {
        int bytes_read = webclient_read(session, buffer, 8192);
        if (bytes_read <= 0) break;
        
        write(fd, buffer, bytes_read);
    }
    
cleanup:
    bt_interface_set_sniff_enable(1);  // 恢复Sniff
    rt_free(buffer);
    close(fd);
    webclient_close(session);
    return 0;
}

你换个手机测试也是这样的吗?

理论上跟你发的包大小也有关系

原本以为测试的网址应该没限速 因为浏览器下载很快 秒下,后来禁用了浏览器缓存发现网站有限速,我后边再测试看看 感谢解答