Use python-debian's new debian package instead of debian_bundle
[quix0rs-apt-p2p.git] / docs / debaday.html
1 <div class="entry">
2
3 <p><strong>Article submitted by Cameron Dale. Guess what? We still need
4 you to <a href="http://debaday.debian.net/contribute/">submit good
5 articles about software you like</a>!</strong></p>
6
7 <p>Do you want to help out the Debian (or Ubuntu) project with some
8 mirror bandwidth but don't know how? Do you want to contribute somehow
9 to Debian's infrastructure, but you're not a coder? Tired of getting
10 slow download speeds when the mirrors are overloaded after a new
11 release? Then Apt-P2P is for you.</p>
12
13 <p>After installing the apt-p2p package and making some minor changes to
14 apt's sources, all the files you download with apt (or aptitude,
15 synaptic, gnome-apt, etc...) will be shared with other users, and any
16 files you download will use other users (peers) to download from.
17 However, if no other users have the file you want there's no need to
18 worry, Apt-P2P will happily fall back to downloading directly from the
19 mirror so your download will not fail.<p>
20
21 <h4>How it works</h4>
22
23 <p>Apt-P2P is a daemon that runs in the background, responding to any
24 requests from apt for files to download, and sharing any downloaded
25 files with other users. The sharing is all done using HTTP, so it
26 operates as both a server for the requests from apt and other peers, and
27 as a client to download from other peers and mirrors. Also, if you go to
28 <a href="http://localhost:9977/">http://localhost:9977/</a> in your
29 browser on the machine Apt-P2P is running on, you will get a nice
30 statistical display of what it is doing.</p>
31
32 <p>The main operation of Apt-P2P is the maintenance of a
33 <a href="http://en.wikipedia.org/wiki/Distributed_hash_table">Distributed
34 Hash Table (DHT)</a> used to find and store peers to download from for
35 each file. Whenever you download a file, apt-2p will first lookup the
36 SHA1 hash of the file in the DHT. If it is found and has peers listed,
37 then the downloading will occur from the peers (if there are only 1 or 2
38 peers, the mirror is used as well to speed up the download). If it is
39 not found then the file is requested directly from the mirror. Once the
40 download is complete, a new value is added to the DHT using the SHA1
41 hash of the file as the key, and including your contact info, so that
42 other peers can then find you to download the file from.</p>
43
44 <p>That's just a brief overview, but there are many hidden details that
45 make things go smoother. For example, for larger files the SHA1 hashes
46 of pieces of the file are stored in the DHT as well, which allows
47 downloaders to break up large files among several peers to get better
48 download speeds (similar to BitTorrent). For more information, you can
49 go to the Apt-P2P home page:
50 <a href="http://www.camrdale.org/apt-p2p/">http://www.camrdale.org/apt-p2p/</a>.</p>
51
52 <h4>Comparison with other P2P programs</h4>
53
54 Other than <a href="http://debtorrent.alioth.debian.org/">DebTorrent<a>,
55 there aren't any other peer-to-peer downloaders available for apt. There
56 was <a href="http://sianka.free.fr/">apt-torrent<a>, but it was never
57 packaged in Debian, and now seems to be dead (no updates in 18 months).
58 Comparing Apt-P2P with DebTorrent, Apt-P2P:
59
60 <ul>
61 <li>Is faster at downloading from mirrors.</li>
62 <li>Uses much less memory and a little less CPU.</li>
63 <li>Can download almost all files (source files,
64 <kbd>Packages.bz2</kbd>, etc...) from peers, not just <kbd>.deb</kbd>
65 packages.</li>
66 <li>Works with only the information apt has, no need for other
67 files.</li>
68 <li>Doesn't require a new apt transport for communicating with apt.</li>
69 <li>Is more modular and easier to understand as it is based on existing
70 technologies (e.g. <a href="http://twistedmatrix.com">twisted<a>).</li>
71 </ul>
72
73 <h4>Setup</h4>
74
75 <p>Apt-P2P is available in testing (lenny) and unstable (sid), and will
76 be available in Intrepid for Ubuntu. It can be installed by
77 <kbd>aptitude install apt-p2p</kbd>.</p>
78
79 <p>First, it is <strong>VERY</strong> important to set up port
80 forwarding if your machine is behind a firewall or router/NAT. The
81 default port you need to forward is 9977, both UDP and TCP. More
82 information on how to determine if you are connectable can be
83 <a href="http://www.camrdale.org/blog/posts/May-10-2008/">found
84 here</a>.</p>
85
86 <p>Setting up apt to use Apt-P2P as a proxy is easy, especially if you
87 have used other proxy software (e.g. apt-proxy, apt-cacher, approx) in
88 the past. The configuration change is the same, simply adding a
89 <kbd>localhost:9977/</kbd> to the front of the entries in your
90 <kbd>/etc/apt/sources.list</kbd> file. For example, if you previously
91 had this:
92
93 <pre class="terminal"># Official
94 deb http://ftp.us.debian.org/debian etch main contrib non-free
95 deb-src http://ftp.us.debian.org/debian etch main contrib non-free
96
97 # Security Updates
98 deb http://security.debian.org/ etch/updates main contrib non-free
99 deb-src http://security.debian.org/ etch/updates main contrib non-free
100
101 # Unofficial
102 deb http://ftp.debian-unofficial.org/debian etch main contrib non-free restricted
103 deb-src http://ftp.debian-unofficial.org/debian etch main contrib non-free restricted
104
105 # Backports
106 deb http://www.backports.org/debian etch-backports main contrib non-free
107 deb-src http://www.backports.org/debian etch-backports main contrib non-free</pre>
108
109 <p>Then, if you only want to share the official and backported packages,
110 you would change it to this:</p>
111
112 <pre class="terminal"># Official
113 deb http://localhost:9977/ftp.us.debian.org/debian etch main contrib non-free
114 deb-src http://localhost:9977/ftp.us.debian.org/debian etch main contrib non-free
115
116 # Security Updates
117 deb http://security.debian.org/ etch/updates main contrib non-free
118 deb-src http://security.debian.org/ etch/updates main contrib non-free
119
120 # Unofficial
121 deb http://ftp.debian-unofficial.org/debian etch main contrib non-free restricted
122 deb-src http://ftp.debian-unofficial.org/debian etch main contrib non-free restricted
123
124 # Backports
125 deb http://localhost:9977/www.backports.org/debian etch-backports main contrib non-free
126 deb-src http://localhost:9977/www.backports.org/debian etch-backports main contrib non-free</pre>
127
128 <p>Then, run an <kbd>apt-get update</kbd> and start installing
129 packages.</p>
130
131 </div>