TCP Transmission Control Protocol: transport layer protocol
UDP User Datagram Protocol
, a reliable process to process communication protocol is a connection-oriented TCP
TCP provides full-duplex service, i.e., at the same time data can be bi-directional transmission
of no more than 1500 bytes TCP segment
the TCP packet a plurality of bytes is called segment
TCP segment encapsulated in an IP datagram
TCP segment header format
Source port number: port number corresponding to the sender
Destination port number: corresponding to the receiving end of the process, after the receiver receives the data segment to determine which application data to the process according to the port number
ID: byte number for each sending end, the receiving end so that the recombinant
No acknowledgment: a message acknowledgment transmitting end
Header length: It can be used to determine the byte length of the header portion of the data
Reserved: do not have to use
Control bits: The six have a very important role, TCP connection, transmission and disconnection are controlled by six command
URG: urgent pointer valid bit. 1 is on 0 is off, without caching directly to
PSH: rapid acceptance of transfer application layer. Need to go through the cache and a number of segments in attendance, sent directly to the application layer
SYN: request to establish a connection
FIN: disconnection.
ACK: Acknowledge bit
RST: notification to reconnect
Window size: acceptable for explaining the number of local data segments, the window size is variable
Checksum: used for error control
Urgent pointer: URG with use, effective when turned URG
TCP three-way handshake (TCP connection is established)
The first handshake: pc1 pc2 to send a request to establish a connection SYN connection
Second handshake: pc2 connection and sends an ACK request for connection acknowledgment to the SYN pc1
Third handshake: pc1 sends an ACK acknowledgment to pc2, to achieve connection
TCP handshake (disconnected)
The first handshake: pc1 transmission acknowledgment ACK and FIN disconnected to pc2
The second handshake: pc2 pc1 reply to a confirmation ACK
Third handshake: pc2 pc1 transmission and disconnects to an acknowledgment FIN ACK
Fourth handshake: pc1 pc2 sends a confirmation ACK
在TCP断开连接过程中,有一个半关闭状态。TCP一方客户端可以终止发送数据,但是仍然可以接受数据,称为半关闭
(1)客户端发送 FIN 报文段,半关闭了这个连接,服务器发送 ACK 报文段接受半关闭。
(2)服务器继续发送数据,而客户端只发送 ACK 确认,不再发送任何数据。
(3)当服务器已经把所有数据发送完毕时,就发送 FIN 报文段,客户再发送 ACK 报文 段,这样就关闭了 TCP 连接。
TCP常用端口号
端口号 协议 说明
21 FTP FTP服务器所开放的控制端口 20端口是ftp的数据连接21端口是ftp的控制连接
23 TELNET 明文 用于远程登录,可以远程控制管理目标计算机
25 SMTP 用于发送邮件
80 HTTP 超文本传输协议 https 443安全
110 POP3 用于邮件的接受
143 IAMP 用于发送邮件
22 SSH 密文远程登陆
UDP协议
UDP is a connectionless, does not guarantee the reliability of the transport layer protocol, the sender does not care whether that is sending data to reach the target host, such as whether a data error, the host received the data will not tell the sender whether the received data it's to protect the reliability of the upper-layer protocols. Since UDP has the disadvantage, why the process is also willing to use it? Because UDP also has the advantage of a simple UDP header structure, when data transmission achieves the lowest cost, if the process wants to send a short message without regard to reliability, you can use UDP. When using UDP to send a short message, much less than in the interaction between the sender and receiver use TCP.
UDP header format
Source Port Number: used to identify the end of data transmission process, and the port number of the TCP protocol similar.
Destination port number: used to identify the data receiving end processes, and the port number of the TCP protocol similar.
UDP length: to indicate the total length of the UDP, headed portion plus data.
Checksum: error check for completion of UDP data, its TCP checksum calculation and the like. This is the only reliable mechanism for UDP provides.
Their common feature UDP port number
Port Protocol Description
69 TFTP Trivial File Transfer Protocol
111 RPC Remote Procedure Call
123 NTP Network Time Protocol