From cea3ff9d3896009bf9dafc8ae519208faaae24c9 Mon Sep 17 00:00:00 2001 From: marcbou Date: Thu, 19 Jun 2003 12:45:32 +0000 Subject: [PATCH] Change TCP_TMR_INTERVAL from 100 to 250ms. tcp_fasttmr() and tcp_slowtmr() call frequencies should remain unchanged, but system load will be reduced. Closes patch #1495. Please email me if you see any issues with this. Non-standard TCP timer definitions in contrib/ports/v2pro/lwipopts.h might need adjustment as a consequence of this change. --- src/core/tcp.c | 19 ++++++------------- src/include/lwip/tcp.h | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/core/tcp.c b/src/core/tcp.c index c1332500..30d7f57e 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -106,18 +106,11 @@ tcp_init(void) void tcp_tmr(void) { - ++tcp_timer; - if (tcp_timer == 10) { - tcp_timer = 0; - } - - if (tcp_timer & 1) { - /* Call tcp_fasttmr() every 200 ms, i.e., every other timer - tcp_tmr() is called. */ - tcp_fasttmr(); - } - if (tcp_timer == 0 || tcp_timer == 5) { - /* Call tcp_slowtmr() every 500 ms, i.e., every fifth timer + /* Call tcp_fasttmr() every 250 ms */ + tcp_fasttmr(); + + if (++tcp_timer & 1) { + /* Call tcp_tmr() every 500 ms, i.e., every other timer tcp_tmr() is called. */ tcp_slowtmr(); } @@ -626,7 +619,7 @@ tcp_slowtmr(void) /* * tcp_fasttmr(): * - * Is called every TCP_FINE_TIMEOUT (100 ms) and sends delayed ACKs. + * Is called every TCP_FAST_INTERVAL (250 ms) and sends delayed ACKs. */ /*-----------------------------------------------------------------------------------*/ void diff --git a/src/include/lwip/tcp.h b/src/include/lwip/tcp.h index 72f2593c..dcd1c6ed 100644 --- a/src/include/lwip/tcp.h +++ b/src/include/lwip/tcp.h @@ -53,7 +53,7 @@ void tcp_init (void); /* Must be called first to initialize TCP. */ void tcp_tmr (void); /* Must be called every TCP_TMR_INTERVAL - ms. (Typically 100 ms). */ + ms. (Typically 250 ms). */ /* Application program's interface: */ struct tcp_pcb * tcp_new (void); struct tcp_pcb * tcp_alloc (u8_t prio); @@ -115,30 +115,30 @@ void tcp_rexmit (struct tcp_pcb *pcb); #define TCP_SEQ_GT(a,b) ((s32_t)((a)-(b)) > 0) #define TCP_SEQ_GEQ(a,b) ((s32_t)((a)-(b)) >= 0) -#define TCP_FIN 0x01 -#define TCP_SYN 0x02 -#define TCP_RST 0x04 -#define TCP_PSH 0x08 -#define TCP_ACK 0x10 -#define TCP_URG 0x20 +#define TCP_FIN 0x01U +#define TCP_SYN 0x02U +#define TCP_RST 0x04U +#define TCP_PSH 0x08U +#define TCP_ACK 0x10U +#define TCP_URG 0x20U -#define TCP_FLAGS 0x3f +#define TCP_FLAGS 0x3fU /* Length of the TCP header, excluding options. */ #define TCP_HLEN 20 #ifndef TCP_TMR_INTERVAL -#define TCP_TMR_INTERVAL 100 /* The TCP timer interval in +#define TCP_TMR_INTERVAL 250 /* The TCP timer interval in milliseconds. */ #endif /* TCP_TMR_INTERVAL */ #ifndef TCP_FAST_INTERVAL -#define TCP_FAST_INTERVAL 200 /* the fine grained timeout in +#define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */ #endif /* TCP_FAST_INTERVAL */ #ifndef TCP_SLOW_INTERVAL -#define TCP_SLOW_INTERVAL 500 /* the coarse grained timeout in +#define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in milliseconds */ #endif /* TCP_SLOW_INTERVAL */