lwip 快速 高频 短帧发送 测试
正在做CAN报文转TCP , 当 CAN 产生大量报文时,每接收到一帧CAN报文,调用
netconn_write(new_conn, buff, len, NETCONN_COPY); 一次,则会产生大量的软件开销;
当前 lwipopts.h 文件中, TCP_MSS 设置为 1460 ,
test1:建立1460缓存区,20字节的报文填充到缓冲区,填充73帧,缓存区共计1460字节,调用一次 netconn_write 接口,共计调用200次;
test2:发送帧长度为20字节的报文,每发送一帧调用一次netconn_write接口,共计调用14600次;
测试3次
test1,size=1460,cnt=200,tick= 744 ms. // 总线速率 约 400 KB/s 速率太慢了
test2,size=20,cnt=14600,tick= 4686 ms.
test1,size=1460,cnt=200,tick= 901 ms. // 更慢了
test2,size=20,cnt=14600,tick= 5878 ms.
test1,size=1460,cnt=200,tick= 977 ms.
test2,size=20,cnt=14600,tick= 6477 ms.
问题分析:每次测试时间不固定,还比较慢, 可能是上位机,用的串口工具,显示数据影响了数据传输速度。因此更换一个 上位机接收数据缓存在 RAM中; 再次进行测试, 16ms 和 70ms 的区别, 偶尔会发生首帧延迟1S的情况;
tcp rx one frame:,len:8.
0x23 0x23 0x23 0x23 0x08 0x00 0x00 0x00
test1,size=1460,cnt=200,tick= 15 ms.
test2,size=20,cnt=14600,tick= 71 ms.
tcp rx one frame:,len:8.
0x23 0x23 0x23 0x23 0x08 0x00 0x00 0x00
test1,size=1460,cnt=200,tick= 16 ms.
test2,size=20,cnt=14600,tick= 70 ms.
tcp rx one frame:,len:8.
0x23 0x23 0x23 0x23 0x08 0x00 0x00 0x00
test1,size=1460,cnt=200,tick= 15 ms.
test2,size=20,cnt=14600,tick= 71 ms.
tcp rx one frame:,len:8.
0x23 0x23 0x23 0x23 0x08 0x00 0x00 0x00
test1,size=1460,cnt=200,tick= 15 ms.
test2,size=20,cnt=14600,tick= 70 ms.
tcp rx one frame:,len:8.
0x23 0x23 0x23 0x23 0x08 0x00 0x00 0x00
test1,size=1460,cnt=200,tick= 16 ms. // 约 17.4MB/S
test2,size=20,cnt=14600,tick= 69 ms.
tcp rx one frame:,len:8.
0x23 0x23 0x23 0x23 0x08 0x00 0x00 0x00
test1,size=1460,cnt=200,tick= 1158 ms.
test2,size=20,cnt=14600,tick= 69 ms.
tcp rx one frame:,len:8.
0x23 0x23 0x23 0x23 0x08 0x00 0x00 0x00
test1,size=1460,cnt=200,tick= 16 ms.
test2,size=20,cnt=14600,tick= 70 ms.
tcp rx one frame:,len:8.
0x23 0x23 0x23 0x23 0x08 0x00 0x00 0x00
test1,size=1460,cnt=200,tick= 1338 ms.
test2,size=20,cnt=14600,tick= 69 ms.
浙公网安备 33010602011771号