[活动专区] 【AT-START-F407测评】ETH + LwIP2.1.2 iPerf 实测63.6MB/s

[复制链接]
 楼主| 大头哥 发表于 2021-2-3 09:22 | 显示全部楼层 |阅读模式
刚刚用BSP自带的DEMO ETH实测了一下网口加载和速度, 63.6MB/s。

只改了IP地址:

  1. /**
  2.   ******************************************************************************
  3.   * File   : netconf.c
  4.   * Version: V1.2.8
  5.   * Date   : 2020-11-27
  6.   * Brief  : Network connection configuration
  7.   ******************************************************************************
  8.   */

  9. /* Includes ------------------------------------------------------------------*/
  10. #include "lwip/memp.h"
  11. #include "lwip/tcp.h"
  12. #include "lwip/priv/tcp_priv.h"
  13. #include "lwip/udp.h"
  14. #include "netif/etharp.h"
  15. #include "lwip/dhcp.h"
  16. #include "ethernetif.h"
  17. #include "main.h"
  18. #include "netconf.h"
  19. #include <stdio.h>

  20. /* Private define ------------------------------------------------------------*/
  21. /* Private macro -------------------------------------------------------------*/
  22. #define ADDR_LENGTH   (4)
  23. /* Private variables ---------------------------------------------------------*/
  24. struct netif netif;
  25. __IO uint32_t TCPTimer = 0;
  26. __IO uint32_t ARPTimer = 0;

  27. #if LWIP_DHCP
  28. __IO uint32_t DHCPfineTimer = 0;
  29. __IO uint32_t DHCPcoarseTimer = 0;
  30. static uint32_t IPaddress = 0;
  31. #else
  32. static uint8_t G_IP[ADDR_LENGTH]   = {192, 168, 53, 32};
  33. static uint8_t G_GW[ADDR_LENGTH]   = {192, 168, 53, 2};
  34. static uint8_t G_MASK[ADDR_LENGTH] = {255, 255, 255, 0};
  35. #endif

  36. /* Private function prototypes -----------------------------------------------*/
  37. extern void client_init(void);
  38. extern void server_init(void);

  39. /* Private functions ---------------------------------------------------------*/

  40. /**
  41.   * [url=home.php?mod=space&uid=247401]@brief[/url]  Initializes the lwIP stack
  42.   * @param  None
  43.   * @retval None
  44.   */
  45. void LwIP_Init(void)
  46. {
  47.   ip_addr_t ipaddr;
  48.   ip_addr_t netmask;
  49.   ip_addr_t gw;
  50.   uint8_t macaddress[6]={0,0,0x44,0x45,0x56,1};

  51.   /* Initializes the dynamic memory heap defined by MEM_SIZE.*/
  52.   mem_init();

  53.   /* Initializes the memory pools defined by MEMP_NUM_x.*/
  54.   memp_init();


  55. #if LWIP_DHCP  //need DHCP server
  56.   ipaddr.addr = 0;
  57.   netmask.addr = 0;
  58.   gw.addr = 0;

  59. #else
  60.   IP4_ADDR(&ipaddr, G_IP[0], G_IP[1], G_IP[2], G_IP[3]);
  61.   IP4_ADDR(&netmask, G_MASK[0], G_MASK[1], G_MASK[2], G_MASK[3]);
  62.   IP4_ADDR(&gw, G_GW[0], G_GW[1], G_GW[2], G_GW[3]);
  63. #endif

  64.   Set_MAC_Address(macaddress);

  65.   /* - netif_add(struct netif *netif, struct ip_addr *ipaddr,
  66.             struct ip_addr *netmask, struct ip_addr *gw,
  67.             void *state, err_t (* init)(struct netif *netif),
  68.             err_t (* input)(struct pbuf *p, struct netif *netif))
  69.    
  70.    Adds your network interface to the netif_list. Allocate a struct
  71.   netif and pass a pointer to this structure as the first argument.
  72.   Give pointers to cleared ip_addr structures when using DHCP,
  73.   or fill them with sane numbers otherwise. The state pointer may be NULL.

  74.   The init function pointer must point to a initialization function for
  75.   your ethernet netif interface. The following code illustrates it's use.*/
  76.   netif_add(&netif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &netif_input);

  77.   /*  Registers the default network interface.*/
  78.   netif_set_default(&netif);


  79. #if LWIP_DHCP
  80.   /*  Creates a new DHCP client for this interface on the first call.
  81.   Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at
  82.   the predefined regular intervals after starting the client.
  83.   You can peek in the netif->dhcp struct for the actual DHCP status.*/
  84.   dhcp_start(&netif);
  85. #endif

  86.   /*  When the netif is fully configured this function must be called.*/
  87.   netif_set_up(&netif);

  88. }

  89. /**
  90.   * @brief  Called when a frame is received
  91.   * @param  None
  92.   * @retval None
  93.   */
  94. void LwIP_Pkt_Handle(void)
  95. {
  96.   /* Read a received packet from the Ethernet buffers and send it to the lwIP for handling */
  97.   ethernetif_input(&netif);
  98. }

  99. /**
  100.   * @brief  LwIP periodic tasks
  101.   * @param  localtime the current LocalTime value
  102.   * @retval None
  103.   */
  104. void LwIP_Periodic_Handle(__IO uint32_t localtime)
  105. {

  106.   /* TCP periodic process every 250 ms */
  107.   if (localtime - TCPTimer >= TCP_TMR_INTERVAL)
  108.   {
  109.     TCPTimer =  localtime;
  110.     tcp_tmr();
  111.   }
  112.   /* ARP periodic process every 5s */
  113.   if (localtime - ARPTimer >= ARP_TMR_INTERVAL)
  114.   {
  115.     ARPTimer =  localtime;
  116.     etharp_tmr();
  117.   }

  118. #if LWIP_DHCP
  119.   /* Fine DHCP periodic process every 500ms */
  120.   if (localtime - DHCPfineTimer >= DHCP_FINE_TIMER_MSECS)
  121.   {
  122.     DHCPfineTimer =  localtime;
  123.     dhcp_fine_tmr();
  124.   }
  125.   /* DHCP Coarse periodic process every 60s */
  126.   if (localtime - DHCPcoarseTimer >= DHCP_COARSE_TIMER_MSECS)
  127.   {
  128.     DHCPcoarseTimer =  localtime;
  129.     dhcp_coarse_tmr();
  130.   }
  131. #endif

  132. }


