Hi,
I am using HTTP server based on Keil TCP/IP stack. It is very slow downloading my CSS, JS and HTML files.
I can see in Wireshark logs Keil stack is causing Retransmission of TCP packets that is why it is slow download files. some files are taking 3 seconds to download.
As compare Apache server. It very fast download only takes few milliseconds for same set of files.
Can we ask browser to cache some of the files.
Thanks, Naeem
My files are 10k to about 50k. It will be transmit by Ethernet buffer which is max=1400 bytes into multiple packets similar to Apache server. I am trying to find why retransmission happens. I will enable the debugging feature to see more debug logs.
Of course you data needs to be split based on allowed packet sizes (MTU). But it's important how many packets that can be in flight waiting for acknowledge. If the stack has no buffers for receiving one more packet it must throw away incoming data. And with too few buffers it can't send out all required 1400-byte packets for the full files and instead need to stall the send until an acknowledge is received.
I saw similar retransmission when I do multiple ajax calls without waiting for ajax call to finish.
I can guess browser is requesting multiple Get HTTP request simultaneous to fetch files.
I guess Keil TCP/IP Stack is not optimized to handle these situations as Apache have.
Any idea about lwIP stack comparison. Can we use lwIP stack with Keil RTOS.
I enabled Debug for Keil TCP. It is not starting and not coming into main function. I guess it requires more heap memory.
You understand that a small micro-controller isn't going to have anywhere near the resources, memory or horse-power of a 2 GHz Intel Linux box running Apache, right?
Exactly - it's all about memory. The Apache runs on top of a TCP/IP stack that can handle a very large windows size, i.e. number if outstanding packets. That hides the ping time and makes the experience feel responsive and at the same time gives a very high bandwidth.
With few buffers, the transfers will become more or less stop-and-go transfers. Memory really matters when networking.
You took the words right out of my mouth.
I can't remember how many times I've told clients that.
I have only 128k RAM. If I enable TCP/IP Debug. then my embedded device stops working.
I guess I need more RAM in order to get performance and avoid triggering TCP retransmission.
One thing worth checking in TCPnet is the size of the buffer in the Ethernet driver. We had a problem show up with bad/slow/retransmission when on a busy network carrying lots of broadcast traffic. The simple answer to the cause was that the buffer in this driver was filling up before the stack had a chance to remove any items.
Two changes we made:
1) Increase the receive buffer allocation in the Ethernet driver 2) Increase the rate at which the stack does its processing
Worked very well for us.
If only political parties were so easy to control :(
How can I set these to settings.
Tell me extract #define name and within which config header file?
1) Look at the Ethernet driver that you're using for the board 2) Look at the TCPnet configuration and the timing values
After changes values in Net_TCP_config and increase TCP and http session numbers. It is good performance. however now we have embedded flash file system. We enabled FTP server and upload all web files on flash. I deleted all files from internal ROM and stop using FCARM.
Now when browser request HTTP get files e.g index.html and index.html includes some css and js files. It is very slow and browser failed to download all files and web pages is not rendered fully.
Any idea why?
I guess I need to try using FAT File system to have decent performance with multiple files open.
I found out Keil Embedded File system does not support opening more than 2 files at the same file.
I have unit test to prove it now.
Is this limitation with Embedded File system?
We have more than 2 HTTP sessions. these HTTP session trying to open more than 2 files simultaneous using fopen. then browser HTTP Get request fails for some files.
I try setting File : File_config.c Embedded File System Number of Files > 3
If I try opening more than 3 files at same time. fopen hangs.
I am using External NOR Flash memory with SPI driver.
If I have only 2 HTTP sessions and Number of Files =2 then it works but browser load very slowly first time if no cache for any files.
I have few html, JS and css files.
Have Keil test their HTTP server with Embedded File System or we need to use SD card with FAT File system.
We found issue and solve it.
fopen was acquiring mutex. If It already have more than OS_MUTEXTCNT. It loop forever ( Keil better improve this code and put debug logging for any error instead of hanging thread and loop forever)
Keil functions/API are thread-safe. We had OS_MUTEXTCNT=8 in out config for RTOS. Now we put it to 26. Other settings We have HTTP session =10 and Number of files opened=16
fopen can open multiples files at the same time max to 16 now.
We better have ARM provide us source for Keil RTOS and MDK. It will easier for us to debug and give you feedback. We can give feedback to improve your code base.
I am not sure we need thread-safe version of all functions. for example in our case, we are opening files from same thread, so we do not need mutex. Is there way to use Keil non-thread function to speed up performance more.
We better have ARM provide us source for Keil RTOS and MDK
Source for the RTX is already supplied. From what your describing, you probably mean you expect the source to the flash file system. If you were to think about it you should realize that source for MDK is not a particularly sensible item to ask for. The MDK is the name of the whole package (IDE, compilers, linkers etc).
If you expect someone to supply something, the first sensible step is to know and specify exactly what you really want.
Hi Peter,
Thanks for clarification.
Sorry for not very clear in term of asking source code. Yes I meant source code for RTX RTOS and their components such as network and file system.
For example, I did try to step into fopen C function, however I could not.