Try to rejoin DHT periodically after failures using exponential backoff.
[quix0rs-apt-p2p.git] / TODO
1 Add statistics gathering to the peer downloading.
2
3 Statistics are needed of how much has been uploaded, downloaded from
4 peers, and downloaded from mirrors.
5
6
7 Add all cache files to the database.
8
9 All files in the cache should be added to the database, so that they can
10 be checked to make sure nothing has happened to them. The database would
11 then need a flag to indicate files that are hashed and available, but
12 that shouldn't be added to the DHT.
13
14
15 Packages.diff files need to be considered.
16
17 The Packages.diff/Index files contain hashes of Packages.diff/rred.gz 
18 files, which themselves contain diffs to the Packages files previously 
19 downloaded. Apt will request these files for the testing/unstable 
20 distributions. They need to be dealt with properly by 
21 adding them to the tracking done by the AptPackages module.
22
23
24 Retransmit DHT requests before timeout occurs.
25
26 Currently, only a single transmission to a peer is ever attempted. If
27 that request is lost, a timeout will occur after 20 seconds, the peer
28 will be declared unreachable and the action will move on to the next
29 peer. Instead, try to resend the request periodically using exponential
30 backoff to make sure that lost packets don't delay the action so much.
31 For example, send the request, wait 2 seconds and send again, wait 4
32 seconds and send again, wait 8 seconds (14 seconds have now passed) and
33 then declare the host unreachable. The same TID should be used in each
34 retransmission, so receiving multiple responses should not be a problem
35 as the extra ones will be ignored. 
36
37
38 PeerManager needs to download large files from multiple peers.
39
40 The PeerManager currently chooses a peer at random from the list of 
41 possible peers, and downloads the entire file from there. This needs to 
42 change if both a) the file is large (more than 512 KB), and b) there are
43 multiple peers with the file. The PeerManager should then break up the 
44 large file into multiple pieces of size < 512 KB, and then send requests 
45 to multiple peers for these pieces.
46
47 This can cause a problem with hash checking the returned data, as hashes 
48 for the pieces are not known. Any file that fails a hash check should be 
49 downloaded again, with each piece being downloaded from different peers 
50 than it was previously. The peers are shifted by 1, so that if a peers 
51 previously downloaded piece i, it now downloads piece i+1, and the first 
52 piece is downloaded by the previous downloader of the last piece, or 
53 preferably a previously unused peer. As each piece is downloaded the 
54 running hash of the file should be checked to determine the place at 
55 which the file differs from the previous download.
56
57 If the hash check then passes, then the peer who originally provided the 
58 bad piece can be assessed blame for the error. Otherwise, the peer who 
59 originally provided the piece is probably at fault, since he is now 
60 providing a later piece. This doesn't work if the differing piece is the 
61 first piece, in which case it is downloaded from a 3rd peer, with 
62 consensus revealing the misbehaving peer.
63
64
65 Consider storing deltas of packages.
66
67 Instead of downloading full package files when a previous version of
68 the same package is available, peers could request a delta of the
69 package to the previous version. This would only be done if the delta
70 is significantly (>50%) smaller than the full package, and is not too
71 large (absolutely). A peer that has a new package and an old one would
72 add a list of deltas for the package to the value stored in the DHT.
73 The delta information would specify the old version (by hash), the
74 size of the delta, and the hash of the delta. A peer that has the same
75 old package could then download the delta from the peer by requesting
76 the hash of the delta. Alternatively, very small deltas could be
77 stored directly in the DHT.
78
79
80 Consider tracking security issues with packages.
81
82 Since sharing information with others about what packages you have
83 downloaded (and probably installed) is a possible security
84 vulnerability, it would be advantageous to not share that information
85 for packages that have known security vulnerabilities. This would
86 require some way of obtaining a list of which packages (and versions)
87 are vulnerable, which is not currently available.
88
89
90 Consider adding peer characteristics to the DHT.
91
92 Bad peers could be indicated in the DHT by adding a new value that is
93 the NOT of their ID (so they are guaranteed not to store it) indicating
94 information about the peer. This could be bad votes on the peer, as
95 otherwise a peer could add good info about itself.
96
97
98 Consider adding pieces to the DHT instead of files.
99
100 Instead of adding file hashes to the DHT, only piece hashes could be
101 added. This would allow a peer to upload to other peers while it is
102 still downloading the rest of the file. It is not clear that this is
103 needed, since peer's will not be uploading and downloading ery much of
104 the time.