No more than 2-3 packets/sec from the ESP8266?

doughboy
Posts: 63
Joined: Thu Mar 05, 2015 1:54 am

Re: No more than 2-3 packets/sec from the ESP8266?

Postby doughboy » Wed Mar 18, 2015 1:16 pm

ok, I optimized my arduino code to buffer send data 256 bytes at a time.
and for the above example that sends 280 bytes of data that for split into 52 CIPSENDs that used to take 10 seconds, now use 1 CIPSEND and time is less than 1ms. So I don't think there is a hardcoded 200ms delay for each cipsend, but something in the lower level code is adding delay for consecutive cipsend with small number of bytes.

jayc75
Posts: 23
Joined: Sun Feb 15, 2015 6:44 pm

Re: No more than 2-3 packets/sec from the ESP8266?

Postby jayc75 » Wed Mar 18, 2015 6:27 pm

the delay added by the lower level code is 20ms it is documented !

doughboy
Posts: 63
Joined: Thu Mar 05, 2015 1:54 am

Re: No more than 2-3 packets/sec from the ESP8266?

Postby doughboy » Thu Mar 19, 2015 12:25 am

jayc75 wrote:the delay added by the lower level code is 20ms it is documented !

ok, I see it in documentation, But that is for CIPMUX=0 mode and for pure client mode only.

On my use, I have a tcp server that accepts connections, once a connection is received, the client is created, and that operates in CIPMUX=1 mode, hence the 20ms delay does not apply.

but yes I do agree there should be no delay added, not even 1ms.

fwiw, if delay is 20ms, then you should be able to get closer to 50 packets per second.
before I did my optimization, I was getting about 5 packets per second, so the delay I experience is more like 200ms.
what kind of delay are you experiencing on CIPMUX=0 mode? exactly 20ms?

Her Majesty
Posts: 186
Joined: Mon Oct 27, 2014 11:09 am

Re: No more than 2-3 packets/sec from the ESP8266?

Postby Her Majesty » Thu Mar 19, 2015 11:30 am

:roll:

the transmission speed depends on TCP ACK ,which usually be 200ms to get one if you send a packet.. but if you send two packets every each time,it will response TCP ACK immediately..

Anyway, I tested it in WLAN.. not bad ..
Attachments
speed-test.png
speed-test.png (74.02 KiB) Viewed 3888 times

doughboy
Posts: 63
Joined: Thu Mar 05, 2015 1:54 am

Re: No more than 2-3 packets/sec from the ESP8266?

Postby doughboy » Fri Mar 20, 2015 5:33 am

there should be no delay if esp8266 is not using nagle algorithm right?

I don't think it is a question of sending one packet or two packet each time. At the application level, it is sending the packet consecutively, immediately one after another.
But it seems esp8266 waits for the ACK after each send, and hence it is esp8266 that is not sending the packets immediately because it waits for ack causing the delay.

ESP_Faye
Posts: 1623
Joined: Mon Oct 27, 2014 11:08 am

Re: No more than 2-3 packets/sec from the ESP8266?

Postby ESP_Faye » Fri Mar 20, 2015 10:12 am

Hi,

Thanks for your interest in ESP8266 !

ESP8266 RAM is limited, so we only have 2*2920 bytes send buffer for each TCP connection. TCP can't send further data if send buffer is full. After recv ACK, send buffer will free ACKed data, then application can send further data.

That's why we need to wait for TCP ACK, because our buffer is limited.

And yes, TCP ACK usually got in 200ms, but if you send two packets each time, TCP ACK will response immediately, then application can send further data immediately, too.

tve
Posts: 123
Joined: Sun Feb 15, 2015 4:33 pm

Re: No more than 2-3 packets/sec from the ESP8266?

Postby tve » Tue Mar 31, 2015 2:23 pm

I'm sorry, but waiting for the TCP ACK does not explain why the esp8266 is so slow. I just recompiled my test (which is still freely available at https://github.com/jeelabs/ESP8266-bandwidth) with the 1.0 SDK and despite my server sending an ACK immediately (it gets enqueued in microseconds) the esp8266 can't send any faster than one packet every ~200ms. Look at the tcpdump snippet in the first post of this thread!

What do you mean by "if you send two packets each time"? The documentation for espconn_sent clearly states that one is not allowed to send a second packet until one receives the sent_callback. All my code does is send out "Hello" as fast as it's allowed, here's my callback handler:

Code: Select all

static void ICACHE_FLASH_ATTR serverSentCb(void *arg) {
  sendpacket(arg);
}

where sendpacket bascillay just does

Code: Select all

sint8 result = espconn_sent(conn, "HEllO\n", 6);


The whole program is just 78 lines. You claim that the esp8266 can do better, please try it yourself and tell us what you see (perhaps with some tcpdumps) or change the program to do better!

tve
Posts: 123
Joined: Sun Feb 15, 2015 4:33 pm

Re: No more than 2-3 packets/sec from the ESP8266?

Postby tve » Tue Mar 31, 2015 2:31 pm

Actually the *proof* that the problem has nothing to do with TCP ACKs is very simple. Run two "nc esp8266 23" connections at the same time. The acks for these two connections are completely independent. The buffers are also independent. Thus the two connections should not influence one-another and the esp8266 should send packets at twice the rate as with one connection. However, observation shows the opposite: the number of packets sent by the esp8266 remains the same, each connection goes at half the speed. This would not be the case if the ACK round-trip delay was the issue! You have a bug!

Her Majesty
Posts: 186
Joined: Mon Oct 27, 2014 11:09 am

Re: No more than 2-3 packets/sec from the ESP8266?

Postby Her Majesty » Tue Mar 31, 2015 3:54 pm

:lol:

Here is my test bin I'd like to share.. Simple test to get 1Mbps tx speed, er.. maybe depend on network condition..

download test bin to flash and input as below through UART, baudrate 74880 which is original ..I didn't change it...
step 1. input "op -S -o 1" from UART to set as station mode
step 2. input "ap -C -s ROUTER_SSID -p ROUTER_PASSWORD" to connect to your router
step 3. create a TCP server in your PC
step 4. input "tcp -W -i TCP_SERVER_IP -p TCP_SERVER_PORT -n 1 -c 500 -l 2920" to create a TCP connection and send data.. see the receive speed of PC TCP server.

My test result as the picture
speed-test.png
speed-test.png (74.02 KiB) Viewed 3815 times
Attachments
bin_test_tx.zip
(167.89 KiB) Downloaded 123 times

tve
Posts: 123
Joined: Sun Feb 15, 2015 4:33 pm

Re: No more than 2-3 packets/sec from the ESP8266?

Postby tve » Tue Mar 31, 2015 11:37 pm

Thanks, that's interesting. I suppose 1Mbps / 8bits/byte / 1420 packet length = 88 packets/sec. Can you show the source code for your app or at least for the section that does the sending?

Who is online

Users browsing this forum: Google [Bot] and 7 guests