DEV Community

zhuyue
zhuyue

Posted on

How is the TCP transmission speed for ESP8266 based programmable controller

After a series of adjustment and optimizations, the TCP communication of a simple programmable controller based on ESP8266 reaches a very good speed, including:
1) Adjusting the priority of the main task and the LWIP task
2) State machine optimization for data processing of the main task
3) Solving the fast communication crash problem by increasing the kernel lock of LWIP
4) Using signal trigger to achieve 10ms tick scheduling for the main task, while providing an interface for LWIP to actively wake up
...
The web page file is about 90kByte in total, and pc tool transfers the binary to ascii data, doubling the amount of data to 180kByte;
The pc tool will write the data, and then read out the same comparison, so the effective data transferred in both directions is 360kByte, plus 0.6 times the HTTP header data, a total of 576kByte of data transferred in both directions.

The whole download process erases flash once, which takes 54.6ms, writes flash 354 times, which takes 4.0ms each time, and reads flash 354 times, which takes 0.5ms each time;
The total elapsed time for flash operation is 1.6s;

The elapsed time for complete download is 7.7s, deducting the flash operation time of 1.6s, the transmission elapsed time is 6.1s;

According to this calculation, the transmission speed of TCP can reach 755kb/s;
There are still optimization problems.
The response of TCP is sent in two packages, which can be optimized to be sent in a single package;

And if you comment out the code that wakes up the main task after LWIP receives the data.
xSemaphoreGive(xBinarySemaphore).
Two full downloads were tested, taking 9360ms and 9371ms respectively;

if with the code, also tested twice, taking 7762ms and 7821ms respectively;

How is the performance for such speed?
A special ESP8266 module is sold in Taobao online shop and has a quite good selling quantity, it claimed to achieve high-speed communication with up to 800kb and suitable to transmit real-time audio signals;
I think with these optimizations, current simple controllers can also reach this level.

Image description

Image description

Top comments (0)