From c6f21fde628193c7957d84792215ecaa14d5beb7 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 12 Feb 2010 07:54:28 +0000 Subject: Speed up Webserver demo data rate by not sending a full ethernet frame each time, preventing the receiver from using a delayed ACK scheme which slows down the connection. TELNET server cleanup. --- Projects/Webserver/Lib/FATFs/diskio.c | 28 ---------------------------- Projects/Webserver/Lib/FATFs/diskio.h | 2 +- Projects/Webserver/Lib/HTTPServerApp.c | 10 +++++++--- Projects/Webserver/Lib/TELNETServerApp.c | 14 ++++++++++---- Projects/Webserver/Lib/uip/uipopt.h | 2 +- 5 files changed, 19 insertions(+), 37 deletions(-) (limited to 'Projects/Webserver/Lib') diff --git a/Projects/Webserver/Lib/FATFs/diskio.c b/Projects/Webserver/Lib/FATFs/diskio.c index c7c837ba4..028c631ba 100644 --- a/Projects/Webserver/Lib/FATFs/diskio.c +++ b/Projects/Webserver/Lib/FATFs/diskio.c @@ -62,31 +62,3 @@ DRESULT disk_write ( return RES_OK; } #endif /* _READONLY */ - - - -/*-----------------------------------------------------------------------*/ -/* Miscellaneous Functions */ - -DRESULT disk_ioctl ( - BYTE drv, /* Physical drive nmuber (0..) */ - BYTE ctrl, /* Control code */ - void *buff /* Buffer to send/receive control data */ -) -{ - if (ctrl == CTRL_SYNC) - return RES_OK; - else - return RES_PARERR; -} - - -DWORD get_fattime (void) -{ - return ((DWORD)1 << 25) | - ((DWORD)1 << 21) | - ((DWORD)1 << 16) | - ((DWORD)1 << 11) | - ((DWORD)1 << 5) | - ((DWORD)1 << 0); -} diff --git a/Projects/Webserver/Lib/FATFs/diskio.h b/Projects/Webserver/Lib/FATFs/diskio.h index 3df93ae7a..2f444f7b6 100644 --- a/Projects/Webserver/Lib/FATFs/diskio.h +++ b/Projects/Webserver/Lib/FATFs/diskio.h @@ -5,7 +5,7 @@ #ifndef _DISKIO #define _READONLY 0 /* 1: Read-only mode */ -#define _USE_IOCTL 1 +#define _USE_IOCTL 0 #include "integer.h" #include "ff.h" diff --git a/Projects/Webserver/Lib/HTTPServerApp.c b/Projects/Webserver/Lib/HTTPServerApp.c index e781beb22..0d0cbb903 100644 --- a/Projects/Webserver/Lib/HTTPServerApp.c +++ b/Projects/Webserver/Lib/HTTPServerApp.c @@ -31,7 +31,7 @@ /** \file * * Simple HTTP Webserver Application. When connected to the uIP stack, - * this will serve out files to HTTP clients. + * this will serve out files to HTTP clients on port 80. */ #define INCLUDE_FROM_HTTPSERVERAPP_C @@ -270,8 +270,12 @@ static void HTTPServerApp_SendData(void) uip_tcp_appstate_t* const AppState = &uip_conn->appstate; char* const AppData = (char*)uip_appdata; - /* Must determine the maximum segment size to determine maximum file chunk size */ - uint16_t MaxSegmentSize = uip_mss(); + /* Must determine the maximum segment size to determine maximum file chunk size - never send a completely + * full packet, as this will cause some hosts to start delaying ACKs until a non-full packet is received. + * since uIP only allows one packet to be in transit at a time, this would cause long delays between packets + * until the host times out and sends the ACK for the last received packet. + */ + uint16_t MaxSegmentSize = (uip_mss() >> 1); /* Return file pointer to the last ACKed position */ f_lseek(&AppState->HTTPServer.FileHandle, AppState->HTTPServer.ACKedFilePos); diff --git a/Projects/Webserver/Lib/TELNETServerApp.c b/Projects/Webserver/Lib/TELNETServerApp.c index 7d8c907fe..2abd7b0ed 100644 --- a/Projects/Webserver/Lib/TELNETServerApp.c +++ b/Projects/Webserver/Lib/TELNETServerApp.c @@ -31,7 +31,7 @@ /** \file * * TELNET Webserver Application. When connected to the uIP stack, - * this will serve out connection information to the client. + * this will serve out raw TELNET to the client on port 23. */ #define INCLUDE_FROM_TELNETSERVERAPP_C @@ -44,9 +44,13 @@ const char PROGMEM WelcomeHeader[] = "****************************************** /** Main TELNET menu, giving the user the list of available commands they may issue */ const char PROGMEM TELNETMenu[] = "\r\n" - " Available Commands:\r\n" + " == Available Commands: ==\r\n" " c) List Active TCP Connections\r\n" - "\r\nCommand>"; + " =========================\r\n" + "\r\n>"; + +/** Header to print before the current connections are printed to the client */ +const char PROGMEM CurrentConnectionsHeader = "\r\n* Current TCP Connections: *\r\n"; /** Initialization function for the simple HTTP webserver. */ void TELNETServerApp_Init(void) @@ -65,11 +69,13 @@ void TELNETServerApp_Callback(void) if (uip_connected()) { + /* New connection - initialize connection state values */ AppState->TELNETServer.CurrentState = TELNET_STATE_SendHeader; } if (uip_acked()) { + /* Progress to the next state once the current state's data has been ACKed */ AppState->TELNETServer.CurrentState = AppState->TELNETServer.NextState; } @@ -124,7 +130,7 @@ static void TELNETServerApp_DisplayTCPConnections(void) { char* const AppData = (char*)uip_appdata; - strcpy(AppData, "\r\n* Current TCP Connections: *\r\n"); + strcpy_P(AppData, CurrentConnectionsHeader); uint16_t ResponseLen = strlen(AppData); uint8_t ActiveConnCount = 0; diff --git a/Projects/Webserver/Lib/uip/uipopt.h b/Projects/Webserver/Lib/uip/uipopt.h index 5fca686a2..244ce1df1 100644 --- a/Projects/Webserver/Lib/uip/uipopt.h +++ b/Projects/Webserver/Lib/uip/uipopt.h @@ -691,7 +691,7 @@ typedef union uint8_t CurrentState; uint8_t NextState; - char FileName[50]; + char FileName[MAX_URI_LENGTH]; FIL FileHandle; bool FileOpen; uint32_t ACKedFilePos; -- cgit v1.2.3