1.根据Nagle算法,什么时候要发送包
内核代码,Nagle算法下,当一个报文能够被发送时,下面这个函数返回0
Filename : \linux-3.4.4\net\ipv4\tcp_output.c
/* Return 0, if packet can be sent now without violation Nagle's rules:
* 1. It is full sized.
* 2. Or it contains FIN. (already checked by caller)
* 3. Or TCP_CORK is not set, and TCP_NODELAY is set.
* 4. Or TCP_CORK is not set, and all sent packets are ACKed.
* With Minshall's modification: all sent small packets are ACKed.
*/
static inline int tcp_nagle_check(const struct tcp_sock *tp,
const struct sk_buff *skb,
unsigned mss_now, int nonagle)
{
return skb->len < mss_now && ((nonagle & TCP_NAGLE_CORK)
|| (!nonagle && tp->packets_out && tcp_minshall_check(tp)));
}
1.报文到达MSS
2.有FIN
3.!TCP_CORK && TCP_NOREPLY
4.!TCP_CORK && All_ACKED
5.超时