The download server provides download services for every user who sends a download request. The download service is point-to-point and one-to-one. BitTorrent works in different ways, it is the part of content contributed by each node. It serves several nodes at the same time until all user downloads are completed.
Generally, if there are too many people downloading HTTP/FTP, the server can easily reach the bottleneck and become slow. BitTorrent downloads feature that the more people download, the more seeds are provided, and the more seeds are available, the faster the download speed. This is where he bt is.
The BitTorrent protocol is in the TCP/IP application layer. According to the BitTorrent protocol, A. torrent file, that is, a seed file, or"Seed". Contains tracker information and file information.Tracker InformationThe address of the tracker server to be downloaded and the settings for the tracker server,File InformationIt is generated based on the calculation of the target file. The file is virtualized into blocks of the same size. The block size must be 2 K to the integer power. The seed contains the index information and hash Verification Code of each block, that is, the index.
When downloading, parse the seed file to get the tracker address and connect to the tracker server. The tracker server responds to the download request and provides the addresses of other download recipients. The downloader connects to another Downloader. Based on the seed file, the other party informs the other party that they already have blocks, and then exchanges the data that the other party does not have. For each downloaded part, you need to calculate the hash verification code of the downloaded part and compare it with the hash verification code in the seed file. If the hash verification code is the same, it indicates that the block is correct. If the hash verification code is different, you need to download the block again. Ensure that each block is correct.
It is interesting to see thatEach node preferentially selects the least chunks in the system to download.And those blocks that are relatively large in the system are downloaded at the end. In this way, the entire system tends to be in a better state. If you download the most chunks, these chunks will be distributed more and more in the system, and those with fewer chunks in the system will become fewer and fewer. Finally, some nodes no longer have the blocks required by other nodes, so the throughput of the entire system will decrease.
Original article: http://blog.csdn.net/hongchangfirst/article/details/26845699
Author: hongchangfirst
Hongchangfirst home: http://blog.csdn.net/hongchangfirst
What is BitTorrent?