tcp client build up the connection slowly with the server

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

tcp client build up the connection slowly with the server

koszo.simon
I created my own http client based on the example which is in the answer of
this question:
https://stackoverflow.com/questions/26192758/how-can-i-send-a-simple-http-request-with-a-lwip-stack

It works well, however I am not satisfied with the speed of the building up
of the tcp connection. I printed out the value of a millisecond counter when
the tcp_setup() function was called and when the connectCallback() function
was called. The difference between the values are usually around 280 ms
which is much bigger than I expected (less then 50 ms).

What do you think? Is my expactation unrealistic? Or: Is there some problem
with the network/server/lwip?

I have tried to connect to three different servers running on different
computers in the network, but the statistisc were the same. So I firstly
suspect lwip...

Do you have any idea what I should check in my lwipopts.h file (or somewhere
else)?



--
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 build up the connection slowly with the server

goldsimon@gmx.de
Am 25.06.2019 um 16:19 schrieb koszo.simon:
> I created my own http client based on the example which is in the answer of
> this question:
> https://stackoverflow.com/questions/26192758/how-can-i-send-a-simple-http-request-with-a-lwip-stack


You created your own http client? Why don't you use the one coming with
lwIP? (And yes, I'm too lazy to open that stackoverflow thing...)

> It works well, however I am not satisfied with the speed of the building up
> of the tcp connection. I printed out the value of a millisecond counter when
> the tcp_setup() function was called and when the connectCallback() function
> was called. The difference between the values are usually around 280 ms
> which is much bigger than I expected (less then 50 ms).
>
> What do you think? Is my expactation unrealistic? Or: Is there some problem
> with the network/server/lwip?

Ehrm, that depends on *so* many factors. On a local network with a
decent embedded system (e.g. Cortex-M around 50 MHz or more), a
connection time of ~1ms should be normal, so yes, you seem to have a
problem.

> I have tried to connect to three different servers running on different
> computers in the network, but the statistisc were the same. So I firstly
> suspect lwip...

Why do people always search for problems in other people's work? As I've
written above, lwIP is perfectly capable of much faster connection setup
than you even thought. This is not an lwIP problem but rather a problem
of your setup (or whoever you got your setup from). And by setup I mean
the OS port, CPU port, netif driver, etc.

Regards,
Simon

_______________________________________________
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 build up the connection slowly with the server

koszo.simon
Thank you for your quick answer! I appreciate that you answer to such a
begginner like me.

>You created your own http client? Why don't you use the one coming with
>lwIP? (And yes, I'm too lazy to open that stackoverflow thing...)

Yes, I had to. All documentation which I found about the built in http
client was this:
https://www.nongnu.org/lwip/2_1_x/group__httpc.html
Based on this I could nicely download files from the server with this code:

   ip_addr_t server_addr;
   IP4_ADDR(&server_addr, 192, 168, 0, 119);
   char domain_name[30] = "www.procontrol.hu";
   domain_name[17] = '\0';
   u16_t portnum = 80;
   httpc_connection_t *conn_settings_try;
   conn_settings_try->use_proxy = 0;

   char url[100] = "/index.html";
   char url[11] = '\0';

   httpc_get_file(&server_addr, portnum, url, conn_settings_try,
HttpClientGetFileReceive, NULL,
   NULL);
   //httpc_get_file_dns(domain_name, portnum, url, conn_settings_try,
HttpClientGetFileReceive,
   //NULL, NULL);

However I could not use the httpc_get_file_dns() function. I would be happy
if someone could help me to use the built in http client.

>Why do people always search for problems in other people's work? As I've
>written above, lwIP is perfectly capable of much faster connection setup
>than you even thought. This is not an lwIP problem but rather a problem
>of your setup (or whoever you got your setup from). And by setup I mean
>the OS port, CPU port, netif driver, etc.

Thank you for the tips. I have forgotten that there are communcation layers
even under lwip...

Regards,
Simon Kószó




--
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 build up the connection slowly with the server

koszo.simon
Dear Simon,

Thank you for your answer again: it helped me to exclude lwip from the
possible reasons of the slow behaviour. Now I have found the reason
somewhere else in the program.

Sorry again for suspecting lwIP.

Regards,
Simon Kószó




--
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