TCP相关

TCP连接的三次握手(不包含数据):

client -> server syn = j 
CLIENT_STATUS: SYN_SEND
server -> client ack = j + 1, syn = k
SERVER_STATUS: SYN_RECV
client -> server ack = k + 1
CLIENT_STATUS: ESTABLISHED[ɪˈstæblɪʃt]
SERVER_STATUS: ESTABLISHED[ɪˈstæblɪʃt]

三次握手是为了确认客户端与服务端之间链路是通的,第一次client向server发送syn包并将client状态置为SYN_SEND,此时服务端收到客户端syn包,返回一个ack包,值为syn包的值加一以让客户端知晓服务端已正常收到,服务端还需要知道客户端是否正常收到数据,于是发送自己的syn包,值为k,并将server状态置为SYN_RECV即收到客户端syn包。客户端首先验证ack包,并将服务端的syn包加一作为ack发回,客户端状态置为ESTABLISHED,服务端若成功收到客户端的ack包则将状态置为ESTABLISHED,连接成功。

  • SYN flood攻击 | 半连接队列 SYN_QUEUE | 全连接队列 ACCEPT_QUEUE

TCP断开连接四次挥手:

client -> server: FIN 
CLIENT_STATUS: ESTABLISHED -> FIN_WAIT_1
server -> client: ACK
SERVER_STATUS: ESTABLISHED -> CLOSE_WAIT
CLIENT_STATUS: FIN_WAIT_1 -> FIN_WAIT_2
server -> client: FIN ACK
SERVER_STATUS: CLOSE_WAIT -> LAST_ACK
client -> server: ACK
CLIENT_STATUS: FIN_WAIT_2 -> TIME_WAIT 2MSL后置为CLOSED断开连接
SERVER_STATUS: LAST_ACK -> CLOSED
tag(s): none
show comments · back · home
Edit with markdown