In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
How to analyze the principle of BitTorrent download, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
BitTorrent protocol.
BT, whose full name is BitTorrent, is a P2P software. When you download download, you are also providing upload upload for other users. Because people are "helping each other", they will not slow down the download speed as the number of users increases.
The following is the general sharing process such as ftp,http:
Here is the process for sharing with BitTorrent:
In fact, it is very similar to ED. The differences between ED and BT are as follows:
To connect an ED-- to a fixed server BT--, there is no fixed server, as long as the sharer makes the .torrent file of the shared file and publishes it.
The more people ED-- shares, the faster it will be? The more seed of BT-- seed, the faster the speed.
ED-- worldwide sharing BT-- group sharing (speed can be guaranteed)
ED-- knows that the user / sharer name is not displayed in the sharer's user name & Speed BT--.
Compared with other P2P software, BT has a unique place, it has an intermediate WEB server, which is the announce we filled in at the time of release. The server provides unified management of release, unlike other P2P software to look everywhere for those very unstable personal servers, which is relatively reassuring.
The greater role of the WEB server is that intranet users can do Send (the principle will be explained below), which can not be done by other software, but the downside is that announce cannot be downloaded when it crashes. You should know that the key to P2P downloading is to be popular, and announce stops for a while so that it has lost all popularity.
The role of .torrent
As we all know, if we want to download using BT, we have to download a .torrent file first. what exactly is this file?
First, announce records the location of the publisher, letting BT know which WEB server published it, then some file information, file name, directory name, length, etc., and finally the fragment length, and the fragment Sha1 check code. (BT divides the file into several fragments in order to continue uploading and file verification.), you can use WordPad to type the torrent file to have a look, that is, you know something. The garbled code behind is a fragment of Sha1 check code.
Start-continue the implementation of sha check
After BT opens a torrent file, you are asked to choose where to save the file. Then determine that the file does not exist, then create a new file, if it does, use the Sha1 check code to verify the file-the error is not downloaded yet, so you can continue to upload, but 128bit check, you can not slow down.
Get peer
Now that we know what to download, where can we download it? We need to find out who provides the upload. Here BT is implemented through the WEB server. First of all, BT will analyze torrent to get the following URL
Http://btfans.3322.org:6969/announce?info_hash=%CDg%D4%AD%96%9D%93%DB%E4%FFXA%C6%5D3O&peer_id=%A3E%E0%9BeB%90d&port=6882&uploadED=0&downloadED=0&left=19171922&event=startED
Http://BTfans.3322.org:6969/announce is the address of the publisher
Info_hash is the Sha check code of the info part of the torrent file, which is used by WEB to find the corresponding record in the release list
Peer_id is its own identity, it is the first eight digits of the Sha check of 12 0 and current time + global unique identification code (GUID), a total of 20 digits
Port, you provided the uploaded port.
IP your ip address. If not, the server will find it by itself.
How much uploadED downloadED have you uploaded and downloaded? the server can use it for traffic analysis.
Left, how many bytes do you have to download?
Event status, telling the server whether you are ready to start the download, stop it, or finish the download
The above operation is done once every 5 minutes by default, or set by the server.
What will the server do?
There is a track program in the server to manage these requests. After getting this string of code, you will use info_hash to find the list. If you find it, you can download it. I'm sorry if you can't find it. Then it will NatCheck your IP and Port so that you can know whether you are an intranet user or a co-network user (if you are an intranet user, it cannot be connected because it will connect to your server, of course your server does not have this port), and then the server returns the IP and port of all public network users who are now downloading the file, like d8:intervali1800e5eersld2:ip14:xxx.xxx.xx.xxx7eerid20:00180531904b7e3abdd74orti6881eeee
Interval 1800 tells BT how many seconds to query. This is 30 minutes (a bit too much). Finally, if you are a public network user, it will put your submitted IP and Port in the list corresponding to info_hash, so that others can find you.
download
After getting these peer IP, BT can find the corresponding IP download, BT will go to all the peer to find what they want to download, not necessarily to seed download. Every time BT finds a peer, it sets up a Socket to download, so the more people download it, the faster it will be.
The principle that intranet users can do Send
As mentioned above, the server will only return the ip of the public network, so how can private network users do Send? this is because BT is an actively connected software (even if you have already downloaded it, you will not actively connect with others) the following is a simulation process:
1. Private network users start to do seed
2 the server received the request, and no peer was returned because it was the first one.
3. A public network user submits a request. Since seed is a private network user, no peer is returned, waiting for download, but the server will put its IP in the list.
4. After the interval interval, the private network sends the request to the server to get the public network IP above.
5. Connect to the private network immediately after obtaining the public network IP
6 Public network users establish a connection and data transmission begins (note that it is a bit strange for public network users to act as servers and private network users as clients)
7 other intranet users go to the above public network users to download data
Therefore, intranet users must have public network users to participate in seed, otherwise other intranet users cannot download it. If all are intranet users, all connections will not be established, of course, this is a more extreme situation.
As can be seen above, private network users cannot connect with private network users, and other users cannot find you from the server, so they cannot actively connect to you. You can only find public network users from the server every 30 minutes to connect.
Since many Chinese users are intranet users (I haven't tried more than 10 peer from the server), it is true that intranet users use BT much slower than public network users.
The download principle of Thunderbolt:
Analysis of the principle of Thunderbolt download
The working principle of Xunlei is said to be that "multi-resource hyper-threading technology is based on grid principle and can effectively integrate server and computer resources that exist on the network." In fact, it is still the traditional download technology, but this kind of download technology comprehensively applies HTTP and FTP transfer protocol to divide the files into blocks and pieces, and can also divide the files and download them to different addresses; and in the process of these traditional downloads, it is interspersed with P2P technology, that is, a new hotlink technology. Generally speaking, the download of Thunderbolt has the following characteristics:
1. Download more points. Collect all download addresses on the Internet for multiple downloads. Other software such as Internet Express does not collect download addresses that contain usernames and passwords in the download address, but collect them like Thunderbolt and then use them for others. This is the "stealing chain", that is, stealing other people's links.
2. Use P2P download technology similar to BT. After Thunderbolt starts, it starts two threads Thunder behind the system. Exe and Issue. Exe, which can be seen in threads. These two threads, like BT, share files on the local hard disk for other Thunderbolt users to download.
3. Collect the resources provided by users. For example, when a user on a movie website gets a download address (A) and then downloads it with Xunlei, the download address will be sent to Xunlei's server; in another place, another user downloads the same movie on another website, and Xunlei's server gets another download address (B). The Xunlei server will gather the download address of the same file (AMague B) together to form a resource, and the two users who download the two movies with Xunlei will have four download points. When another user is ready to download the same movie in another place, Xunlei will compare it in the database, find out the same resources (other download points are originally collected), and provide them to the user who is going to download. The user will have multiple download points to download at the same time to achieve a rapid increase in speed.
Ex.: when a user gets a download address (A) on a movie website and downloads it with Xunlei, the download address will be collected to Xunlei's server.
In another part of the world, another user downloads the same movie on another website and gets another download address (B), which will be collected by Xunlei server. Then the Thunderbolt server will assemble the download address of the same file (Ameme B) together to form a resource. The two users who downloaded the two movies with Xunlei are also included. There will be four download points. And when there are users preparing to download the same movie in other places, Xunlei will compare it in the database, find out the same resources (other download points, that is, collected above), and provide them to the user who is going to download them. Then this user will have multiple download points to download at the same time, thus achieving a speed increase. Of course, this user can not just enjoy high-speed downloads, he will also upload that part of the data he downloaded (BT principle).
Therefore, when a user downloads with Xunlei, it will connect to the Thunderbolt server to find resources. If it is a popular file, Xunlei can return a large number of download points for this user to download. In order to achieve the improvement of download speed.
Principle of BT download
BT is one of the most popular download methods at present. Its full name is "BitTorrent" or "BT" in Chinese, but many friends jokingly call it "abnormal download". What is the reason for this?
As far as HTTP, FTP, PUB and other download methods are concerned, the file is generally put on the server first, and then transferred to each user's machine by the server. Its working principle is shown in figure 1. Therefore, if there are too many users downloading at the same time, it is bound to affect the download speed of all users, and if some users use multithreaded downloads, the impact on bandwidth will be even more serious. therefore, almost all download servers have restrictions on the number of users and the maximum download speed.
Obviously, for the above reasons, even if you are using a broadband network, it is usually difficult to reach the maximum download speed promised by the operator, which has something to do with the network, but it also has something to do with the limitations of the server. Because of this, BT download soon became a favorite of download fans.
The BT server implements file sharing through a pyramid scheme, and its working principle is shown in figure 2. For example, if the BT server divides a file into N parts, and four users, A, B, C and D, download it at the same time, BT will not download all the parts of the file completely from the server, but selectively download the downloaded parts from other users' machines according to the actual situation. For example, if A has downloaded part 1 and B has downloaded part 2, then C will download part 1 from A's machine and part 2 from B's machine. Of course, users A, B and D will also download the corresponding parts from C's machine at the same time, which greatly reduces the load on the BT server and speeds up the download speed of C. In other words, each computer participating in the download not only downloads files from other users' computers, but also provides downloads to other users, so the more users participate in the download, the higher the download speed.
This is the answer to the question about how to analyze the principle of BitTorrent download. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.