TCP Slow, then disconnects, UDP Slow

petermccloud
Posts: 4
Joined: Wed Nov 22, 2017 8:24 pm

TCP Slow, then disconnects, UDP Slow

Postby petermccloud » Fri Nov 24, 2017 7:09 am

I am experiencing very slow TCP and UDP speeds between 2 Sparkfun ESP32 Thing boards. In addition the the TCP being slow, it disconnects very quickly.

The first test was using the iperf example under master https://github.com/espressif/esp-idf/tree/master/examples/wifi/iperf
Compiled with master/commit 597ce3b800cc4857e1939bbb937610a9e30c6e72

Testing with TCP, the output shows an initial slow connection then the speed goes to zero

Code: Select all

I (52003) iperf: mode=tcp-client sip=192.168.4.2:5001, dip=192.168.4.1:5001, interval=3, time=30
esp32> 
        Interval Bandwidth
   0-   3 sec       0.35 Mbits/sec
   3-   6 sec       0.00 Mbits/sec
   6-   9 sec       0.00 Mbits/sec
   9-  12 sec       0.00 Mbits/sec
  12-  15 sec       0.00 Mbits/sec
  15-  18 sec       0.00 Mbits/sec
  18-  21 sec       0.00 Mbits/sec
  21-  24 sec       0.00 Mbits/sec
  24-  27 sec       0.00 Mbits/sec
  27-  30 sec       0.00 Mbits/sec
   0-  30 sec       0.03 Mbits/sec
I (82027) iperf: iperf exit