iPerf的实测结果:
  1.     user@ubuntu1804 ~ $ sudo iperf -c 192.168.53.32 -i 2 -t 60
  2.     ------------------------------------------------------------
  3.     Client connecting to 192.168.53.32, TCP port 5001
  4.     TCP window size: 85.0 KByte (default)
  5.     ------------------------------------------------------------
  6.     [  3] local 192.168.53.2 port 59678 connected with 192.168.53.32 port 5001
  7.     [ ID] Interval       Transfer     Bandwidth
  8.     [  3]  0.0- 2.0 sec  15.2 MBytes  64.0 Mbits/sec
  9.     [  3]  2.0- 4.0 sec  15.1 MBytes  63.4 Mbits/sec
  10.     [  3]  4.0- 6.0 sec  15.1 MBytes  63.4 Mbits/sec
  11.     [  3]  6.0- 8.0 sec  15.2 MBytes  64.0 Mbits/sec
  12.     [  3]  8.0-10.0 sec  15.1 MBytes  63.4 Mbits/sec
  13.     [  3] 10.0-12.0 sec  15.1 MBytes  63.4 Mbits/sec
  14.     [  3] 12.0-14.0 sec  15.1 MBytes  63.4 Mbits/sec
  15.     [  3] 14.0-16.0 sec  15.2 MBytes  64.0 Mbits/sec
  16.     [  3] 16.0-18.0 sec  15.1 MBytes  63.4 Mbits/sec
  17.     [  3] 18.0-20.0 sec  15.1 MBytes  63.4 Mbits/sec
  18.     [  3] 20.0-22.0 sec  15.1 MBytes  63.4 Mbits/sec
  19.     [  3] 22.0-24.0 sec  15.2 MBytes  64.0 Mbits/sec
  20.     [  3] 24.0-26.0 sec  15.1 MBytes  63.4 Mbits/sec
  21.     [  3] 26.0-28.0 sec  15.1 MBytes  63.4 Mbits/sec
  22.     [  3] 28.0-30.0 sec  15.1 MBytes  63.4 Mbits/sec
  23.     [  3] 30.0-32.0 sec  15.1 MBytes  63.4 Mbits/sec
  24.     [  3] 32.0-34.0 sec  15.2 MBytes  64.0 Mbits/sec
  25.     [  3] 34.0-36.0 sec  15.1 MBytes  63.4 Mbits/sec
  26.     [  3] 36.0-38.0 sec  15.1 MBytes  63.4 Mbits/sec
  27.     [  3] 38.0-40.0 sec  15.1 MBytes  63.4 Mbits/sec
  28.     [  3] 40.0-42.0 sec  15.2 MBytes  64.0 Mbits/sec
  29.     [  3] 42.0-44.0 sec  15.1 MBytes  63.4 Mbits/sec
  30.     [  3] 44.0-46.0 sec  15.1 MBytes  63.4 Mbits/sec
  31.     [  3] 46.0-48.0 sec  15.1 MBytes  63.4 Mbits/sec
  32.     [  3] 48.0-50.0 sec  15.1 MBytes  63.4 Mbits/sec
  33.     [  3] 50.0-52.0 sec  15.2 MBytes  64.0 Mbits/sec
  34.     [  3] 52.0-54.0 sec  15.1 MBytes  63.4 Mbits/sec
  35.     [  3] 54.0-56.0 sec  15.1 MBytes  63.4 Mbits/sec
  36.     [  3] 56.0-58.0 sec  15.1 MBytes  63.4 Mbits/sec
  37.     [  3] 58.0-60.0 sec  15.1 MBytes  63.4 Mbits/sec
  38.     [  3]  0.0-60.0 sec   455 MBytes  63.6 Mbits/sec

caizhiwei 发表于 2021-2-13 13:58 | 显示全部楼层
标题有误,63.6 Mbits/,注意是bit哦,不是Byte
您需要登录后才可以回帖 登录 | 注册

本版积分规则

9

主题

57

帖子

0

粉丝
快速回复 在线客服 返回列表 返回顶部