The use of the ESP8266 in the world of IoT

User avatar
By tve
#10196 After a wild goose chase, I'm coming down to the problem that I can't get more than 2-3 packets/sec or 2.8-4.2KB/s out of the ESP8266 via TCP. The bandwidth is of concern, but the latency even more for me. Basically, I can't send a packet more frequently than every ~350ms-400ms. I wrote a simple test program that accepts TCP connections and sends a small buffer containing "HELLO\n" in the sent-callback handler, i.e. as fast as allowed in the SDK 0.9.5. Here's what it looks like:
Code: Select all$ true | nc -q 3 esp8266 23
HELLO
HELLO
HELLO
HELLO
HELLO
HELLO
HELLO
HELLO
$

So this ran for 3 seconds (-q 3) and resulted in a whopping 8 packets received. Looking at tcpdump, here's a typical round-trip:
Code: Select all00:00:00.363428 IP 192.168.0.29.23 > 192.168.0.3.34623: Flags [P.], seq 7:13, ack 1, win 5840, length 6
        0x0000:  4500 002e 0155 0000 ff06 3904 c0a8 001d  E....U....9.....
        0x0010:  c0a8 0003 0017 873f 0000 5f76 dafd 3fd9  .......?.._v..?.
        0x0020:  5018 16d0 3246 0000 4845 4c4c 4f0a       P...2F..HELLO.
00:00:00.000027 IP 192.168.0.3.34623 > 192.168.0.29.23: Flags [.], ack 13, win 29200, length 0
00:00:00.355630 IP 192.168.0.29.23 > 192.168.0.3.34623: Flags [P.], seq 13:19, ack 1, win 5840, length 6
        0x0000:  4500 002e 0156 0000 ff06 3903 c0a8 001d  E....V....9.....
        0x0010:  c0a8 0003 0017 873f 0000 5f7c dafd 3fd9  .......?.._|..?.
        0x0020:  5018 16d0 3240 0000 4845 4c4c 4f0a       P...2@..HELLO.

The timestamps are packet inter-arrival times, e.g., it took 355ms from the ACK sent by my laptop 'til the next "HELLO" data packet. So my laptop responds in microseconds with the ACK and the ESP takes its sweet time.

Maybe my Wifi is borked? Well, the initial syn-ack came back from the ESP in ~100ms and I routinely see ACKs from the ESP in 30ms when my laptop sends data to the ESP.

If I run two connections like the above at the same time I get no more packets per second, each connection runs at half the speed of the above.

Is anyone else seeing this? Are there any work-arounds?

I put my code into a github repo: https://github.com/jeelabs/ESP8266-bandwidth, the main app being https://github.com/jeelabs/ESP8266-band ... ser_main.c
User avatar
By moodgorning
#12383 I ran into the same problem, but managed to speed things u significantly by setting the esp8266 to a higher baud rate.
Send it AT+CIOBAUD=115200 to set the baud rate. with this I managed to send 15 "hello" packets per second to the esp8266