Design network code and network code

Source: Internet
Author: User

Design network code and network code

 

The Protocol itself is a custom protocol for transportation and location over UDP. There are many reasons why I decided to use the custom protocol. First, the current task looks simple enough, so it is easier to build a custom protocol directly than to try to improve a current protocol. Second, custom protocols can minimize overhead and improve performance as much as possible. Finally, this is a good teaching practice.

 

TCP is a stream protocol. Every time you view a webpage, the TCP protocol is used to check emails or download files. Essentially, TCP establishes a two-way pipeline between two computers and tries its best to conceal the reliability and uncertainty of its underlying network.

 

UDP exposes many uncertainties. It uses a checksum to ensure that a corrupted data is not transmitted, but it does not try to mask the problem. If a vro decides to discard a data packet, the data will never be received. If an earlier data packet is delayed so that it arrives late, the data will be received in disorder.

 

The reason for using UDP is that UDP uses fewer resources and provides better performance. In essence, TCP is based on connections. Therefore, each remote device to communicate with must establish and maintain connections. If you plan to support a large number of devices, the overhead will be very high. In addition, TCP may also be slower, such as packet loss. At this time, TCP will try to fix the problem, but it takes time to recover it. In contrast, UDP only skips packet loss and continues to send subsequent updates. If you are pursuing performance and can cope with data loss, UDP is the top choice.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.