跳到主要内容

TCP

Format

Flags

FlagNameDescription
CWRCongestion Window Reduced拥塞窗口减小
ECEECN-Echo
URGUrgent表示紧急指针字段有效
ACKAcknowledge表示确认字段有效
PSHPush要求将缓冲的数据推送到接收应用程序
RSTReset重置连接
SYNSynchronize
FINFinish来自发送方的最后一个数据包

Lifecycle

TCP Handshake

TCP Close

TCP Socket Status

StateEndpointDescription
LISTENServerWaiting for a connection request from any remote TCP end-point.
SYN-SENTClientWaiting for a matching connection request after having sent a connection request.
SYN-RECEIVEDServerWaiting for a confirming connection request acknowledgment after having both received and sent a connection request.
ESTABLISHEDServer and clientAn open connection, data received can be delivered to the user. The normal state for the data transfer phase of the connection.
FIN-WAIT-1Server and clientWaiting for a connection termination request from the remote TCP, or an acknowledgment of the connection termination request previously sent.
FIN-WAIT-2Server and clientWaiting for a connection termination request from the remote TCP.
CLOSE-WAITServer and clientWaiting for a connection termination request from the local user.
CLOSINGServer and clientWaiting for a connection termination request acknowledgment from the remote TCP.
LAST-ACKServer and clientWaiting for an acknowledgment of the connection termination request previously sent to the remote TCP (which includes an acknowledgment of its connection termination request).
TIME-WAITServer or clientWaiting for enough time to pass to be sure that all remaining packets on the connection have expired.
CLOSEDServer and clientNo connection state at all.

QA

TCP最大连接数?

TCP/UDP协议的设计,端口号只有16位,所以只有2^16=65536个端口。 理论上讲,客户端能够建立65535个连接,服务端能建立2^32x2^16=2^48个连接。 实际上,这个数量受以下因素影响:

  • 带宽
  • 服务器性能
    • 最大文件数