大头哥 发表于 2021-2-3 09:22

【AT-START-F407测评】ETH + LwIP2.1.2 iPerf 实测63.6MB/s

刚刚用BSP自带的DEMO ETH实测了一下网口加载和速度, 63.6MB/s。

只改了IP地址:

/**
******************************************************************************
* File   : netconf.c
* Version: V1.2.8
* Date   : 2020-11-27
* Brief: Network connection configuration
******************************************************************************
*/

/* Includes ------------------------------------------------------------------*/
#include "lwip/memp.h"
#include "lwip/tcp.h"
#include "lwip/priv/tcp_priv.h"
#include "lwip/udp.h"
#include "netif/etharp.h"
#include "lwip/dhcp.h"
#include "ethernetif.h"
#include "main.h"
#include "netconf.h"
#include <stdio.h>

/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
#define ADDR_LENGTH   (4)
/* Private variables ---------------------------------------------------------*/
struct netif netif;
__IO uint32_t TCPTimer = 0;
__IO uint32_t ARPTimer = 0;

#if LWIP_DHCP
__IO uint32_t DHCPfineTimer = 0;
__IO uint32_t DHCPcoarseTimer = 0;
static uint32_t IPaddress = 0;
#else
static uint8_t G_IP   = {192, 168, 53, 32};
static uint8_t G_GW   = {192, 168, 53, 2};
static uint8_t G_MASK = {255, 255, 255, 0};
#endif

/* Private function prototypes -----------------------------------------------*/
extern void client_init(void);
extern void server_init(void);

/* Private functions ---------------------------------------------------------*/

/**
* @briefInitializes the lwIP stack
* @paramNone
* @retval None
*/
void LwIP_Init(void)
{
ip_addr_t ipaddr;
ip_addr_t netmask;
ip_addr_t gw;
uint8_t macaddress={0,0,0x44,0x45,0x56,1};

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

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


#if LWIP_DHCP//need DHCP server
ipaddr.addr = 0;
netmask.addr = 0;
gw.addr = 0;

#else
IP4_ADDR(&ipaddr, G_IP, G_IP, G_IP, G_IP);
IP4_ADDR(&netmask, G_MASK, G_MASK, G_MASK, G_MASK);
IP4_ADDR(&gw, G_GW, G_GW, G_GW, G_GW);
#endif

Set_MAC_Address(macaddress);

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

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

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


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

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

}

/**
* @briefCalled when a frame is received
* @paramNone
* @retval None
*/
void LwIP_Pkt_Handle(void)
{
/* Read a received packet from the Ethernet buffers and send it to the lwIP for handling */
ethernetif_input(&netif);
}

/**
* @briefLwIP periodic tasks
* @paramlocaltime the current LocalTime value
* @retval None
*/
void LwIP_Periodic_Handle(__IO uint32_t localtime)
{

/* TCP periodic process every 250 ms */
if (localtime - TCPTimer >= TCP_TMR_INTERVAL)
{
    TCPTimer =localtime;
    tcp_tmr();
}
/* ARP periodic process every 5s */
if (localtime - ARPTimer >= ARP_TMR_INTERVAL)
{
    ARPTimer =localtime;
    etharp_tmr();
}

#if LWIP_DHCP
/* Fine DHCP periodic process every 500ms */
if (localtime - DHCPfineTimer >= DHCP_FINE_TIMER_MSECS)
{
    DHCPfineTimer =localtime;
    dhcp_fine_tmr();
}
/* DHCP Coarse periodic process every 60s */
if (localtime - DHCPcoarseTimer >= DHCP_COARSE_TIMER_MSECS)
{
    DHCPcoarseTimer =localtime;
    dhcp_coarse_tmr();
}
#endif

}


iPerf的实测结果:
    user@ubuntu1804 ~ $ sudo iperf -c 192.168.53.32 -i 2 -t 60
    ------------------------------------------------------------
    Client connecting to 192.168.53.32, TCP port 5001
    TCP window size: 85.0 KByte (default)
    ------------------------------------------------------------
    local 192.168.53.2 port 59678 connected with 192.168.53.32 port 5001
    [ ID] Interval       Transfer   Bandwidth
    0.0- 2.0 sec15.2 MBytes64.0 Mbits/sec
    2.0- 4.0 sec15.1 MBytes63.4 Mbits/sec
    4.0- 6.0 sec15.1 MBytes63.4 Mbits/sec
    6.0- 8.0 sec15.2 MBytes64.0 Mbits/sec
    8.0-10.0 sec15.1 MBytes63.4 Mbits/sec
    10.0-12.0 sec15.1 MBytes63.4 Mbits/sec
    12.0-14.0 sec15.1 MBytes63.4 Mbits/sec
    14.0-16.0 sec15.2 MBytes64.0 Mbits/sec
    16.0-18.0 sec15.1 MBytes63.4 Mbits/sec
    18.0-20.0 sec15.1 MBytes63.4 Mbits/sec
    20.0-22.0 sec15.1 MBytes63.4 Mbits/sec
    22.0-24.0 sec15.2 MBytes64.0 Mbits/sec
    24.0-26.0 sec15.1 MBytes63.4 Mbits/sec
    26.0-28.0 sec15.1 MBytes63.4 Mbits/sec
    28.0-30.0 sec15.1 MBytes63.4 Mbits/sec
    30.0-32.0 sec15.1 MBytes63.4 Mbits/sec
    32.0-34.0 sec15.2 MBytes64.0 Mbits/sec
    34.0-36.0 sec15.1 MBytes63.4 Mbits/sec
    36.0-38.0 sec15.1 MBytes63.4 Mbits/sec
    38.0-40.0 sec15.1 MBytes63.4 Mbits/sec
    40.0-42.0 sec15.2 MBytes64.0 Mbits/sec
    42.0-44.0 sec15.1 MBytes63.4 Mbits/sec
    44.0-46.0 sec15.1 MBytes63.4 Mbits/sec
    46.0-48.0 sec15.1 MBytes63.4 Mbits/sec
    48.0-50.0 sec15.1 MBytes63.4 Mbits/sec
    50.0-52.0 sec15.2 MBytes64.0 Mbits/sec
    52.0-54.0 sec15.1 MBytes63.4 Mbits/sec
    54.0-56.0 sec15.1 MBytes63.4 Mbits/sec
    56.0-58.0 sec15.1 MBytes63.4 Mbits/sec
    58.0-60.0 sec15.1 MBytes63.4 Mbits/sec
    0.0-60.0 sec   455 MBytes63.6 Mbits/sec

caizhiwei 发表于 2021-2-13 13:58

标题有误,63.6 Mbits/,注意是bit哦,不是Byte
页: [1]
查看完整版本: 【AT-START-F407测评】ETH + LwIP2.1.2 iPerf 实测63.6MB/s