Testing with UDP is just slow (according to https://github.com/espressif/esp-idf/issues/322, is should be 130. I get ~1.4.

Code: Select all

I (429604) iperf: mode=udp-client sip=192.168.4.2:5001, dip=192.168.4.1:5001, interval=3, time=30
esp32>
        Interval Bandwidth
   0-   3 sec       1.54 Mbits/sec
   3-   6 sec       1.31 Mbits/sec
   6-   9 sec       1.45 Mbits/sec
   9-  12 sec       1.31 Mbits/sec
  12-  15 sec       1.48 Mbits/sec
  15-  18 sec       1.34 Mbits/sec
  18-  21 sec       1.44 Mbits/sec
  21-  24 sec       1.33 Mbits/sec
  24-  27 sec       1.44 Mbits/sec
  27-  30 sec       1.33 Mbits/sec
   0-  30 sec       1.40 Mbits/sec
I (459633) iperf: iperf exit


I also did further tests using the performance examples: https://github.com/espressif/esp-idf/tree/master/examples/performance
and got similar results.
TCP

Code: Select all

TCP
I (29568) tcp_perf:: connecting to server...
I (29608) tcp_perf:: connect to server success!
I (32608) tcp_perf:: tcp recv 3829 byte per sec!
W (35608) tcp_perf:: tcp disconnected... stop.


UDP

Code: Select all

I (50131) udp_perf:: udp send 88573 byte per sec! total pack: 182
...
I (173131) udp_perf:: udp send 89546 byte per sec! total pack: 7623


I also did testing using the latest release v2.1.1. Since iperf is not part of v2.1.1, I didn't run it, but I did run the TCP and UDP examples and got similar results.

TCP

Code: Select all

I (11688) tcp_perf:: sta has connected to ap.
I (11698) tcp_perf:: tcp_server will start after 3s...
I (14708) tcp_perf:: create_tcp_server.
I (14708) tcp_perf:: server socket....port=4567

I (32418) tcp_perf:: tcp connection established!
I (32518) tcp_perf:: start sending...
I (35418) tcp_perf:: tcp send 5840 byte per sec!
W (38418) tcp_perf:: tcp disconnected... stop.


I've been researching and battling these slow issues for a few days now and I'm out of options. I'm starting to wonder if I got some bad hardware. I have 5 boards and all of them show the same behavior. Any ideas would be appreciated.

WiFive
Posts: 1206
Joined: Tue Dec 01, 2015 7:35 am

Re: TCP Slow, then disconnects, UDP Slow

Postby WiFive » Fri Nov 24, 2017 7:29 am

Try 3.0-dev version i think there are some phy fixes for 26mhz crystal that sparkfun uses

petermccloud
Posts: 4
Joined: Wed Nov 22, 2017 8:24 pm

Re: TCP Slow, then disconnects, UDP Slow

Postby petermccloud » Fri Nov 24, 2017 6:02 pm

WiFive wrote:Try 3.0-dev version i think there are some phy fixes for 26mhz crystal that sparkfun uses


Thanks for the suggestion WiFive! I tried out 3.0-dev. It initially gave me the same output. However, your comment led me to look at the XTAL freq in closer detail. I had been setting XTAL freq to Auto. I tried setting it to 26MHz directly and got a different result.

XTAL set to Autoconfig

Code: Select all

I (28019) tcp_perf:: sta has connected to ap.
I (28029) tcp_perf:: tcp_server will start after 3s...
I (31029) tcp_perf:: create_tcp_server.
I (31029) tcp_perf:: server socket....port=4567

I (48739) tcp_perf:: tcp connection established!
I (48849) tcp_perf:: start sending...
I (51749) tcp_perf:: tcp send 4866 byte per sec!
W (54749) tcp_perf:: tcp disconnected... stop.


XTAL set to 26MHZ

Code: Select all

I (88180) tcp_perf:: tcp connection established!
I (88280) tcp_perf:: start sending...
I (91180) tcp_perf:: tcp send 46233 byte per sec!
I (94180) tcp_perf:: tcp send 53533 byte per sec!
I (97180) tcp_perf:: tcp send 54020 byte per sec!
I (100180) tcp_perf:: tcp send 49640 byte per sec!
I (103180) tcp_perf:: tcp send 50613 byte per sec!
I (106180) tcp_perf:: tcp send 51586 byte per sec!


The speed was about 10x faster and the tcp connection doesn't drop. I went back to master and set XTAL to 26MHz. It doesn't disconnect the TCP connection, but the speeds are intermittent....

master branch, XTAL set to 26MHZ

Code: Select all

I (8207) tcp_perf:: sta has connected to ap.
I (8207) tcp_perf:: tcp_server will start after 3s...
I (11217) tcp_perf:: create_tcp_server.
I (11217) tcp_perf:: server socket....port=4567

I (28987) tcp_perf:: tcp connection established!
I (29087) tcp_perf:: start sending...
I (31987) tcp_perf:: tcp send 46720.00 byte per sec!
I (34987) tcp_perf:: tcp send 0.00 byte per sec!
I (37987) tcp_perf:: tcp send 0.00 byte per sec!
I (40987) tcp_perf:: tcp send 0.00 byte per sec!
I (43987) tcp_perf:: tcp send 0.00 byte per sec!
I (46987) tcp_perf:: tcp send 19466.67 byte per sec!
I (49987) tcp_perf:: tcp send 7786.67 byte per sec!
I (52987) tcp_perf:: tcp send 0.00 byte per sec!
I (55987) tcp_perf:: tcp send 0.00 byte per sec!
I (58987) tcp_perf:: tcp send 0.00 byte per sec!
I (61987) tcp_perf:: tcp send 3893.33 byte per sec!
I (64987) tcp_perf:: tcp send 0.00 byte per sec!


I'm going to do some more testing with iperf with XTAL set to 26 MHz and see if I get different results.

WiFive
Posts: 1206
Joined: Tue Dec 01, 2015 7:35 am

Re: TCP Slow, then disconnects, UDP Slow

Postby WiFive » Sat Nov 25, 2017 2:32 am

Did you try a make erase_flash before switching to 3.0?

petermccloud
Posts: 4
Joined: Wed Nov 22, 2017 8:24 pm

Re: TCP Slow, then disconnects, UDP Slow

Postby petermccloud » Sat Nov 25, 2017 3:36 am

WiFive wrote:Did you try a make erase_flash before switching to 3.0?


Yes. To help isolate the issue, I've been doing a make erase_flash before every time I switch IDF and toolchains to help make sure I've got a clean firmware. For some reason, it looks like my earlier test with v3.0-dev and XTAL set to 26MHz was a fluke. After testing on the master I switched back to v3.0-dev with XTAL set to 26MHz and the same behavior is occurring again. I've tried a few more flashes and the occasional erase_flash and I'm not able to reproduce the results.

WiFive
Posts: 1206
Joined: Tue Dec 01, 2015 7:35 am

Re: TCP Slow, then disconnects, UDP Slow

Postby WiFive » Sat Nov 25, 2017 3:50 am

Sorry master branch should be the better version, I didn't realize 3.0-dev tag was so out of date

Who is online

Users browsing this forum: pratik.yadav.455 and 7 guests