[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] A closed pcb stays for 120seconds in the tcp_tw_pcbs. Right
From: |
Michael Anburaj |
Subject: |
[lwip-users] A closed pcb stays for 120seconds in the tcp_tw_pcbs. Right or wrong? |
Date: |
Tue, 21 Dec 2004 14:27:08 -0800 (PST) |
Hi,
A closed pcb stays for 120seconds in the tcp_tw_pcbs.
Right or wrong?
FYI: Source line references are made w.r.to the CVS
version of the files.
The ftp server program I have been working on, follows
the following loop (pseudo code):
tcp_new
{ Loop:
tcp_bind
tcp_listen
tcp_accept
bunch of reads & writes
tcp_close
}
After 8 times through the loop tcp_listen fails at
line 400 of tcp.c
lpcb = memp_malloc(MEMP_TCP_PCB_LISTEN);
fails to get a free pcb structure veritable.
Since MEMP_NUM_TCP_PCB_LISTEN is defined as 8 after 8
times there are no free pcb structure variables in the
free_list.
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening
TCP
connections. */
#define MEMP_NUM_TCP_PCB_LISTEN 8
Each time tcp_close gets called to free a pcb, its
state gets changed to TIME_WAIT & gets put in
tcp_tw_pcbs list.
At every 500ms ,tcp_slowtmr() gets called & process
all the pcbs in the tcp_tw_pcbs list.
Line 709 of tcp.c
if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL /
TCP_SLOW_INTERVAL) {
++pcb_remove;
}
Questions:
1. Is this check intended for freeing the pcb after (2
* TCP_MSL) == 120millisec time is passed?
2. If yes, then the above check is wrong.
(2 * TCP_MSL) == 2*60000microsec == 120000microsec ==
120millisec
TCP_SLOW_INTERVAL == 500millisec
2 * TCP_MSL / TCP_SLOW_INTERVAL == 240 ticks, which is
240*500ms = 120 seconds not equal to the intended
120millisec
So the check as such, removes a pcb after 120seconds
is passed & not 120milliseconds.
Correct code:
=========
if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL /
(TCP_SLOW_INTERVAL*1000)) {
++pcb_remove;
}
3. Even so, the granularity of the slow timer (500ms)
is not suited for timeout of 120ms.
Let me know if I missed something or if I uncovered a
bug.
Last question:
Looking at the code the PCB_REUSE attribute should
make use of pcbs in tcp_tw_pcbs even before they get
freed. Am I right? Then I shouldnt have seen this
problem
Cheers,
-Mike.
__________________________________
Do you Yahoo!?
Send a seasonal email greeting and help others. Do good.
http://celebrity.mail.yahoo.com