TIME_WAIT Truncation

Step One:

In order to record the start point of a connection, we have added the following line:

tp->cc_cache.t_duration = jiffies;

to function ttcp_connect (net/ipv4/tcp_output.c).

Step Two:

When a sock enters TIME_WAIT state, it calls funtion tcp_time_wait() (net/ipv4/tcp_minisocks.c). In that function, we check whether the connection has been in existence for a period shorter than TTCP_MSL. If so, TIME_WAIT truncation is valid and we set the TIME_WAIT period to 12*TTCP_MSL (12s) instead of TCP_TIMEWAIT_LEN (60s).

Step Three:

The client can actually call bind() to reuse one particular local port intentionally. In this process, tcp_v4_get_port() is called. We have modified the funtion to enable it to make a particular port available when the port is currently owned by one sock in TIME_WAIT state.