tcp_max_orphans

简介: /proc/sys/net/ipv4/tcp_max_orphans 系统所能处理不属于任何进程的TCP sockets最大数量。假如超过这个数量,那么不属于任何进程的连接会被立即reset,并同时显示警告信息。

/proc/sys/net/ipv4/tcp_max_orphans

系统所能处理不属于任何进程的TCP sockets最大数量。假如超过这个数量那么不属于任何进程的连接会被立即reset,并同时显示警告信息。之所以要设定这个限制﹐纯粹为了抵御那些简单的 DoS 攻击﹐千万不要依赖这个或是人为的降低这个限制更应该增加这个值(如果增加了内存之后)。每个孤儿套接字最多能够吃掉你64K不可交换的内存。

Maximal number of TCP sockets not attached to any user file handle, held by system. If this number is exceeded orphaned connections are reset immediately and warning is printed. This limit exists only to prevent simple DoS attacks, you must not rely on this or lower the limit artificially, but rather increase it (probably, after increasing installed memory), if network conditions require more than default value, and tune network services to linger and kill such states more aggressively. Let me to remind again: each orphan eats up to ~64 KB of unswappable memory.

/proc/sys/net/ipv4/tcp_orphan_retries

本端试图关闭TCP连接之前重试多少次。缺省值是7,相当于50~16分钟(取决于RTO)。如果你的机器是一个重载的WEB服务器,你应该考虑减低这个值,因为这样的套接字会消耗很多重要的资源。参见tcp_max_orphans

How may times to retry before killing TCP connection, closed by our side. Default value 7 corresponds to  50sec-16min depending on RTO. If your machine is a loaded WEB server, you should think about lowering this value, such sockets may consume significant resources. Cf. tcp_max_orphans

源码

static int tcp_out_of_resources(struct sock *sk, int do_reset)

{

struct tcp_sock *tp = tcp_sk(sk);

int orphans = atomic_read(&tcp_orphan_count);

/* If peer does not open window for long time, or did not transmit

* anything for long time, penalize it. */

if ((s32)(tcp_time_stamp - tp->lsndtime) > 2*TCP_RTO_MAX || !do_reset)

orphans <<= 1;

/* If some dubious ICMP arrived, penalize even more. */

if (sk->sk_err_soft)

orphans <<= 1;

if (tcp_too_many_orphans(sk, orphans)) {

if (net_ratelimit())

printk(KERN_INFO "Out of socket memory\n");

/* Catch exceptional cases, when connection requires reset.

* 1. Last segment was sent recently. */

if ((s32)(tcp_time_stamp - tp->lsndtime) <= TCP_TIMEWAIT_LEN ||

/* 2. Window is closed. */

(!tp->snd_wnd && !tp->packets_out))

do_reset = 1;

if (do_reset)

tcp_send_active_reset(sk, GFP_ATOMIC);

tcp_done(sk);

NET_INC_STATS_BH(LINUX_MIB_TCPABORTONMEMORY);

return 1;

}

}

return 0;

}

[1]http://blog.chinaunix.net/uid-24237502-id-3014152.html

[2]http://www.blogjava.net/fine/archive/2008/07/26/217709.html

[3]http://www.linuxinsight.com/proc_sys_net_ipv4_tcp_max_orphans.html

[4]http://pastebin.com/fZNh3LJf

[5]http://lartc.org/howto/lartc.kernel.obscure.html

[6]http://www.frozentux.net/ipsysctl-tutorial/chunkyhtml/tcpvariables.html

[7]http://hi.baidu.com/lewutian/item/d51143fbaa226aed1a111fcd

目录
相关文章
|
9月前
|
网络协议 算法 Java
|
6月前
|
网络协议 网络性能优化
TCP面向连接
【8月更文挑战第19天】
110 1
|
9月前
|
网络协议 安全 Unix
聊聊TCP中的TIME_WAIT
【4月更文挑战第4天】 TIME_WAIT 的产生、作用以及优化
|
9月前
|
缓存 网络协议 算法
深入TCP协议——tcp_tw_reuse和tcp_tw_recycle
前情提要:深入理解Linux网络——TCP协议三次握手和四次挥手详细流程 我们已经知道TCP四次挥手中,主动方在收到被动方的FIN数据包之后会进入TIME_WAIT状态等待2MSL的时间后才进入CLOSED。在 Linux 操作系统下,TIME_WAIT 状态的持续时间是 60 秒,这意味着这 60 秒内,客户端一直会占用着这个端口,这是有一定的开销的。如果如果主动关闭连接方的 TIME_WAIT 状态过多,占满了所有端口资源,则会导致无法创建新连接。
|
运维 网络协议 Linux
聊聊 IP packet 的 TTL 与 tcp segment 的 MSL
聊聊 IP packet 的 TTL 与 tcp segment 的 MSL
|
缓存 网络协议 算法
三、TCP篇(下)
三、TCP篇
214 0
三、TCP篇(下)
|
缓存 网络协议 安全
TCP为什么安全
老八股了,都说TCP比UDP安全,那他安全再哪呢。。
238 0
|
缓存 网络协议 Linux
三、TCP篇(上)
三、TCP篇
418 0
三、TCP篇(上)
|
网络协议 网络性能优化
TCP ,丫的终于来了!!(一)
之前的文章一直在聊各种网络协议,那么从这篇文章开始,我就会和你聊一聊关于 TCP 协议的种种特征,比如 TCP 连接管理(也是这篇文章主要讨论的)、TCP 超时和重传、TCP 拥塞控制、TCP 数据流和窗口管理。
TCP ,丫的终于来了!!(一)
|
算法 网络协议 网络性能优化
TCP详解
详解介绍TCP各个阶段的状态及原理

热门文章

最新文章