Long tcp write seems impossible? using open-sdk 1.5.2

jonshouse
Posts: 5
Joined: Mon Dec 08, 2014 12:10 am

Long tcp write seems impossible? using open-sdk 1.5.2

Postby jonshouse » Tue May 10, 2016 9:49 pm

I have spent over two days now trying to get a tcp socket to write a large chunk of data with zero success.

According to what passes documentation (LOL) "espconn_regist_write_finish()" will register a callback that will execute when the tcp chunk of data has been sent? I assume? However it does not seem to work at all ?

espconn_regist_sentcb(), the callback is unreliable, often not firing.

I've tried polling to see if I can send data with "espconn_get_packet_info" but that simply shows typical values like
"send_buf_size=2855, snd_queuelen=7" with no sign of either ever changing, I would expect to see them decrease.

It is really starting to piss me off, I don't see why this SDK/OS cant provide a simple cumulative write() for tcp like any other OS !

Anyhew, does anyone have a simple example of doing a long tcp write - hundreds of K/Bytes.

A tcp server that sends the same line of text a few hundred times would be great if anyone has such a thing?

Many thanks,
Jon

peter@steininc.net
Posts: 1
Joined: Sun Mar 06, 2016 1:48 am

Re: Long tcp write seems impossible? using open-sdk 1.5.2

Postby peter@steininc.net » Wed May 11, 2016 4:26 am

Hi Jon Have you tried breaking your writes into smaller chunks? I have found that the optimum max size for a tcp write is an ethernet frame size 1460 bytes. If you go above 1460 - on a ethernet network - the message gets chopped up anyway. I have used the AT ver 0.9.4 - the last open source one, modified it extensively and I am at last getting something that is usable. I have mine writing and reading to a linux box getting a through-put of about 30KBytes a second. Last test I did ran for about 8 hours with it breaking... Interesting thing I have found is that if you randomise you send size (between about 500 and 1400 bytes per frame) you get a better throughput. Another thing I have found is that the actual position (XYZ orientation) of the ariels on the wifi access point - and on the module ( i am assuming you running in station mode) can make a big difference. Also don't mess around - include in your soure:

Code: Select all

/*
 * user_rf_pre_init
 */
void user_rf_pre_init(void)
{
   system_phy_set_powerup_option(3);
   system_phy_set_max_tpw(82);
}

The power up funcs calibrates the RF black box stuff and set it to max power. Hope this helps.

mikexmas
Posts: 1
Joined: Wed May 11, 2016 2:45 pm

Re: Long tcp write seems impossible? using open-sdk 1.5.2

Postby mikexmas » Wed May 11, 2016 2:47 pm

Consider using chunked mode, to split data, introduced in HTTP1.1:
https://en.wikipedia.org/wiki/Chunked_transfer_encoding

jonshouse
Posts: 5
Joined: Mon Dec 08, 2014 12:10 am

Re: Long tcp write seems impossible? using open-sdk 1.5.2

Postby jonshouse » Wed May 11, 2016 6:59 pm

Thanks for the reply.

Hi Jon Have you tried breaking your writes into smaller chunks?

Currently I am writing 256 byte chunks.

Looks like my code must be broken as the test worked.

I will publish my full application when finished, in the meantime I wrote a tcp test to clarify what is going on.
I found a good tcp example and modified it, original is here:
http://cholla.mmto.org/esp8266/OLD/sdk/tcp_server.c

My simple tcp test here, it is a telnet server that just sends lines back :
http://www.jonshouse.co.uk/download/tcp_test_v_0.1.tar

All noted on the RF API, I will have a look at that later.

Thanks,
Jon

PS

Who is online

Users browsing this forum: No registered users and 1 guest