当前位置:网站首页>TCP abnormal connection
TCP abnormal connection
2022-06-22 11:14:00 【To maintain world peace_】
Catalog
Full queue and half queue queries
TCP Abnormal connections are divided into connect, The first handshake , Third handshake source logic introduction , Give the optimization scheme and the method to view the full connection and half connection .
connect
After the connection fails , A large number of port range lookups , Can call spin lock and other operations hash lookup , Cause system state CPU Expenses are rising .
The first handshake
client
- 1) Half the queue is full , And tcp_syncookies by 0
2) The whole line is full , And there are unfinished semi connection requests ;
3) Have not received synack Client initiated retry , Time to 1s in the future , Have an impact on the system ;
4) Retransmission time 1 2 4 8 16 32 Double ; Times is tcp_syn_retries
int tcp_conn_request(struct request_sock_ops *rsk_ops,
const struct tcp_request_sock_ops *af_ops,
struct sock *sk, struct sk_buff *skb)
{
// Check whether the half connection queue is full
if ((net->ipv4.sysctl_tcp_syncookies == 2 ||
inet_csk_reqsk_queue_is_full(sk)) && !isn) {
// Check whether kernel parameters are enabled tcp_syncookies, Generally open , When the semi connection queue is full, the normal handshake can still be guaranteed
want_cookie = tcp_syn_flood_action(sk, rsk_ops->slab_name);//syn attack The half connection queue on the server is exhausted, making the user request unable to respond
if (!want_cookie)
goto drop;
}
// Check whether the full connection queue is full
if (sk_acceptq_is_full(sk)) {
NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);
goto drop;
}
}The third handshake
Server side
1) If the full connection queue is full, it will be discarded , The client doesn't know , The server initiates syn+ack
2) The number of times by tcp_synack_retries control
( Phenomenon manufacturing , Don't make accept, Let the client fill up the connection queue resources )
tuning
Insufficient ports
1) Adjust port Ip_local_port_range Increase the port range
2) Use multiplexed connections
3) Use long links
4) Turn on tcp_tw_reuse and tcp_tw_recycle
In case of handshake
1) open syncookies
Prevent too many requests from filling the half connection queue ;SYN attack ; Solve the packet loss caused by the full half connection queue at the server .
2) Increase the full connection queue length
The whole queue :Min(backlog,net.core.somaxconn)
3) Call as soon as possible accept
Remove the connection from the whole queue
4) Reduce TCP Number of connections , Reject as soon as possible ;
Kernel parameters tcp_abort_on_overflow Send directly when full rst To the client , The client receives connection reset by peer
Use long links instead of short ones ;
The number of retries should not be increased ;
Full queue and half queue queries
Full connection queue
#netstat -s | grep overflowedA change in the preceding number means an overflow
Semi connected queues
netstat –s | grep SYNs This method is wrong , Can't explain the problem Because full connection overflow will also increase .
1)want_cookie Whether the parameter is 1, If it's true , Then the semi connection overflow and packet loss will not occur .
2)want_cookie, Not open , except netstat –antp, Suggest checking listen On port SYN_RECV The number of
#watch 'netstat -s | grep "SYNs"'
#netstat –antp | grep SYN_RECV | wc -l Reference resources
https://course.0voice.com/v1/course/intro?courseId=2&agentId=0
边栏推荐
- Pule frog VR typhoon escape experience VR disaster self rescue simulation system VR popular science knowledge equipment
- Backbone! Youxuan software was selected as one of the top 100 digital security companies in China in 2022
- Eureka的InstanceInfoReplicator类(服务注册辅助工具)
- 云端极简部署Svelte3聊天室
- Go微服务(一)——RPC入门
- Recommend a virtual machine software for fast cluster building of M1 chip computers
- 2022年深入推进IPv6部署和应用,该如何全面实现安全升级改造?
- Microsoft edge browser dev 104 is released, and the deep / shallow theme switching is smoother
- Arm load storage instruction
- 7-1 框架发布 - 通过npm发布框架
猜你喜欢

CVPR 2022 oral | a new motion oriented point cloud single target tracking paradigm

A special file upload

The father of the college entrance examination student told himself at night that what he cared about most was not the child's performance, and the turning point was not false at all

CVPR 2022 Oral | 以运动为导向的点云单目标跟踪新范式

Should the theme of the IDE be bright or dark? Here comes the ultimate answer!

The first "cyborg" in the world died, and he only transformed himself to "change his life against the sky"

Pytoch realizes wave impedance inversion

rtklib postpos 梳理(以单点定位为例)

HMS Core新闻行业解决方案:让技术加上人文的温度

When the system is reconstructed, I will leave!
随机推荐
R语言使用MatchIt包进行倾向性匹配分析、使用match.data函数构建匹配后的样本集合、使用lm函数对匹配后的样本构建线性回归模型、summary函数查看模型的汇总统计信息
social phobia? When I introduce myself, my brain goes blank?
Examination question bank and online simulation examination for main principals of hazardous chemical production units in 2022
6-13 improving load performance - application cache
“不敢去怀疑代码,又不得不怀疑代码”记一次网络请求超时分析
LeetCode Algorithm 21. Merge two ordered linked lists
Rtklib postpos carding (taking single point positioning as an example)
Today, how does sysak implement business jitter monitoring and diagnosis Take you through Anolis OS 25-26
【云图说】 第244期 三分钟了解容器镜像服务
7-1 框架发布 - 通过npm发布框架
Leetcode algorithm Delete the node of the linked list
在 Laravel 中使用计算列
R语言使用MatchIt包进行倾向性匹配分析、使用match.data函数构建匹配后的样本集合、使用可视化分析检验倾向性评分匹配后样本中的所有协变量的平衡情况
The first "cyborg" in the world died, and he only transformed himself to "change his life against the sky"
2022 Shaanxi Provincial Safety Officer B certificate operation certificate examination question bank and online simulation examination
线程死锁的理解
Construction details of Danzhou clean animal laboratory
[cloud picture] episode 244 three minute understanding of container image service
社恐?自我介绍时大脑一片空白?
What is the name of CITIC Securities app? Is it safe to open a stock account?