Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By Kelrob
#57663 Hi guys,

The attachment of this post contains sample code for simple TCP/IP performance testing.

(1) The web server project
Idea behind is to create a simplistic web server on the ESP8266, working with external AP or by creating an own AP, and any browser on PC or smartphone can connect to it to download a file. The file is simulated by static RAM content, the speed measurement is done on the module itself and presented on both serial console and the web page itself.

(2) The web client project
Idea behind is to create a simplistic web client on the ESP8266 which connect to an external AP downloading a file from an internet source. In this case the ESP consumes the data so it's just the opposite to the web server implementation. Negative aspect is that the speed measurement is affected by internet infrastructure, positive aspect is that the same source code can be used for ESP32 as well (as currently no WifiServer class is implemented there).

Observations:
(1) The web server implementation delivers up to 10MBit/s as I used the trick to send 2920 bytes (2x max. MTU size) packets to force the client to acknowledge them as fast as possible without waiting for more data. The ESP8266 seems to wait for an ACK for any send request so TCP/IP speed depends heavily on ACK delay of the client. E.g. my Win7 computer reaches up to 10MBit/s with IE,Firefox and Chrome while my Samsung smartphone is limited to 6.0 MBit/s, and they both can perform faster on file downloads.
Are there other tricks to go faster? Can the ESP be told to use a larger TCP/IP window size to send out even more data before they have to be acknowledged, to get independent from ACK latency?

(2) The web client implementation delivers roughly 1.5MBit/s, tested here in the company where the internet connection is not the limiting factor (at home I got 0.8MBit/s, the slow DSL connection may be blamed for). This speed was quite constant for all packet sizes tested from 32 bytes up to 5840 bytes in each client.read() call. The speed was also not affected by changing the receive timeout between 10 and 1000ms, and not by the NoDelay setting.
Why is it far slower than the server implementation above? Are there options I missed to speed it up?
I'm curios about it as my ESP32 module running the same code is limited to 0.053MBit/s which was modem speed 20 years ago (ok, maybe off-topic as still under development, but maybe it is affected by the same wrong setting I missed?).

Please share your thoughts and tips,
thanks in advance,
Kelrob
You do not have the required permissions to view the files attached to this post.
User avatar
By mindthomas
#65649 Thanks for this example snippet.
Did you ever continue the work and investigation why the client rate is so slow?
Imagine that you want to upload a file to the ESP8266 for it to use/process, then this upload will be limited by this rather slow client rate of only 1.5 Mbit/s.

Why can we get 10 Mbit/s only one way?