#include <dolphin/ip.h>
#define TCP_MSL 120 // maximum segment lifetime in second
s32 TCPSetTimeWaitBuffer( void* buffer, s32 len );
TCPSetTimeWaitBuffer() specifies the run-time buffer used for maintaining TCP connections in
the TIME_WAIT state. To prevent delayed
packets from being accepted by a later connection reincarnation and to complete
the TCP's full-duplex closing of a connection, the library
run-time must keep actively closed connection information in memory until 2 MSL
timeout (recommended value is four minutes). Since TCPInfo is a relatively
large structure, the library separately maintains connections that move to the TIME_WAIT
state in the time-wait buffer, where each connection occupies 24 bytes. The size required
for the time-wait buffer depends on how frequently the application performs the TCP active connection close. For example, with 1024 byte time-wait
buffer, the mean active close rate should not be faster than about once per 5.6 second
[(2 * MSL) / (1024 / 24) = 5.6258...].
Note that when a connection is actively closed and if there is no free space in the time-wait buffer, the library run-time discards the oldest entry in the time-wait buffer. If it happened, the other-end of the connection might not be able to complete the TCP's full-duplex closing of a connection, and delayed packets could be accepted by a later connection reincarnation.
buffer |
Pointer to the buffer to be used as the time wait buffer. |
len |
The size of the buffer in bytes. |
IP_ERR_NONE |
Succeeded. |
IP_ERR_INVALID |
Failed. |