TCP Client handshakes but no data transmission

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

TCP Client handshakes but no data transmission

tirmalabenikasibeni
Hello everyone,

I am new in developing with LwIP and working on a TCP Client using RAW API,
FreeRTOS 9.0.0, LwIP 2.0.3, STM32H743BI.
I can succesfully establish connection but cannot send or receive data. PCAP
file is attached.
I wrote the code refer to tcpecho_client example with minimal changes and
can share if needed. I appreciate any help.

Thank you!

Btw an HTTP server (using netconn) is running simultaneously.

TCP_Client.pcapng
<http://lwip.100.n7.nabble.com/file/t2209/TCP_Client.pcapng>  



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: TCP Client handshakes but no data transmission

ricardoschoof
Hi,

Please read for more information about the API's:
https://www.nongnu.org/lwip/2_0_x/raw_api.html

/When running in a multithreaded environment, raw API functions MUST only be
called from the core thread since raw API functions are not protected from
concurrent access (aside from pbuf- and memory management functions). /

Running netconn and raw might interfere with each other. My suggestion would
be to run the TCP Client also in either netconn or socket mode.

Cheers!




--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: TCP Client handshakes but no data transmission

tirmalabenikasibeni
Hi Ricardo,


ricardoschoof wrote
> Please read for more information about the API's:
> https://www.nongnu.org/lwip/2_0_x/raw_api.html

I have read that doc. Point is I have a TCP server also written using RAW
API, and it works fine. I have tried to write this server with netconn but
failed.

But I'm gonna try netconn right now,

THX!



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: TCP Client handshakes but no data transmission

tirmalabenikasibeni
In reply to this post by ricardoschoof
I've changed my code like this:

void client_netconn_thread(void){
  ip_addr_t DEST_IP, LOC_IP;
  err_t err0, err2;
  struct netconn *conn;
  struct netbuf *incoming;
  char* buf;
  Ui16 buflen, i;

  IP4_ADDR(&LOC_IP, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3 );
  IP4_ADDR(&DEST_IP, DEST_IP_ADDR0, DEST_IP_ADDR1, DEST_IP_ADDR2,
DEST_IP_ADDR3);

  conn = netconn_new(NETCONN_TCP);

  if(conn != NULL){
    err0 = netconn_bind(conn, &LOC_IP, MODBUS_PORT);
    netconn_connect(conn, &DEST_IP, MODBUS_PORT);
  }
  if((err0 == ERR_OK)){
    while(TRUE){
      netconn_write(conn, (const unsigned char*)(TXData), (size_t)(1500),
NETCONN_NOCOPY);
      osDelay(10);
      err2 = netconn_recv(conn, &incoming);
      if(err2 == ERR_OK){
        if (netconn_err(conn) == ERR_OK){
            netbuf_data(incoming, (void**)&buf, &buflen);

            for(i=0; i<buflen; i++){
              RXData[i] = *(Ui08 *)buf;
              buf++;
            }
            netbuf_delete(incoming);
          }
      }
    }
  }
  else netconn_delete(conn);
}

But result is the same, nothing changed. PCAPs has no difference.

Thanks.



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: TCP Client handshakes but no data transmission

ricardoschoof
This post was updated on .
Hi,
I've run your code, with a few changes. I am able to have TCP communication.
First thing I noticed was the large amount of data you're sending [netconn_write(conn, (const unsigned char*)(TXData), (size_t)(1500)), NETCONN_NOCOPY);] is this causing some overflow?

Next step would be checking the configuration. Is there some kind of firewall active between the 2 devices? And do you have enough memory assigned i.e. enough netbuffs/netconns etc. in lwipoprts?

Altered code, pardon my goto's but it's a quick test:
void client_netconn_thread(void* pvParam){
  ip_addr_t DEST_IP;
  struct netconn *conn = NULL;
  struct netbuf *incoming;

  IP4_ADDR(&DEST_IP, XXX, XXX, XXX, XXX);

  conn = netconn_new(NETCONN_TCP);

  if(conn != NULL){
    if (ERR_OK != netconn_bind(conn, NULL, MODBUS_PORT))
      goto err;
    if (ERR_OK != netconn_connect(conn, &DEST_IP, MODBUS_PORT))
      goto err;
  }
  while(true){
    if (ERR_OK != netconn_write(conn, "request", 8, NETCONN_NOCOPY))
      goto err;
    vTaskDelay(500);
    if (ERR_OK != netconn_recv(conn, &incoming))
      goto err;
    if (netconn_err(conn) == ERR_OK){
      netbuf_delete(incoming);
    }
  }

err:
  netconn_close(conn);
  netconn_delete(conn);
  vTaskDelete(NULL);
}




-----Original Message-----
> From: lwip-users <lwip-users-bounces+r.schoof=orga.nl@nongnu.org> On
> Behalf Of tirmalabenikasibeni
> Sent: Tuesday, 30 April 2019 14:44
> To: lwip-users@nongnu.org
> Subject: Re: [lwip-users] TCP Client handshakes but no data transmission
>
> I've changed my code like this:
>
> void client_netconn_thread(void){
>   ip_addr_t DEST_IP, LOC_IP;
>   err_t err0, err2;
>   struct netconn *conn;
>   struct netbuf *incoming;
>   char* buf;
>   Ui16 buflen, i;
>
>   IP4_ADDR(&LOC_IP, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3 );
>   IP4_ADDR(&DEST_IP, DEST_IP_ADDR0, DEST_IP_ADDR1, DEST_IP_ADDR2,
> DEST_IP_ADDR3);
>
>   conn = netconn_new(NETCONN_TCP);
>
>   if(conn != NULL){
>     err0 = netconn_bind(conn, &LOC_IP, MODBUS_PORT);
>     netconn_connect(conn, &DEST_IP, MODBUS_PORT);
>   }
>   if((err0 == ERR_OK)){
>     while(TRUE){
>       netconn_write(conn, (const unsigned char*)(TXData), (size_t)(1500),
> NETCONN_NOCOPY);
>       osDelay(10);
>       err2 = netconn_recv(conn, &incoming);
>       if(err2 == ERR_OK){
>         if (netconn_err(conn) == ERR_OK){
>             netbuf_data(incoming, (void**)&buf, &buflen);
>
>             for(i=0; i<buflen; i++){
>               RXData[i] = *(Ui08 *)buf;
>               buf++;
>             }
>             netbuf_delete(incoming);
>           }
>       }
>     }
>   }
>   else netconn_delete(conn);
> }
>
> But result is the same, nothing changed. PCAPs has no difference.
>
> Thanks.
>
>
>
> --
> Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html
>
> _______________________________________________
> lwip-users mailing list
> lwip-users@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/lwip-users

_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

tcp.pcapng (4K) <http://lwip.100.n7.nabble.com/attachment/34410/0/tcp.pcapng>
Reply | Threaded
Open this post in threaded view
|

Re: TCP Client handshakes but no data transmission

tirmalabenikasibeni
Hi,


ricardoschoof wrote
> First thing I noticed was the large amount of data you're sending
> [netconn_write(conn, (const unsigned char*)(TXData), (size_t)(1500)),
> NETCONN_NOCOPY);] is this causing some overflow?

I just tried with 150 and 15, it doesnt have an effect. Besides my
ETH_RX_BUFFER_SIZE is 1536UL

And also tried your code and it worked for me, too.

After that I change only line of netconn_write in my own and it worked too.
The problem is second argument of netconn_write. Data type is not valid, I
guess. But it never returned me an error.

Anyway, thanks a lot bro, it was very helpful!



--
Sent from: http://lwip.100.n7.nabble.com/lwip-users-f3.html

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users