Protocol core-core Version 3 » History » Version 53
Greg Burri, 08/02/2009 01:17 PM
1 | 47 | Greg Burri | h1. Protocol core-core |
---|---|---|---|
2 | 1 | Greg Burri | |
3 | 46 | Greg Burri | This page describes the protocol used by Aybabtu for network communication between cores. |
4 | 1 | Greg Burri | |
5 | 49 | Greg Burri | See source:application/Protos/core_protocol.proto for message details. |
6 | 1 | Greg Burri | |
7 | 21 | Greg Burri | !network_protocol.png! |
8 | 43 | Greg Burri | |
9 | 51 | Greg Burri | h2. Downloading thread |
10 | 29 | Greg Burri | |
11 | 39 | Greg Burri | There is _NbDownloadThread_ threads. Each thread will choose a free chunk and download it. A peer cannot have more than one connection per other peer. A peer which a download is active is set as not free. |
12 | 23 | Greg Burri | |
13 | <pre> |
||
14 | 27 | Greg Burri | F : the list of all unfinished download |
15 | C : A list of chunk candidates (empty at start) |
||
16 | |||
17 | 33 | Greg Burri | - Take the first file in F -> f. |
18 | Loop : |
||
19 | If the hash chunks of f are unknown : |
||
20 | 37 | Greg Burri | If there is already a peer asking for hashes : |
21 | - Take the next file in F -> f. |
||
22 | - continue |
||
23 | Else |
||
24 | - Ask the hashes to the source (see the message 'GetHashes'). |
||
25 | 41 | Greg Burri | For each chunk not downloaded and not being downloaded of f -> c : |
26 | 27 | Greg Burri | If c has a free peer : |
27 | 37 | Greg Burri | - Add c to C |
28 | 27 | Greg Burri | If C isn't empty : |
29 | 30 | Greg Burri | - Take the best chunk in C based on peer.downloadRate. |
30 | 1 | Greg Burri | If there is more than one best chunk then choose one randomly. |
31 | - Grab the lock for the peer |
||
32 | 42 | Greg Burri | - Request the download (see the message 'GetChunk') |
33 | 33 | Greg Burri | - Take the first file in F -> f. |
34 | 34 | Greg Burri | Else : |
35 | 33 | Greg Burri | - Take the next file in F -> f. |
36 | 23 | Greg Burri | </pre> |
37 | |||
38 | 51 | Greg Burri | h2. Updating peer to hash association |
39 | 23 | Greg Burri | |
40 | 50 | Greg Burri | This loop will periodically grab the _NumberOfChunkToUpdate_ first chunks and request to all other peers what chunk they have. |
41 | 1 | Greg Burri | |
42 | 40 | Greg Burri | If there is no chunk available the message will be send without hashes. This message is also used to know the peer on the network. |
43 | 37 | Greg Burri | |
44 | <pre> |
||
45 | F : the list of all unfinished download |
||
46 | C : list of latest chunk hashes sent |
||
47 | |||
48 | Loop : |
||
49 | 53 | Greg Burri | - Empty C |
50 | t : Time.now |
||
51 | 37 | Greg Burri | n : number of chunk = 0 |
52 | While take the next file in F -> f |
||
53 | If C.count >= 'NumberOfChunkToUpdate' : |
||
54 | - Break |
||
55 | If we know the hashes for f : |
||
56 | For all chunks of f -> c : |
||
57 | - Add c to C |
||
58 | Else : |
||
59 | - Break |
||
60 | - Send the list of the chunk to everyone. (The received responses will be compared against C) |
||
61 | 1 | Greg Burri | - Wait 'TimeBetweenChunksUpdate' - (Time.now - t) |
62 | 37 | Greg Burri | |
63 | </pre> |
||
64 | 23 | Greg Burri | |
65 | 46 | Greg Burri | h2. Parameters |
66 | 8 | Greg Burri | |
67 | 10 | Greg Burri | Most parameters will be stored as constants in their component. |
68 | |||
69 | 9 | Greg Burri | |_.Name|_.Value |_.Unit|_.Explanation/Comments| |
70 | 19 | Greg Burri | | _IMAliveFrequency_ | 0.1 | [Hz] | The message _IMAlive_ is sent each 10s. | |
71 | 14 | Greg Burri | | _ChunkSize_ | 33554432 | [Byte] | (32 MB) | |
72 | | _LanSpeed_ | 52428800 | [Byte/s] | (50 MB/s) | |
||
73 | 17 | Greg Burri | | _TimeRecheckChunkFactor_ | 4 | - | If the time to download a chunk exceeds _TimeRecheckChunkFactor_ * _ChunkSize_ / _LanSpeed_ the peers are rescanned to choose a better one (better download rate). For example : 4 * 32 / 50 = 2.6 second | |
74 | | _SwitchToAnotherPeerFactor_ | 1.5 | - | During the recheck of the peers to choose a better one the other download rate must be above the current * 1.5. | |
||
75 | | _DownloadRateValidTime_ | 1500 / _LanSpeed_ = 300 s | [s] | (5 min). The download rate of a peer is only valid during this time after its last update. After that its rate is set to the maximum. | |
||
76 | 15 | Greg Burri | | _TimeBetweenChunksUpdate_ | 500 / _LanSpeed_ = 10 s | [s] | Each 10 s a daemon will scan the _NumberOfChunkToUpdate_ first chunks from the first queued downloads to know which peer has which chunk. | |
77 | 20 | Greg Burri | | _NumberOfChunkToUpdate_ | 100 * _LanSpeed_ / _ChunkSize_ = 156 | - | The first 156 hash chunks (3 kB) will by send periodically to each peer. See message _HaveChunks_ in the proto file. | |
78 | 19 | Greg Burri | | _FindTimeout_ | 15 | [s] | A search request is abandoned after 15 seconds from the start of the request. See message _Find_. | |
79 | 25 | Greg Burri | | _GetHashesTimeout_ | 200 | [s] | Timeout for the message _GetHashes_. | |
80 | 19 | Greg Burri | | _HaveChunksTimeout_ | _TimeBetweenChunksUpdate_ = 10 | [s] | Timeout for the message _HaveChunks_. | |
81 | 1 | Greg Burri | | _GetEntriesTimeout_ | 10 | [s] | Timeout for the message _GetEntries_. | |
82 | | _NbDownloadThread_ | 3 | - | Number of concurrent downloading thread. | |
||
83 | 45 | Greg Burri | | _BufferSize_ | 1048576 | [Byte] | (1 MB). This buffer is used when reading or writing a file. | |
84 | | _TCPSocketBufferSize_ | 33554432 | [Byte] | (32 Mo). Used when data are received. See _QAbstractSocket::setReadBufferSize_. | |
||
85 | | _TCPPeerConnectionKeepAlive_ | 600 | [s] | (10 min). There's can be one or more connection to a certain peer, these connections are kept alive for a period of time. For each known peer there is a pool of connection. | |