PicoTCP robustness Test
Dependencies: PicoTCP lpc1768-picotcp-eth mbed-rtos mbed
Revision 5:16d6db68e32f, committed 2014-04-09
- Comitter:
- tass
- Date:
- Wed Apr 09 13:50:55 2014 +0000
- Parent:
- 4:0406e4e7639f
- Commit message:
- Robustness test now continues on multiple read time-outs in staid of hanging forever. A more resent and robust PicoTCP version is used.
Changed in this revision
diff -r 0406e4e7639f -r 16d6db68e32f PicoTCP.lib --- a/PicoTCP.lib Mon Feb 10 08:38:15 2014 +0000 +++ b/PicoTCP.lib Wed Apr 09 13:50:55 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/daniele/code/PicoTCP/#0a7a449980e6 +http://mbed.org/users/daniele/code/PicoTCP/#551effcf6a39
diff -r 0406e4e7639f -r 16d6db68e32f main.cpp --- a/main.cpp Mon Feb 10 08:38:15 2014 +0000 +++ b/main.cpp Wed Apr 09 13:50:55 2014 +0000 @@ -1,3 +1,7 @@ +/* +* This is an endurance test that downloads text, an image and a pdf file from the web in a loop using PicoTCP +* Debug output is printed to the USB serial port (what it is doing and memory stats) +*/ #include "mbed.h" #include <stdarg.h> #include "EthernetInterface.h" @@ -6,22 +10,21 @@ //#define msgdbg printf - -#define SENDING_RETRIES 3u -#define READING_RETRIES 7u -#define DHCP_RETRIES 10u +#define SENDING_RETRIES 3 +#define READING_RETRIES 10 +#define DHCP_RETRIES 10 #define BUFFER_SIZE 256 -#define NUMBER_OF_HOSTS 3u +#define NUMBER_OF_HOSTS 3 -#define MBED_HOST "www.mbed.org" -#define MBED_HOST_REQUEST "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n" +#define HOST_1 "www.mbed.org" +#define HOST_1_REQUEST "GET /media/uploads/mbed_official/hello.txt HTTP/1.0\n\n" -#define MEDIAFAX_HOST "www.mediafax.ro" -#define MEDIAFAX_HOST_REQUEST "GET / HTTP/1.1\nHost: www.mediafax.ro\n\n" +#define HOST_2 "www.mbed.org" +#define HOST_2_REQUEST "GET /media/img/boardlogos/lpc1768/pinout.png\nHost: www.mbed.org\n\n" -#define NXP_HOST "www.nxp.com" -#define NXP_HOST_REQUEST "GET /documents/user_manual/UM10360.pdf HTTP/1.0\nHost: www.nxp.com\n\n" +#define HOST_3 "www.nxp.com" +#define HOST_3_REQUEST "GET /documents/user_manual/UM10360.pdf HTTP/1.0\nHost: www.nxp.com\n\n" int totalTime = 0; @@ -29,29 +32,29 @@ { char request[70]; char host[20]; - int avgDuration; + int sumDuration; int maxReceived; int minReceived; int snapshots; }; -struct WebStats webStatistics[NUMBER_OF_HOSTS]= +struct WebStats webStatistics[NUMBER_OF_HOSTS]= { - {MBED_HOST_REQUEST,MBED_HOST,0,0,0x7FFFFFFF,0}, - {MEDIAFAX_HOST_REQUEST,MEDIAFAX_HOST,0,0,0x7FFFFFFF,0}, - {NXP_HOST_REQUEST,NXP_HOST,0,0,0x7FFFFFFF,0} + {HOST_1_REQUEST,HOST_1,0,0,0x7FFFFFFF,0}, + {HOST_2_REQUEST,HOST_2,0,0,0x7FFFFFFF,0}, + {HOST_3_REQUEST,HOST_3,0,0,0x7FFFFFFF,0} }; void inline printMemoryStats(void); void printStatistics(void) { - printf("\nTotal Time : %f seconds\n",(float)totalTime/1000.0f); + printf("\nTotal Time : %f seconds\n",(float)totalTime/1000.0f); for(int i=0;i<NUMBER_OF_HOSTS;i++) { printf("Host number : %d | %s\n",i, webStatistics[i].host); - printf("MaxRecv : %d\n",webStatistics[i].maxReceived); - printf("MinRecv : %d\n",webStatistics[i].minReceived); - printf("Avg duration : %d ms\n",webStatistics[i].avgDuration); + printf("MaxRecv : %d\n", webStatistics[i].maxReceived); + printf("MinRecv : %d\n", webStatistics[i].minReceived); + printf("Avg duration : %d ms\n", webStatistics[i].sumDuration / webStatistics[i].snapshots); printf("Total snapshots : %d\n\n",webStatistics[i].snapshots); } printMemoryStats(); @@ -74,7 +77,7 @@ struct MemoryUsage * memStat = (struct MemoryUsage *)pvHeapInfo; static const char* freeRamFormat = "%d bytes in"; va_list valist; - + if(memcmp(pFormatString,freeRamFormat,strlen(freeRamFormat)) == 0) { va_start(valist, pFormatString); @@ -82,11 +85,12 @@ memStat->curFreeRam = freeSize; if(memStat->minFreeRam > freeSize) memStat->minFreeRam = freeSize; - + if(memStat->maxFreeRam < freeSize) memStat->maxFreeRam = freeSize; - - memStat->avgFreeRam = ((memStat->avgFreeRam * memStat->cntSamples) + freeSize)/(++memStat->cntSamples); + + memStat->avgFreeRam = ((memStat->avgFreeRam * memStat->cntSamples) + freeSize)/(memStat->cntSamples + 1); + memStat->cntSamples++; } else { @@ -101,11 +105,11 @@ printf("\n\n***** Initial Memory Report *****\n"); else printf("\n\n********* Memory Report *********\n"); - - printf("Current free memory : %d bytes\n",memoryStats.curFreeRam); - printf("Maximum free memory : %d bytes\n",memoryStats.maxFreeRam); - printf("Minimum free memory : %d bytes\n",memoryStats.minFreeRam); - printf("Average free memory : %d bytes\n",memoryStats.avgFreeRam); + + printf("Current free memory : %d bytes\n", (int)memoryStats.curFreeRam); + printf("Maximum free memory : %d bytes\n", (int)memoryStats.maxFreeRam); + printf("Minimum free memory : %d bytes\n", (int)memoryStats.minFreeRam); + printf("Average free memory : %d bytes\n", (int)memoryStats.avgFreeRam); printf("****************************\n"); } @@ -114,13 +118,12 @@ __heapstats((__heapprt)fakePrintf, &memoryStats); } +int main() { -int main() { - int retries = 0; EthernetInterface eth; TCPSocketConnection client; - + printf("Initialising...\n"); // use DHCP @@ -136,11 +139,12 @@ goto failure; } }; - + printf("[%llu] Starting the robustness test...\n",PICO_TIME_MS()); - - while(1) + + while(1) { + printf("Starting cycle ****************************************\n"); for(int i=0;i<NUMBER_OF_HOSTS;i++,client.close()) { int retries = 0; @@ -148,28 +152,26 @@ int time = 0; char tmpBuffer[BUFFER_SIZE]; int ret; - + printf("Mbed --> %s\n",webStatistics[i].host); - + time = PICO_TIME_MS(); // connecting if (client.connect(webStatistics[i].host, 80)) { printf("Failed to connect to : %s\n",webStatistics[i].host); continue; - } - - client.set_blocking(false,8000); + } + + client.set_blocking(false, 8000); retries = 0; - + // sending request - ret = client.send_all(webStatistics[i].request,strlen(webStatistics[i].request)); - if (ret <= 0) - { + if (ret <= 0) { printf("This test failed big time, ret=%d, err=%d!!\n", ret, pico_err); while(1);;; } - + retries = 0; // start reading while(true) @@ -180,49 +182,42 @@ retries++; } else if (ret < 0) { if (pico_err != PICO_ERR_ESHUTDOWN) { - printf("Read error, bailing out. Ret = %d, err = %d\n", ret, pico_err); - while(1);;; + printf("Read error, skipping. Ret = %d, err = %d\n", ret, pico_err); + break; } client.close(); break; } else { received += ret; } - + if(retries == READING_RETRIES) { - printf("Read operation failed too many times. Giving up.\n"); + printf("Read operation failed too many times: skipping.\n"); break; - } + } } - - - + //Snapshot! time = PICO_TIME_MS() - time; - + if(webStatistics[i].maxReceived < received) - { webStatistics[i].maxReceived = received; - } - + if(webStatistics[i].minReceived > received) - { webStatistics[i].minReceived = received; - } + printf("Received : %d bytes\n",received); - if (received <= 0) { - printf("Test FAILED!\n"); - while(1);;; - } - webStatistics[i].avgDuration = ((webStatistics[i].avgDuration *(webStatistics[i].snapshots++) ) + time)/webStatistics[i].snapshots; + webStatistics[i].sumDuration += time; + webStatistics[i].snapshots++; totalTime += time; memoryStamp(); } - + printStatistics(); Thread::wait(500); } - failure: + failure: printf("Fatal error. Main thread is inactive\n"); while(1); } +
diff -r 0406e4e7639f -r 16d6db68e32f mbed-rtos.lib --- a/mbed-rtos.lib Mon Feb 10 08:38:15 2014 +0000 +++ b/mbed-rtos.lib Wed Apr 09 13:50:55 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed-rtos/#58b30ac3f00e +http://mbed.org/users/mbed_official/code/mbed-rtos/#cb1d43beeb70
diff -r 0406e4e7639f -r 16d6db68e32f mbed.bld --- a/mbed.bld Mon Feb 10 08:38:15 2014 +0000 +++ b/mbed.bld Wed Apr 09 13:50:55 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e \ No newline at end of file