A question about "lwip_tcpecho" example based on KSDK2.5-FRDM-K64F

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

A question about "lwip_tcpecho" example based on KSDK2.5-FRDM-K64F

1,592件の閲覧回数
cuizhuangping
Contributor I

Hi:

   I encountered a  question about "lwip_tcpecho" example based on KSDK2.5-FRDM-K64F, recently. I used a tcp tool  to test after the "lwip_tcpecho" example is programmed to the board. The tcp tool can get periodic data after a  tcp socket connection is established with periodic send option. However, Another socket connection can still establish since there is already running one.Moreover, the ethernet will broken after the later socket send several packets to the board. The previous socket will disconnet and It cannot ping to the board after the ethernet is broken. Is there any implict "accept" function to establish new socket connect? And send data throw new socket connect will destruct the ethernet?

0 件の賞賛
返信
3 返答(返信)

1,491件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi zhuangping:

Not sure what TCP tool you are using.

But please be aware that the tcpecho demo sends back all the received TCP packets from the PC.

The implementation is like this

  /* 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);
    }
  }

as you can see, it always accept new connection, send buffer, delete connection. It is only used to test whether a TCP connection is available.

I am doubting your TCP tool behaviour will result in huge network traffic, then system will crash.

Regards

Daniel

0 件の賞賛
返信

1,491件の閲覧回数
cuizhuangping
Contributor I

Hi

   Daniel,It has the same problem to echo example with freertos system when I changed to "MK66" freedom board? It seems that the ethernet bug come from ksdk itself? It rather strange why new tcp connection can rebuilt since there is already one running?

0 件の賞賛
返信

1,491件の閲覧回数
cuizhuangping
Contributor I

Hi

   Daniel, The tcp tool is uploaded. I tried two kinds of tcp tool at least.I traced the code which is just the code you sticked here. The programme entered the "while cycle" after a  tcp socket connection is estabulish. However, I have no idea why another socket connection can also estabulish at the same time since the code has entered the "while cycle". And Sending data throw the later socket can result in huge network traffic while other thread is normal.

0 件の賞賛
返信