1.TCP and UDP difference:
1. whether the connection-oriented?
- By TCP three-way handshake to establish a connection.
- UDP is not a connection.
2. is reliable?
- TCP transport is reliable and ordered data
- UDP is only a best effort delivery, not necessarily reliable
3.UDP have better real-time application scenarios: SMS, multi-client, do not ask for information reliability, high efficiency requirements.
4. Each TCP is a point to point, UDP support a broader one, many-to-many.
5.TCP resource demanding, UDP requires less resources.
6.TCP oriented data streams, UDP datagram oriented.
2.TCP / IP implementations reliable transmission:
- Sequence number, ACK signals : transmission side to each data packet to be sent are marked with a sequence number. Recipient after receiving the data packet, an ACK to the transmitting signal comprises sending a transmission request sequence number of the next data packet.
- Retransmission timeout : When the sender does not receive ACK recipient in a predetermined time, the packet will be re-transmitted, and waits for the next retransmission time exponentially. After a certain number of retransmissions, if the ACK has not been received, it will be forced to disconnect.
- TCP connection management : three-way handshake, waving four times.
- In packet transmission data segment units : To establish the connection, i.e. the unit negotiation packets (the maximum message length (the MSS)) in the communication parties.
- Sliding window : a front end including not received data packets sent an ACK packet to be transmitted, and a rear end. After the receiver receives the ACK, the window is slid forward, stopped until data is unacknowledged.
- Flow control : TCP datagram header field to control the size of the sliding window.
- Congestion control : sending end congestion window active control data traffic. Slow start : to prevent the communicating parties start to send large amounts of data packets, the congestion window size is a start: 1MSS, each receives an ACK congestion window to expand twice, select the congestion window and sliding window when sending small data packets value. Congestion avoidance algorithm : slow start compared to the growth rate of the congestion window more slowly. Fast retransmit : When the ACK is not received within the specified time limit, then it is probably a problem with the network. In this case a congestion window is reduced, the slow start again.