当前位置: 首页 > news >正文

TCP状态转移图详解

状态

描述

LISTEN

represents waiting for a connection request from any remote TCP and port.

SYN-SENT

represents waiting for a matching connection request after having sent a connection request.

SYN-RECEIVED

represents waiting for a confirming connection request acknowledgment after having both received and sent a connection request.

ESTABLISHED

represents an open connection, data received can be delivered to the user. The normal state for the data transfer phase of the connection.

FIN-WAIT-1

represents waiting for a connection termination request from the remote TCP, or an acknowledgment of the connection termination request previously sent.

FIN-WAIT-2

represents waiting for a connection termination request from the remote TCP.

CLOSE-WAIT

represents waiting for a connection termination request from the local user.

CLOSING

represents waiting for a connection termination request acknowledgment from the remote TCP.

LAST-ACK

represents waiting for an acknowledgment of the connection termination request previously sent to the remote TCP (which includes an acknowledgment of its connection termination request).

TIME-WAIT

represents waiting for enough time to pass to be sure the remote TCP received the acknowledgment of its connection termination request.

CLOSED

represents no connection state at all.

重点解读:

1. 数据包类型和作用:

SYN - 同步序列编号,用于发起连接请求

SYN,ACK - 同步序列编号和确认,用于响应连接请求。

ACK - 确认,用于确认接收到的数据或连接请求。

FIN - 终止,用于发起连接关闭请求。

RST - 重置,用于立即终止连接或拒绝连接请求。

FIN,ACK - 终止和确认,用于在关闭连接过程中确认接收到的FIN。

2. 图中实线表示 client端状态转换, 虚线表示server端的状态转换

3.建立连接, TCP三次握手,1、3是client端,2 、4是server端:

3. TCP关闭,4次挥手:

4.  Simultaneous Open(同时打开),这种情况不常见。

  • 定义:这是指两个TCP端点在几乎同一时间尝试发起连接的过程。

  • 过程:

    1. 同时发送SYN段,进入SYN_SENT状态。

    2. 双方接收到对方的SYN段,进入SYN_RCVD状态。

    3. 然后双方都发送SYN-ACK(SYN和ACK的组合),再次进入SYN_SENT状态。

    4. 最后,双方接收到对方的ACK段,进入ESTABLISHED状态,连接建立。

  • 场景:这种情况在实际应用中不常见,但可能出现在对等网络(P2P)中,其中两个节点同时尝试建立连接。

 

5.  理解这张图的难点是:这张图是状态转移图,不是按时间线走的

所以根据不同场景从状态转移图里面标识出时间线,那么就容易理解了。

状态转移举例说明:

比如 SYN_SENT 表示 发送了  SYN 包后的状态,

client端和server端都可以发起连接(tcp Simultaneous ) 。

SYN_SENT 的前一个状态可能是: closed(client)   或者  listen(server),

他的下一个状态:

1正常情况: 接收到自己已发送SYN包的ACK 和对方的SYN请求 ,回复对法SYN(发送ACK), 流转到 established 连接已建立(只是发起方单向连接,接受方还需要收到ACK 后才行)

2只收到了SYN, 自己发送的SYN 对应的 ACK 还没到达,那么状态就转成syn_rcvd ,等待自己SYN 包的ACK

3 超时:自己发送SYN后,达到超时时间后,啥也没收到,超时关闭

http://www.lryc.cn/news/525220.html

相关文章:

  • curl简介与libcurl开源库的使用总结
  • Win10系统部署RabbitMQ Server
  • uniapp APP端页面触发调用webview(页面为uniapp开发的H5)里的方法
  • 嵌入式知识点总结 C/C++ 专题提升(七)-位操作
  • 新星杯-ESP32智能硬件开发--ESP32的I/O组成
  • 航空航天混合动力(7)航空航天分布式电推进系统
  • AIGC视频生成明星——Emu Video模型
  • Cyber Security 101-Security Solutions-Firewall Fundamentals(防火墙基础)
  • 备赛蓝桥杯之第十五届职业院校组省赛第一题:智能停车系统
  • Docker核心命令与Yocto项目的高效应用
  • idea plugin插件开发——入门级教程(IntelliJ IDEA Plugin)
  • 61,【1】BUUCTF WEB BUU XSS COURSE 11
  • 开发环境搭建-1:配置 WSL (类 centos 的 oracle linux 官方镜像)
  • Spring Boot MyBatis Plus 版本兼容问题(记录)
  • 26. 【.NET 8 实战--孢子记账--从单体到微服务】--需求更新--用户注销、修改用户名、安全设置
  • 神经网络|(一)加权平均法,感知机和神经元
  • OpenHarmony OTA升级参考资料记录
  • 在 Kubernetes 上快速安装 KubeSphere v4.1.2
  • 【回忆迷宫——处理方法+DFS】
  • 华为OD机试真题---战场索敌
  • 计算机网络 (53)互联网使用的安全协议
  • c++算法贪心系列
  • 【Maui】注销用户,采用“手势”点击label弹窗选择
  • 智慧脚下生根,智能井盖监测终端引领城市安全新革命
  • Word2Vec如何优化从中间层到输出层的计算?
  • 第七篇:vue3 计算属性:computed
  • 搭建k8s集群
  • Android SystemUI——最近任务应用列表(十七)
  • java 根据前端传回的png图片数组,后端加水印加密码生成pdf,返回给前端
  • 《探秘鸿蒙Next:如何保障AI模型轻量化后多设备协同功能一致》