I wrote a (very) simple web server that sends files from a file systhem depending on request.
Of course there ara myny pictures and they are transfered slowly. E.g. a jpg-file of 50KBytes woul be send in 3-4 seconds, that is too slow on my opinion.
After my research I found that sending on WIFI network of 1460 bytes requires about 200ms (!). Time from calling localSocket:send(cont_type, web_sendfile_cnf) to call of the send confirmation function web_sendfile_cnf.
1460 I took because it is nearly to maximum length of the Ethernet paket size (+ IP overhead). The code to send the data and my measurement points are below:
--function sends file content to web
function web_sendfile(localSocket, filename)
local bytes_send = 0
local t1 = 0
local t2 = 0
-- callback function confirms data sending
local function web_sendfile_cnf(loc_socket)
-->> get second test timestamp in microseconds and print the test difference
t2 = tmr.now()
print( t2 - t1 ) -- over 200 000 microseconds ???
-- file exists?
if nil==file.open(filename,"r") then
-- go to next position in the file to read
-- read part of data and close the file
local fd = file.read(1460)
if nil~=fd then
--increment number of send bytes and send data
-- nothing to send, close socket
-- free memory
end-- of callback function
-->> get first test timestamp in microseconds
t1 = tmr.now()
-- send the http header
It is no dependency on connection mode (client or access point), that time is always about 200ms.
I hope this community includes expirienced users that could help me to fins solution for this problem.
Thanks in advance for helping!