Project

General

Profile

Protocol core-core Version 3 » History » Version 37

Greg Burri, 07/09/2009 10:12 PM

1 1 Greg Burri
h1. Protocols
2
3
This page describes the protocols used by Aybabtu for network communication between cores and between core and GUI.
4
5 7 Greg Burri
h2. Core <-> Core
6 1 Greg Burri
7 22 Greg Burri
See source:protos/network_protocol.proto for message details.
8 21 Greg Burri
9 31 Greg Burri
h3. Downloading threads
10 29 Greg Burri
11
There is _NbDownloadThread_ threads. Each thread will choose a free chunk and download it.
12 23 Greg Burri
There is no more than one downloading from B to A. A peer which a download is active is setted as not free.
13
14
<pre>
15 27 Greg Burri
F : the list of all unfinished download
16
C : A list of chunk candidates (empty at start)
17
18 33 Greg Burri
- Take the first file in F -> f.
19
Loop :
20
   If the hash chunks of f are unknown :
21 37 Greg Burri
      If there is already a peer asking for hashes :
22
         - Take the next file in F -> f.
23
         - continue
24
      Else
25
         - Ask the hashes to the source (see the message 'GetHashes').
26 1 Greg Burri
   For each chunk not downloaded or not being downloaded -> c :
27 27 Greg Burri
      If c has a free peer :
28 37 Greg Burri
         - Add c to C
29 27 Greg Burri
   If C isn't empty :
30 30 Greg Burri
      - Take the best chunk in C based on peer.downloadRate.
31 1 Greg Burri
        If there is more than one best chunk then choose one randomly.
32
      - Grab the lock for the peer
33
      - Request the download   
34 33 Greg Burri
      - Take the first file in F -> f.
35 34 Greg Burri
   Else :
36 33 Greg Burri
      - Take the next file in F -> f.
37 23 Greg Burri
</pre>
38
39 36 Greg Burri
h3. Updating peer to hash association thread
40 23 Greg Burri
41 36 Greg Burri
This thread will periodically grab the _NumberOfChunkToUpdate_ first chunks and request to all other peers what chunk they have.
42 1 Greg Burri
43
If there is no chunk available the message will be send without hashes.
44 37 Greg Burri
45
<pre>
46
F : the list of all unfinished download
47
C : list of latest chunk hashes sent
48
49
Loop :
50
   Time.now -> t
51
   Empty C
52
   n : number of chunk = 0
53
   While take the next file in F -> f
54
      If C.count >= 'NumberOfChunkToUpdate' :
55
         - Break
56
      If we know the hashes for f :
57
         For all chunks of f -> c :
58
            - Add c to C
59
      Else :
60
         - Break
61
   - Copy C to C_latest
62
   - Send the list of the chunk to everyone. (The received responses will be compared against C)
63
   - Wait 'TimeBetweenChunksUpdate' - (Time.now - t)
64
         
65
</pre>
66 23 Greg Burri
67 8 Greg Burri
h3. Parameters
68
69 10 Greg Burri
Most parameters will be stored as constants in their component.
70
71 9 Greg Burri
|_.Name|_.Value |_.Unit|_.Explanation/Comments|
72 19 Greg Burri
| _IMAliveFrequency_ | 0.1 | [Hz] | The message _IMAlive_ is sent each 10s. |
73 14 Greg Burri
| _ChunkSize_ | 33554432 | [Byte] | (32 MB) |
74
| _LanSpeed_ | 52428800 | [Byte/s] | (50 MB/s) |
75 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 |
76
| _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. |
77
| _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. | 
78 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. |
79 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. |
80 19 Greg Burri
| _FindTimeout_ | 15 | [s] | A search request is abandoned after 15 seconds from the start of the request. See message _Find_. |
81 25 Greg Burri
| _GetHashesTimeout_ | 200 | [s] | Timeout for the message _GetHashes_. |
82 19 Greg Burri
| _GetChunkTimeout_ | 10 | [s] | Timeout for the message _GetChunk_. |
83
| _HaveChunksTimeout_ | _TimeBetweenChunksUpdate_ = 10 | [s] | Timeout for the message _HaveChunks_. |
84 1 Greg Burri
| _GetEntriesTimeout_ | 10 | [s] | Timeout for the message _GetEntries_. |
85 23 Greg Burri
| _NbDownloadThread_ | 3 | - | Number of concurrent downloading thread. |
86 35 Greg Burri
| _BufferSize_ | 1048576 | [Byte] | (1MB). This buffer is used when reading or writing a file. |
87 26 Greg Burri
| _TCPSocketBufferSize_ | 33554432 | [Byte] | (32Mo). Used when data are received. See _QAbstractSocket::setReadBufferSize_. |
88 8 Greg Burri
89 7 Greg Burri
h2. Core <-> GUI