Protocol core-core Version 3 » History » Revision 51
Revision 50 (Greg Burri, 08/02/2009 10:25 AM) → Revision 51/73 (Greg Burri, 08/02/2009 10:26 AM)
h1. Protocol core-core This page describes the protocol used by Aybabtu for network communication between cores. See source:application/Protos/core_protocol.proto for message details. !network_protocol.png! h2. Downloading thread threads 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. <pre> F : the list of all unfinished download C : A list of chunk candidates (empty at start) - Take the first file in F -> f. Loop : If the hash chunks of f are unknown : If there is already a peer asking for hashes : - Take the next file in F -> f. - continue Else - Ask the hashes to the source (see the message 'GetHashes'). For each chunk not downloaded and not being downloaded of f -> c : If c has a free peer : - Add c to C If C isn't empty : - Take the best chunk in C based on peer.downloadRate. If there is more than one best chunk then choose one randomly. - Grab the lock for the peer - Request the download (see the message 'GetChunk') - Take the first file in F -> f. Else : - Take the next file in F -> f. </pre> h2. h3. Updating peer to hash association This loop will periodically grab the _NumberOfChunkToUpdate_ first chunks and request to all other peers what chunk they have. 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. <pre> F : the list of all unfinished download C : list of latest chunk hashes sent Loop : Time.now -> t Empty C n : number of chunk = 0 While take the next file in F -> f If C.count >= 'NumberOfChunkToUpdate' : - Break If we know the hashes for f : For all chunks of f -> c : - Add c to C Else : - Break - Send the list of the chunk to everyone. (The received responses will be compared against C) - Wait 'TimeBetweenChunksUpdate' - (Time.now - t) </pre> h2. Parameters Most parameters will be stored as constants in their component. |_.Name|_.Value |_.Unit|_.Explanation/Comments| | _IMAliveFrequency_ | 0.1 | [Hz] | The message _IMAlive_ is sent each 10s. | | _ChunkSize_ | 33554432 | [Byte] | (32 MB) | | _LanSpeed_ | 52428800 | [Byte/s] | (50 MB/s) | | _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 | | _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. | | _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. | | _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. | | _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. | | _FindTimeout_ | 15 | [s] | A search request is abandoned after 15 seconds from the start of the request. See message _Find_. | | _GetHashesTimeout_ | 200 | [s] | Timeout for the message _GetHashes_. | | _HaveChunksTimeout_ | _TimeBetweenChunksUpdate_ = 10 | [s] | Timeout for the message _HaveChunks_. | | _GetEntriesTimeout_ | 10 | [s] | Timeout for the message _GetEntries_. | | _NbDownloadThread_ | 3 | - | Number of concurrent downloading thread. | | _BufferSize_ | 1048576 | [Byte] | (1 MB). This buffer is used when reading or writing a file. | | _TCPSocketBufferSize_ | 33554432 | [Byte] | (32 Mo). Used when data are received. See _QAbstractSocket::setReadBufferSize_. | | _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. | h2. Core <-> GUI