Skip to main content
ismail fatih iltar
Associate III
June 28, 2018
Question

disco/nucleo board ultra low speed ethernet

  • June 28, 2018
  • 1 reply
  • 4727 views
Posted on June 28, 2018 at 15:04

Hello, im generating default ethernet codes from CubeMX. im using freertos+lwip and i set static ip. All other lwip settings are default. My clock config:

0690X0000060LWyQAM.png

My default lwIP settings:

0690X0000060LX3QAM.png

My default FreeRtos settings:

0690X0000060LTvQAM.png

And i use simple below iperf codes for test.

void iperfthread(void *arg) {  ethernetif_input(&gnetif); }  void iperf_test_start(void) {  sys_thread_new(''iperfthread'', iperfthread, NULL, 128, osPriorityRealtime ); }  static err_t iperf_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) {  LWIP_UNUSED_ARG(arg);   if (err == ERR_OK && p != NULL) {  tcp_recved(pcb, p->tot_len);  pbuf_free(p);  } else  if (err != ERR_OK && p != NULL) {  pbuf_free(p);  }   if (err == ERR_OK && p == NULL) {  tcp_arg(pcb, NULL);  tcp_sent(pcb, NULL);  tcp_recv(pcb, NULL);  tcp_close(pcb);  }  return ERR_OK; }  static err_t iperf_accept(void *arg, struct tcp_pcb *pcb, err_t err) {  LWIP_UNUSED_ARG(arg);  LWIP_UNUSED_ARG(err);   tcp_arg(pcb, NULL);  tcp_sent(pcb, NULL);  tcp_recv(pcb, iperf_recv);  return ERR_OK; }  void iperf_init(void) {  struct tcp_pcb *pcb;   pcb = tcp_new();  tcp_bind(pcb, IP_ADDR_ANY, 5001); // bind to iperf port  pcb = tcp_listen(pcb);  tcp_accept(pcb, iperf_accept);  }   �?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

im creating simple thread for iperf task. And this is my main

int main(void) {  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */  HAL_Init();   /* Configure the system clock */  SystemClock_Config();   /* Initialize all configured peripherals */  MX_GPIO_Init();  MX_RTC_Init();  MX_TIM1_Init();  /* USER CODE BEGIN 2 */  MX_LWIP_Init();   iperf_init();  iperf_test_start();   /* USER CODE END 2 */   /* Start scheduler */  osKernelStart();    /* We should never get here as control is now taken by the scheduler */  /* USER CODE BEGIN WHILE */  while (1)  {  } }�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Test results are so bad. 11-12Mbits/sec.0690X0000060LPaQAM.png

For nucleo board the speed is 15 Mbps

0690X0000060LXJQA2.png

How can i fix and increase it ?

#cubemx #ethernet #lwip #iperf #discovery

Note: this post was migrated and contained many threaded conversations, some content may be missing.
This topic has been closed for replies.

1 reply

Bogdan Golab
Lead
June 29, 2018
Posted on June 29, 2018 at 16:40

TCP_MSS is set to 536 bytes. I would increase it to 1460 bytes as the TCP header takes 20 bytes + IP header 20 bytes.

This would fit the Ehernet MTU of 1500 bytes.

The goal is to increase the packet size and reduce time spent on processing headers (to lower the number of packets).

Try to collect some Wireshark traces to prove what packet size is really used.

I have never tested the TCP_MSS value on the STM32. This is general approach to TCP based communication

ismail fatih iltar
Associate III
July 2, 2018
Posted on July 02, 2018 at 07:13

I tried your advice. Its so logical. But there is no change. Unlike, it fixes the speed 191 Kbits/sec after some times. When i manually restart it reaches 15 Mbits/sec again. Is there a problem about buffers or etc. ? 

Bogdan Golab
Lead
July 2, 2018
Posted on July 02, 2018 at 07:27

I wonder if the change of the MSS really change the packet size. I would capture wireshark traces to see it.

They suggest some improvements here but I have not tested it (I use Ethernet on STM32 sporadically, for pretty low tyransfer):

http://lwip.wikia.com/wiki/Tuning_TCP