在线时间588 小时
UID3469866
注册时间2018-4-19
NXP金币2806
TA的每日心情 | 慵懒 2024-2-8 09:39 |
---|
签到天数: 217 天 [LV.7]常住居民III
版主
- 积分
- 7576
- 最后登录
- 2024-4-17
|
本帖最后由 az158 于 2021-9-20 18:13 编辑
NXP针对以太网的操作提供了相当齐全的例程。主要是freertos加lwip的方案,很经典也很好用。
今天笔者就简单测一下RT1176板卡的千兆以太网速率。这里使用的例程是SDK_2_10_0_MIMXRT1170-EVK\boards\evkmimxrt1170\lwip_examples\lwip_iperf\bm\cm7\mdk。
iperf是是一个网络性能测试工具。Iperf可以测试最大TCP和UDP带宽性能,具有多种参数和UDP特性,可以根据需要调整,可以报告带宽、延迟抖动和数据包丢失。
可以在下面的代码里面配置默认的ip地址、掩码、网关。
- /* IP address configuration. */
- #define configIP_ADDR0 192
- #define configIP_ADDR1 168
- #define configIP_ADDR2 0
- #define configIP_ADDR3 102
- /* Netmask configuration. */
- #define configNET_MASK0 255
- #define configNET_MASK1 255
- #define configNET_MASK2 255
- #define configNET_MASK3 0
- /* Gateway address configuration. */
- #define configGW_ADDR0 192
- #define configGW_ADDR1 168
- #define configGW_ADDR2 0
- #define configGW_ADDR3 100
复制代码
设备接线
串口打印,这里笔者选择了1模式,测试TCP的RX速率
上位机显示,测试时间为60s
最终速率达到了253Mbit/s,对于一个单片机来说可以说相当惊人了。
之后笔者测试了freertos的tcp服务器的RX速度。不对接收到的数据做任何处理
- static void
- tcpecho_thread(void *arg)
- {
- struct netconn *conn, *newconn;
- err_t err;
- LWIP_UNUSED_ARG(arg);
- /* Create a new connection identifier. */
- /* Bind connection to well known port number 7. */
- #if LWIP_IPV6
- conn = netconn_new(NETCONN_TCP_IPV6);
- netconn_bind(conn, IP6_ADDR_ANY, 7);
- #else /* LWIP_IPV6 */
- conn = netconn_new(NETCONN_TCP);
- netconn_bind(conn, IP_ADDR_ANY, 7);
- #endif /* LWIP_IPV6 */
- LWIP_ERROR("tcpecho: invalid conn", (conn != NULL), return;);
- /* Tell connection to go into listening mode. */
- netconn_listen(conn);
- while (1) {
- /* Grab new connection. */
- err = netconn_accept(conn, &newconn);
- /*printf("accepted new connection %p\n", newconn);*/
- /* Process the new connection. */
- if (err == ERR_OK) {
- struct netbuf *buf;
- void *data;
- u16_t len;
- while ((err = netconn_recv(newconn, &buf)) == ERR_OK) {
- // /*printf("Recved\n");*/
- // do {
- // netbuf_data(buf, &data, &len);
- // err = netconn_write(newconn, data, len, NETCONN_COPY);
- //#if 0
- // if (err != ERR_OK) {
- // printf("tcpecho: netconn_write: error "%s"\n", lwip_strerr(err));
- // }
- //#endif
- // } while (netbuf_next(buf) >= 0);
- netbuf_delete(buf);
- }
- /*printf("Got EOF, looping\n");*/
- /* Close connection and discard connection identifier. */
- netconn_close(newconn);
- netconn_delete(newconn);
- }
- }
- }
复制代码 速度大约有45Mbit/s,这里估计是NXP并没有对其代码做优化,有时间可以继续试一下。
|
|