刚刚用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[ADDR_LENGTH] = {192, 168, 53, 32};
static uint8_t G_GW[ADDR_LENGTH] = {192, 168, 53, 2};
static uint8_t G_MASK[ADDR_LENGTH] = {255, 255, 255, 0};
#endif
/* Private function prototypes -----------------------------------------------*/
extern void client_init(void);
extern void server_init(void);
/* Private functions ---------------------------------------------------------*/
/**
* [url=home.php?mod=space&uid=247401]@brief[/url] Initializes the lwIP stack
* @param None
* @retval None
*/
void LwIP_Init(void)
{
ip_addr_t ipaddr;
ip_addr_t netmask;
ip_addr_t gw;
uint8_t macaddress[6]={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[0], G_IP[1], G_IP[2], G_IP[3]);
IP4_ADDR(&netmask, G_MASK[0], G_MASK[1], G_MASK[2], G_MASK[3]);
IP4_ADDR(&gw, G_GW[0], G_GW[1], G_GW[2], G_GW[3]);
#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, ðernetif_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);
}
/**
* @brief Called when a frame is received
* @param None
* @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);
}
/**
* @brief LwIP periodic tasks
* @param localtime 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)
------------------------------------------------------------
[ 3] local 192.168.53.2 port 59678 connected with 192.168.53.32 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0- 2.0 sec 15.2 MBytes 64.0 Mbits/sec
[ 3] 2.0- 4.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 4.0- 6.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 6.0- 8.0 sec 15.2 MBytes 64.0 Mbits/sec
[ 3] 8.0-10.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 10.0-12.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 12.0-14.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 14.0-16.0 sec 15.2 MBytes 64.0 Mbits/sec
[ 3] 16.0-18.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 18.0-20.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 20.0-22.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 22.0-24.0 sec 15.2 MBytes 64.0 Mbits/sec
[ 3] 24.0-26.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 26.0-28.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 28.0-30.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 30.0-32.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 32.0-34.0 sec 15.2 MBytes 64.0 Mbits/sec
[ 3] 34.0-36.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 36.0-38.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 38.0-40.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 40.0-42.0 sec 15.2 MBytes 64.0 Mbits/sec
[ 3] 42.0-44.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 44.0-46.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 46.0-48.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 48.0-50.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 50.0-52.0 sec 15.2 MBytes 64.0 Mbits/sec
[ 3] 52.0-54.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 54.0-56.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 56.0-58.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 58.0-60.0 sec 15.1 MBytes 63.4 Mbits/sec
[ 3] 0.0-60.0 sec 455 MBytes 63.6 Mbits/sec
|