-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02-show.html
77 lines (75 loc) · 3.99 KB
/
02-show.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!doctype html>
<head>
<title>BitTorrent协议实现</title>
<link rel="stylesheet" href="skin/skin.css">
<style>
body {
font: 12px "Myriad Pro", "Lucida Grande", sans-serif;
width: 80%;
margin: auto auto auto auto;
}
#description{
font-size: 1.3em;
}
</style>
<script src="jquery-3.4.1.min.js"></script>
<script src="flowplayer.min.js"></script>
</head>
<body>
<h1>BitTorrent协议实现</h1>
<div id="description">
<ul>实现协议细节:
<li><a href="https://wiki.theory.org/index.php/BitTorrentSpecification">BitTorrentSpecification(自备梯子)</a></li>
</ul>
<p>场景:点对点下载任意文件</p>
<ul>
<li>在点对点的网络中,每个点是一个主机</li>
<li>每个主机即可作为客户端,又可作为服务端</li>
<li>客户端从其他节点处下载数据</li>
<li>服务端根据客户端的请求发送数据片段</li>
</ul>
<p>实现主要细节</p>
<ul>
<li>使用了UDP和HTTP协议和tracker沟通:
<ul>
<li>tracker是一个独立存在的服务器,他的作用是记录一份文件被哪些用户所下载</li>
<li>有两种类型的tracker存在,一种是提供http访问的tracker,一种是基于udp访问的tracker,提供udp的访问方式是降低服务器的维护开销,但据我获取到的tracker来看,还是有很多trakcer提供了http的访问方式</li>
<li>客户端下载时,访问tracker获得已经下载该文件的ip地址列表</li>
</ul>
</li>
<li>使用TCP完成文件的下载:
<ul>
<li>将文件切分成若干数据片段</li>
<li>从tracker获取到的ip地址所对应的主机里,存有已经完全下载或者下载了一些的数据片段</li>
<li>下载时开多线程访问主机来进行数据的下载</li>
<li>下载简单的流程是这样的:问一台主机,有没有这个数据片段,如果有就请求下载该片段,持续这个过程,直到文件所有片段都被下载好</li>
</ul>
</li>
<li>从Bittorrent软件中完成了文件的下载</li>
</ul>
</div>
<h2>演示1-作为客户端从bittorrent客户端下载文件</h2>
<div class="flowplayer" data-swf="flowplayer.swf" data-ratio="0.4167">
<video>
<source type="video/mp4" src="https://listmyproject-video.oss-cn-shenzhen.aliyuncs.com/02-bittorrent/%E6%BC%94%E7%A4%BA1-%E4%BB%8Ebittorrent%E5%AE%A2%E6%88%B7%E7%AB%AF%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6.mp4">
</video>
</div>
<h2>演示2-作为服务端的实现</h2>
<div class="flowplayer" data-swf="flowplayer.swf" data-ratio="0.4167">
<video>
<source type="video/mp4" src="https://listmyproject-video.oss-cn-shenzhen.aliyuncs.com/02-bittorrent/%E6%BC%94%E7%A4%BA2-%E4%BB%8E%E4%BB%A3%E7%A0%81%E7%A4%BA%E4%BE%8B%E4%B8%AD%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6.mp4">
</video>
</div>
<h2>演示3-作为客户端从Bittorrent中一次下载多个文件</h2>
<div class="flowplayer" data-swf="flowplayer.swf" data-ratio="0.4167">
<video>
<source type="video/mp4" src="https://listmyproject-video.oss-cn-shenzhen.aliyuncs.com/02-bittorrent/%E6%BC%94%E7%A4%BA3-%E5%A4%9A%E6%96%87%E4%BB%B6%E4%B8%8B%E8%BD%BD.mp4">
</video>
</div>
<h2>演示4-作为服务端的实现,允许客户端下载多个文件</h2>
<div class="flowplayer" data-swf="flowplayer.swf" data-ratio="0.4167">
<video>
<source type="video/mp4" src="https://listmyproject-video.oss-cn-shenzhen.aliyuncs.com/02-bittorrent/%E6%BC%94%E7%A4%BA4-%E6%94%AF%E6%8C%81client%E4%B9%8B%E9%97%B4%E5%A4%9A%E6%96%87%E4%BB%B6%E4%B8%8B%E8%BD%BD.mp4">
</video>
</div>
</body>