当前位置:网站首页>Transport layer protocol (TCP 3-way handshake)
Transport layer protocol (TCP 3-way handshake)
2022-08-05 06:13:00 【Magic star】
传输层协议(TCP3次握手)
传输层协议
TCP/IP协议栈
TCP/IP介绍
TCP/IP传输协议,即传输控制/网络协议,也叫作网络通讯协议.它是在网络的使用中的最基本的通信协议.TCP/IP传输协议对互联网中各部分进行通信的标准和方法进行了规定.并且,TCP/IP传输协议是保证网络数据信息及时、完整传输的两个重要的协议.TCP/IP传输协议是严格来说是一个四层的体系结构,应用层、传输层、网络层和数据链路层都包含其中.
TCP/IP 通信过程
TCPFeatures and Features
**特点:**稳定、可重传、传输慢
特性:
- 工作在传输层
- 面向连接协议
- 全双工协议
- 半关闭
- 错误检查
- 将数据打包成段,排序
- 确认机制
- 数据恢复,重传
- 流量控制,滑动窗口
TCP端口
Each time a process is opened in the system, it will be allocatedpid(number in the system,方便管理),Next will assign one端口号
**端口号作用:**确定进程
源端口、目标端口:A process on a computer communicates with other processes through a computing port,而一个计算机端口某个时刻只能被一个进程占用,所以通过指定源端口和目标端口,就可以知道是哪两个进程需要通信.(源端口、目标端口是用16位表示的,可推算计算机的端口个数为2^16个,即 65536 (0-65535))
序列号:Indicates the number of the first byte of the data sent in this segment.(在TCP连接中所传送的字节流的每一个字节都会按顺序编号.由于序列号由32位表示,所以每2^32个字节,就会出现序列号回绕,再次从0 开始 无限循环)
确认号:(ack)Indicates that the receiver expects to receive the first byte data number of the sender's next segment.(也就是告诉发送方:我希望你(指发送方)下次发送的数据的第一个字节数据的编号为此确认号:Is there a problem with the transmission?)
数据偏移/首部长度:表示TCP报文段的首部长度,共4位,由于TCP首部包含一个长度可变的选项部分,需要指定这个TCP报文段到底有多长.
控制位:
URG(紧急位):Whether the data sent in this segment contains urgent data.(注:后面的紧急指针字段只有当URG=1时才有效 )
ACK(确认位):前面确认号字段是否有效.(注:只有当ACK=1时,前面的确认号字段才有效.A和BThe connection status has been established ACK=1)
PSH(急切位):提示接收端应用程序应该立即从TCP接收缓冲区中读走数据.(为接收后续数据腾出空间,如果为1,It means that the other party should immediately submit the data to the upper-layer application,Otherwise it will stay there foreverTCP缓冲区中)
RST(重置位):若RST=1,The connection to the host has gone terribly wrong(需释放连接,再重连),Or indicate a problem with the last data sent to the host(The host refused to respond,带RST标志的TCP报文段为复位报文段)
SYN(同步位):在建立连接时使用,用来同步序号.(A想和BRequest to establish connection status SYN=1 同步位)
FI N (断开位):通知对方本端要关闭连接了,标记数据是否发送完毕(A和B已经断开连接 FIN=1)窗口大小:表示现在允许对方发送的数据量.(也就是告诉对方,从本报文段的确认号开始允许对方发送的数据量,达到此值,需要ACK确认后才能再继续传送后面数据)
校验和:提供额外的可靠性紧急指针:标记紧急数据在数据字段中的位置
选项部分:其最大长度可根据TCP首部长度进行推算.(TCP首部长度用4位表示,选项部分最长为:(2^4-1)*4-20=40字节)
TCP3次握手(重点)
注释:
- Seq=x //序列号
- SYN=1 //同步位,Indicates that sent to another computerTCP数据包,请求在它们之间建立连接.
- ack=x+1 //确认号
- ACK=1 //确认位,
当PC1想和PC2建立起连接,Write connection information to the message
第一次握手:
客户端给服务器发送一个SYN报文(在TCP标头中SYN=1的TCP/IP数据包),该段中包含客户端的初始序列号Seq=x.
第二次握手:
服务器返回客户端SYN+ACK报文(在TCP标头中SYN=1,ACK=1的TCP/IP数据包),This segment contains the server's initial serial numberSeq=y,同时用ack=x+1to indicate that the client has been receivedSYN段(ACK数据包是任何确认收到一条消息或一系列数据包的TCP数据包)
第三次握手:
客户端给服务器响应一个ACK报文(在TCP标头中ACK=1的TCP/IP数据包)该网段中ack=y+1to indicate that it has been received from the serverSYN段,Seq=x+1
四次挥手
TCP超时重传
超时重传是TCP协议保证数据可靠性的另一个重要机制,其原理是在After a certain data is sent, one is opened 计时器 ,在一定时间内如果没有得到发送的数据报的ACK 报文 ,那么就重新发送数据,直到发送成功为止. TCP 可靠性中最重要的一个机制是处理数据超时和重传.
UDP协议
UDP特性
- 工作在传输层
- 提供不可靠的网络访问
- 非面向连接协议
- 有限的错误检查
- 传输性能高
- 无数据恢复特性
边栏推荐
- Autoware--北科天绘rfans激光雷达使用相机&激光雷达联合标定文件验证点云图像融合效果
- spark source code - task submission process - 5-CoarseGrainedExecutorBackend
- Spark source code - task submission process - 6-sparkContext initialization
- 通过单总线调用ds18b20的问题
- D41_缓冲池
- spark源码-任务提交流程之-5-CoarseGrainedExecutorBackend
- dsf5.0新建页面访问时重定向到首页的问题
- Remembering my first CCF-A conference paper | After six rejections, my paper is finally accepted, yay!
- spark源码-任务提交流程之-3-ApplicationMaster
- Configuration of TensorFlow ObjecDetectionAPI under Anaconda3 of win10 system
猜你喜欢
账号与权限管理
传输层协议(TCP3次握手)
[Day5] Soft and hard links File storage, deletion, directory management commands
Getting Started 04 When a task depends on another task, it needs to be executed in sequence
什么?CDN缓存加速只适用于加速静态内容?
[Day1] (Super detailed steps) Build a soft RAID disk array
正则表达式小实例--验证邮箱地址
TCP/IP四层模型
spark源码-RPC通信机制
【Day8】 RAID磁盘阵列
随机推荐
硬盘分区和永久挂载
VLAN详解及实验
[Day8] Commands involved in using LVM to expand
图片压缩失效问题
账号与权限管理
OpenCV3.0 is compatible with VS2010 and VS2013
[Day1] (Super detailed steps) Build a soft RAID disk array
The spark operator - repartition operator
Spark源码-任务提交流程之-6.2-sparkContext初始化-TaskScheduler任务调度器
【机器学习】1单变量线性回归
千亿IT运维市场,产品要凭实力说话
IJCAI 2022|Boundary-Guided Camouflage Object Detection Model BGNet
洞察互联网大趋势,读完这篇文章你就彻底了解中文域名
Hugo搭建个人博客
Unity3D中的ref、out、Params三种参数的使用
正则表达式小示例--获取重复最多的字符及其数量
添加新硬盘为什么扫描不上?如何解决?
idea 常用快捷键
单臂路由与三成交换机
vim的三种模式