当前位置:网站首页>Can the out of sequence message complete TCP three handshakes
Can the out of sequence message complete TCP three handshakes
2022-07-04 06:33:00 【dog250】
as follows TCP Handshake sequence :
Ask which message in bold can be completed TCP Shake hands ?server Terminal accept Will you return ?
The answer is yes :
- Just get to server The message ack Field equals server syn+1, To complete the handshake .
TCP The protocol is full duplex ,3rd ack Belong to server To client Direction syn The confirmation of ,server Just verify it ack Field as the root ,seq Can be regarded as client To server Direction ack A piggyback to data, The verification is not strict .
The following packetdrill Scripts can demonstrate :
+0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0 setsockopt(3, SOL_SOCKET, SO_RCVBUF, [8000], 4) = 0
+0 bind(3, ..., ...) = 0
+0 listen(3, 1) = 0
// Start shaking hands
+0 < S 0:0(0) win 1000 <mss 1000,sackOK,nop,nop>
+0 > S. 0:0(0) ack 1<...>
// Complete handshake with out of sequence messages
+.1 < P. 1000:5380(4380) ack 1 win 32792
// The following is the normal sequential message , Open the notes for comparison
//+.8 < . 1:1(0) ack 1 win 32792
+0 accept(3, ..., ...) = 4
+.2 %{
assert 1 == tcpi_state }%
+.3 %{
print tcpi_state, tcpi_ca_state }%
+.3 %{
print tcpi_rcv_space }%
// The third time of disorder ACK
+.8 < . 1:1(0) ack 1 win 32792
// The first message out of order
+.8 < . 1:1000(999) ack 1 win 32792
Start another terminal , Enter the following command line and execute packetdrill give the result as follows :
~/test$ sudo bpftrace -e 'kr:inet_csk_accept/comm == "pdrill"/{
$tp = (struct tcp_sock*)retval;$sk = (struct sock*)retval;printf("state:%d rcv_nxt:%d ofo_pkts:%d\n", $sk->sk_state, $tp->rcv_nxt, $tp->rcv_ooopack);}' --include "linux/tcp.h"
Attaching 1 probe...
state:1 rcv_nxt:1 ofo_pkts:1 # explain : Connected ESTABLISHED, Expect to receive 1 Number , Disordered message enters ofo queue
stay accept At the right time , come from client The third handshake ACK It hasn't arrived yet , But the disordered message arrived , Handshake can also be successful . The most important thing is 12 Yes "ack 1", If it is changed to other , Handshake will not complete .
It begins with ,server Received data Belong to 3rd ack A piggyback to , Disorder should be tolerated , Just in server Tolerance range , To complete the handshake , This tolerance range is determined by server Announcement window metrics . If the out of sequence message is as follows :
+.1 < P. 11000:15380(4380) ack 1 win 32792
This message exceeds the notification window ,server It can be determined that it is forged or over issued , The message is discarded , The handshake couldn't be completed ,accept Will wait forever .
As a rule ,client Observe the limits of the notification window , Even if the order is disordered, it will eventually be covered by the window , So the design is reasonable . But the root cause , It's still in TCP full duplex , The two directions should be treated separately .
The above text can also be passed tcpdump Packet capture verification .
TCP syncookie Shaking hands can also tolerate disorder , This means that seq Code in cookie Why , But if seq No participation cookie Calculation , The following data loss problems may occur :
so cookie In the case of handshake , Tolerance of disorder and data integrity cannot be achieved at the same time , Abandon data integrity and maintain robustness .
It's coming , Short summary TCP handshake .
TCP Handshake is 4 Second, not 3 Time , Every direction 2 Time . It's just server To client The direction is right syn Confirmation and server To client The direction of the syn combine 1 Time , Show 3 Just a handshake :
Look at the wave stage , Because the two directions of transmission are independent of each other , Therefore, passive closing end pairs cannot be merged fin And their own fin.
Beneath the surface , Waving and shaking hands are essentially the same , Its core is TCP Full duplex .
Zhejiang Wenzhou leather shoes wet , It's not fat when it's raining .
边栏推荐
- 如何实现视频平台会员多账号登录
- 分布式CAP理论
- QT QTableWidget 表格列置顶需求的思路和代码
- SQL join, left join, right join usage
- How to realize multi account login of video platform members
- Nexus 6p从8.0降级6.0+root
- C language - Blue Bridge Cup - Snake filling
- Option (024) - do all objects have prototypes?
- JS execution mechanism
- Appium基础 — APPium安装(二)
猜你喜欢
SQL injection SQL lab 11~22
2022 Xinjiang's latest eight members (Safety Officer) simulated examination questions and answers
Weekly summary (*63): about positive energy
Component、Container容器常用API详解:Frame、Panel、ScrollPane
17-18. Dependency scope and life cycle plug-ins
How to realize multi account login of video platform members
Learning multi-level structural information for small organ segmentation
Practical gadget instructions
Arcpy uses the updatelayer function to change the symbol system of the layer
Review | categories and mechanisms of action of covid-19 neutralizing antibodies and small molecule drugs
随机推荐
buuctf-pwn write-ups (8)
JSON web token -- comparison between JWT and traditional session login authentication
MySQL information_ Schema database
Detailed explanation of common APIs for component and container containers: frame, panel, scrollpane
uniapp 自定義環境變量
C # symmetric encryption (AES encryption) ciphertext results generated each time, different ideas, code sharing
Manually page the list (parameter list, current page, page size)
【问题记录】03 连接MySQL数据库提示:1040 Too many connections
The solution of win11 taskbar right click without Task Manager - add win11 taskbar right click function
Learning multi-level structural information for small organ segmentation
leetcode 310. Minimum Height Trees
LayoutManager布局管理器:FlowLayout、BorderLayout、GridLayout、GridBagLayout、CardLayout、BoxLayout
[Android reverse] function interception (CPU cache mechanism | CPU cache mechanism causes function interception failure)
Arcpy 利用updatelayer函数改变图层的符号系统
How to help others effectively
Data analysis notes 09
How to realize multi account login of video platform members
Tf/pytorch/cafe-cv/nlp/ audio - practical demonstration of full ecosystem CPU deployment - Intel openvino tool suite course summary (Part 2)
ORICO ORICO outdoor power experience, lightweight and portable, the most convenient office charging station
Common JS tool Libraries