Principles of Internet (complex network environment) voice and video text file transmission, P2P

Source: Internet
Author: User

The holiday is over, and I return to school again.

I have been doing WinForm before, and now I have finished it. Then I am going to apply it on the Internet. After a long period of exploration and study, I finally got a rough outline in my mind, understand the General Principles

An instant messaging software similar to QQ is used as an example.

There are a lot of chat program source code that can be downloaded on the Internet, including the QQ series of source code that implements file transmission and video speech, but there is basically a common feature, it is applicable only to LAN servers and rarely uses asynchronous processing.

However, in the actual network environment, many computers access the Internet through the Intranet gateway. The Gateway has a public IP address.

Communication between two computers on the Internet must be complex.

Taking instant messaging as an example, the software can be divided into a client and a server, which is actually a hybrid P2P architecture.

The server is located in a computer with a public IP address (server)

The client is located on other computers, including computers on the Intranet and on the Internet.

If all the information is transferred through the server, P2P cannot be implemented, and the server is under great pressure. For communications between the client and the server, because the server is on the public network, as long as the connection is requested from the client, NAT can be ignored. Communication between the two parties is not restricted by the network environment, both the client and the public network are the same.

However, if the two clients need to transmit a large amount of information such as audio and video files, it will be difficult for the server to bear if both are transferred through the service provider. The best way is through point-to-point connection.

The following are the main modules of Instant Messaging:

1. Text message Command Transmission

2. Video language Transmission

3. File Transfer

Obviously, the video audio file should be transmitted in P2P mode, which makes it easier for the server to record chat information.

The key issue here is P2P.

Suppose there is A client A and client B. If A direct connection is established with AB? There are several situations

1. Both parties on the internet can monitor the data or connection requests sent by either party to be accurate, which ensures direct point-to-point data output by AB.

2. One of the AB instances is located on the Internet and the other is located on the Intranet. As long as the computer in the Intranet knows that the IP address of another instance sends requests from the Intranet, it can also penetrate through NAT for point-to-point communication.

3. If AB is in different intranets and UDP protocol is used, it ensures P2P communication through UDP holes. Due to various complex NAT devices, such as various vrouters, the success rate of implementing P2P connections by AB is not high.

 

We can see that the key to P2P implementation lies in 3rd points.

Text messages are transferred through the server, and no P2P is involved. Video speech supports point-to-point transmission through UDP. Although UDP is unreliable, even if packet loss or error occurs during transmission, it is only a small part, here, we don't need to worry about the incorrect videos and voices. Even if a small part of the lost or wrong videos occur, the process is still in general.

Therefore, for Instant Messaging (including remote video conferencing) on the Internet, after reading a lot of relevant information, the following policies should be set for the main modules of Instant Messaging:

1. Text message transmission, including modifying the user's logon status and passing the emoticon, all of which are forwarded by the central server in the form of text (instructions ).

2. Video language transmission uses UDP protocol. When necessary, point-to-point transmission must penetrate NAT devices (such as routers) through UDP holes)

3. file transmission does not guarantee the complete transmission of files. If the two machines are in different intranets, the server will assist TCP holes. If the AB directly establishes a TCP connection, if a TCP connection cannot be established, it will be transferred through the server.

Such a policy can adapt to instant messaging in complex network environments. For a distributed system, such a policy should be universally applicable.

Think. NET platform, although there are mainly two main technologies of Remoting and Socket for network programming, but you can also read the book Remoting, there are still many shortcomings, not Socket flexibility, both have different advantages, you should choose to use different technologies or even a mix of the two based on different requirements.

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.