传输层:①数据分段 服务0-65535,静态端口号(著名端口号) 1-1023,动态端口号
②1024-65535,通过端口号区分不同的服务
MSS最大段长度 1500B
MTU最大传输单元 1480B (多了20B报头)
HTTPS 443, talent 520
网络层:通过IP地址进行逻辑寻址
数据链路层:①MAC媒介访问控制层
②LLC逻辑链路层 为上层提供FCS校验
物理层:定义电器电压接口规范光学特性
TCP面向连接的可靠传输协议 面向连接体现在三次握手 可靠体现在确认,重传,排序,流控(滑动窗口)
UDP非面向连接的不可靠传输协议
8bite一个字节 16比特
报头要记住
TCP三次握手
Seq序列号:记录发送次数
Ack=seq+1
MTU有最大传输单元 报头:做记录的作用
TCP
- BIt ack number确认序列号 ack=seq+1
ack包 置位
保留:给qos做预留,可以插队
URG:为1时,为紧急数据,可以先走做优先处理
ACK(为0时是没有建立):确认ACK,TCP规定,建立后所在报文的传输都为1
PSH希望立刻收到对方的应答:推送PSH 立刻收到相应时为1
RST 为1时出错,确认重连排序流控
SYN 同步序列号(序列号是记录发送次数的)
FIN 断开请求 释放连接的,FIN=1时 发完
窗口:告诉你可以发几个包 不用再重传
校验和 校验首部和数据
紧急指针 本段报文里的紧急字节从哪到哪
选项 (可以加密什么的)
正在建立会话,但是包丢了,服务器断开请求 TIMW WAIT状态
用户端继续向server端发送ACK报文
保证让迟来的TCP报文段有足够的时间被识别和丢弃,连接结束了,网络中的延迟报文页应该被丢掉,以免影响立刻建立的新连接
为什么三次握手?因为TCP可靠传输协议,可以保证数据可靠传输又能提高传输速率
“三次握手” 的目的是 “为了防止已失效的连接请求报文段突然又传送到了服务端,因而产生错误”
网络延迟没有收到服务器发的确认包 就重发 延迟的SYN又发送给服务端 客户端误以为这是新的同步报文又回一个ACK
SCTP:是一种传输协议,是TCP与UDP协议各自优点的组合后的产物。
SCTP和TCP的区别:
1. TCP是以字节为单位传输的,SCTP是以数据块为单位传输的
2. TCP通常是单路径传输,SCTP可以多路径传输
3. TCP是单流有序传输,SCTP可以多流独立有序/无序传输
4. TCP连接的建立过程需要三步握手,SCTP连接的建立过程需要四步握手
5. SCTP有heartbeat机制来管理路径的可用性