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