Skip to content

Commit

Permalink
Improve TCP Window Handling
Browse files Browse the repository at this point in the history
- Testing improvements to window handling:
a: Testing showed some web servers will transmit payloads equal in size
to 1/2 MSS.
b: TCP window is not closed unless data received prior is still in the
buffer OR the length of the data is > 1/2 MSS
c: Allows usage of TCP window sizes > 511
d: Improves transfer rates and responsiveness
  • Loading branch information
TMRh20 committed Mar 6, 2015
1 parent 7fe284a commit b8da4d1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
39 changes: 27 additions & 12 deletions RF24Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,28 @@ void serialip_appcall(void) {
if(u){
if (uip_newdata()){
IF_RF24ETHERNET_DEBUG_CLIENT( Serial.println();Serial.print(F("UIPClient uip_newdata, uip_len:")); Serial.println(uip_len); );
if (uip_len && !(u->state & (UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED))){
uip_stop();
memcpy(u->myDataIn, uip_appdata, uip_datalen());
u->dataCnt += uip_datalen();
u->connAbortTime = u->restartTime = millis();
u->state &= ~UIP_CLIENT_RESTART;
u->windowOpened = false;

if (uip_len && !(u->state & (UIP_CLIENT_CLOSE | UIP_CLIENT_REMOTECLOSED))){

if(u->dataCnt > 0 || uip_len > uip_mss()/2){
uip_stop();
u->connAbortTime = u->restartTime = millis();
u->state &= ~UIP_CLIENT_RESTART;
u->windowOpened = false;
}
memcpy(&u->myDataIn[u->dataPos+u->dataCnt], uip_appdata, uip_datalen());
u->dataCnt += uip_datalen();

/*if(u->dataCnt == uip_mss()){
uip_stop();
u->connAbortTime = u->restartTime = millis();
u->state &= ~UIP_CLIENT_RESTART;
u->windowOpened = false;
} */

u->packets_in = 1;
u->dataPos=0;
//u->dataPos=0;

}
goto finish;
}
Expand Down Expand Up @@ -253,7 +266,7 @@ void serialip_appcall(void) {

/*******Polling**********/
if (uip_poll() || uip_rexmit() ){
IF_RF24ETHERNET_DEBUG_CLIENT( Serial.println(); Serial.println(F("UIPClient uip_poll")); );
//IF_RF24ETHERNET_DEBUG_CLIENT( Serial.println(); Serial.println(F("UIPClient uip_poll")); );

if (u->packets_out != 0 ) {
uip_len = u->out_pos;
Expand Down Expand Up @@ -387,11 +400,13 @@ int RF24Client::read(uint8_t *buf, size_t size) {

size = rf24_min(data->dataCnt,size);
memcpy(buf,&data->myDataIn[data->dataPos],size);
//memcpy(buf,&data->myData,size);
data->dataCnt -= size;

data->dataPos+=size;
//memmove(data->myData,data->myData+size,data->dataCnt);

if(data->dataPos >= uip_mss()){
data->dataPos = 0;
}

if(!data->dataCnt) {

data->packets_in = 0;
Expand Down
8 changes: 4 additions & 4 deletions uip-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ User Configuration Options
* @note Must be an odd number or the TCP/IP sequence gets out of order with payloads larger than 511 bytes
* I think this might be a bug or missing feature of the uip stack
*/
#if UIP_CONF_BUFFER_SIZE >= 512
#define OUTPUT_BUFFER_SIZE 511
#else
//#if UIP_CONF_BUFFER_SIZE >= 512
// #define OUTPUT_BUFFER_SIZE 511
//#else
#define OUTPUT_BUFFER_SIZE UIP_CONF_BUFFER_SIZE - UIP_CONF_LLH_LEN - UIP_TCPIP_HLEN
#endif
//#endif

/**
* <b>Optional:</b> Used with UIP_CONNECTION_TIMEOUT
Expand Down

0 comments on commit b8da4d1

Please sign in to comment.