Skip to content

Read and customize TCP_WND, TCP_MSS #1392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
starlino opened this issue May 7, 2018 · 10 comments
Closed

Read and customize TCP_WND, TCP_MSS #1392

starlino opened this issue May 7, 2018 · 10 comments

Comments

@starlino
Copy link

starlino commented May 7, 2018

I am porting some code from ESP8266 to ESP32 core.
What is the proper way to read/change TCP_WND, TCP_MSS from the code ?
The constants TCP_WND, TCP_MSS no longer work on ESP32, but worked fine on ESP8266.
It would be nice if these can be brought back for compatibility.
Thank you.

@lbernstone
Copy link
Contributor

If you put lwip/opt.h in your sketch folder, you should be able to set the TCP_WND in that file.

@starlino
Copy link
Author

starlino commented May 8, 2018

@lbernstone sorry , but your solution does not work:

#include "lwip/opt.h"
#include <WiFi.h>
//static_assert(  536 == TCP_MSS   ,"536 != TCP_MSS ");
void setup() {
  printf("TCP_MSS:%u\n",TCP_MSS);
}
void loop() {
  
  
}

neither does this:


#define TCP_MSS 536
#include <WiFi.h>
//static_assert(  536 == TCP_MSS   ,"536 != TCP_MSS ");
void setup() {
  printf("TCP_MSS:%u\n",TCP_MSS);
}
void loop() {
  
  
}

outputs:

TCP_MSS:1436

The last once is interesting, how does WiFi.h manages to overwrite my #define TCP_MSS 536

Am I missing something here ?

@lbernstone
Copy link
Contributor

lbernstone commented May 8, 2018

Not include. Physically copy the opt.h into your sketch directory and modify it there. Arduino IDE will override the lwip/ include.

@starlino
Copy link
Author

starlino commented May 8, 2018

@lbernstone are you sure you don't mean lwipopts.h ? Because this code worked:

#include "lwipopts.h"
#include <WiFi.h>
static_assert( 536 == TCP_MSS ,"536 != TCP_MSS ");
void setup() {

printf("TCP_MSS:%u\n",TCP_MSS);

}
void loop() {

}

I put lwipopts.h in the same folder as sketch and modified TCP_MSS to 536
Without #include "lwipopts.h" it fails.

@lbernstone
Copy link
Contributor

If you have a solution, please close the issue.

@starlino
Copy link
Author

This is not 100% solved, can we hold this for couple of days so I can do more tests with Wireshark. I suspect even if I change TCP_MSS define, the real value is hard-coded in the pre-compiled lib, I have to figure out how to change TCP_WND as well.

On a related question - if I customized esp-idf , how do a make Arduino IDE to use my esp-idf and not the default supplied one ? (This way I can just use sdkconfig , to set all these settings) ?

@copercini
Copy link
Contributor

copercini commented May 14, 2018

You can use Arduino as IDF component and set these options on IDF make menuconfig

This will replace the pre-compiled libs by your IDF code/configs

@starlino
Copy link
Author

Is using Arduino as IDF the only way to do it ? What if I want to keep arduino IDE, is it possible ? A lot of contrubutors on my project would like to stay in Arduino IDE as well and not go to the trouble of configuring esp-idf, etc. Can I just supply them a customized / forked version of this repository ?
So... can I just recompile esp-idf with desired settings and copy SDK to the arduino tools directory ?
For instance ESP8266 has instructions how to update sdk:
https://github.com/esp8266/Arduino/blob/master/tools/sdk/lib/README.md
but I didn't find a similar readme file in:
https://github.com/espressif/arduino-esp32/tree/master/tools/sdk/lib
Can anyone shed some light on updating sdk for Arduino ESP32 ?
Are there any cleanup opperations required like for instance this script in esp8266:
https://github.com/esp8266/Arduino/blob/master/tools/sdk/lib/fix_sdk_libs.sh
It might be as trivial as copying files, but I know there are people here who know all the caveats (if any) so please share.
Thank you !

@copercini
Copy link
Contributor

copercini commented May 14, 2018

ok, got it =)

You can set up Arduino as IDF component just for you, then configure the TCP things on make menuconfig , doing a make build it will compile all the core with your configs and generate a file with the new TCP settings on project_name\build\lwip\liblwip.a get it and distribute in your github project.

To work on everyone's computer with the new settings, just tell the people to grab your version of liblwip.a and replace it here: https://github.com/espressif/arduino-esp32/tree/master/tools/sdk/lib in their Arduino installation

@lbernstone
Copy link
Contributor

I think I can do even better. It is not the headers you need to drop in to overrride, but the c files themselves. Download the esp-idf (https://github.com/espressif/esp-idf) and find the .c file(s) where those defines are used. Place THOSE in the sketch folder, and add defines to them for the values you want. I just tested this with sntp.c (which is much easier to see your changes), and got it to refresh every minute instead of every hour. Sorry for forgetting how that override works...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants