buglwIP - A Lightweight TCP/IP stack - Bugs: bug #65630, issue to download file bigger than...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #65630: issue to download file bigger than 6KB using using https protocol

Submitter:  Stefano Oliveri <stf12>
Submitted:  Tue 23 Apr 2024 09:12:30 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  2.2.0

Tue 30 Apr 2024 03:22:25 PM UTC, comment #1: 

Hello,

I was able, finally, to move forward and make my application works.

The issue I noted (I am sure it depends on my integration of lwIP and Mbed TLS in the application), analyzing the communication sniffed with Wireshark, was a TCP Zero Window. I am trying to understand this mechanism, so any comment is welcome.

This TCP window size depends on the TCP_WND. At the beginning it 7300 in my case, and it worked fine without TLS. When I added the support the TCP window start to shrink when I download "not small" file until the Zero Window problem occurs.
By increasing TCP_WND up to 21900 my application (seems to) works fine with both http and https.

There are a couple of question in my mind I would like to understand:
1. is this analysis correct? Is that the root cause? Or the TCP/IP should be able to work also with small TCP Window?
2. How to size correctly the TCP_WND option?

Best regards,
Stefano

Stefano Oliveri <stf12>
Tue 23 Apr 2024 09:12:30 AM UTC, original submission:  

Hello,

I am working at a demo application running on STM32, and I am using:
- lwIP version STABLE-2.2.0
- Mbed TLS 2.28.7 branch released 2024-01-26

What I am trying to do is to download a couple of files from a server using https protocol. My demo works fine if I use http, but I have some issue when I switch to https. One is a small JSON file (few hundred bytes). The other file is a fw binary of ~500KB.

I am using the httpc implementation in lwip/apps/http and I followed the indication in the lwIP documentation to add the SSL/TLS with mbedTLS (https://www.nongnu.org/lwip/2_1_x/group__altcp__api.html). For the certificate I am using, for the moment, the test CA Certificates provided by MBed TLS.

This is the issue.

I can download with success the small JSON file:
  if (port == LWIP_IANA_PORT_HTTPS)
  {
    _this->connection_settings.altcp_allocator = &_this->tls_allocator;
  }
  else
  {
    _this->connection_settings.altcp_allocator = NULL;
  }

  /* start the http request for the JSON header */
  lwip_res = httpc_get_file_dns(p_host_name, port, p_request, &_this->connection_settings, tcp_recv_cb, _this, &_this->p_connection_state);

But, when I try to download the binary file, the operation fails with a server timeout (http_res == 5):
  if (port == LWIP_IANA_PORT_HTTPS)
  {
    _this->connection_settings.altcp_allocator = &_this->tls_allocator;
  }
  else
  {
    _this->connection_settings.altcp_allocator = NULL;
  }

  if (!SYS_IS_ERROR_CODE(res))
  {
    /* start the http request for the JSON header */
    lwip_res = httpc_get_file_dns(p_host_name, port, p_request, &_this->connection_settings, tcp_recv_cb, _this, &_this->p_connection_state);


A strange thing, for me, is that if I replace in the server the binary file with a small file (~6k) then the same code works fine.

I enabled some TCP log in lwIP to collect some information. Let me share this info and my lwIP and Mbed TLS configuration.

Any suggestion about a possible root cause or how to debug this issue? Do you think that it is an issue related to Mbed TLS, so I should not file this request here?

Best regards,
Stefano


Stefano Oliveri <stf12>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #55958:  bug_fota_https.zip added by stf12 (33KiB - application/x-zip-compressed - log and configurations files)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by stf12 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-04-23 stf12 Attached File- Added bug_fota_https.zip, #55958

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code