## 4 P2P-Based Crowdsourcing Platform
### Routing Algorithms  
To process the incoming images with the P2P-based crowdsourcing platform, we use three routing algorithms named **Baseline**, **Centralized**, and **Distributed**. In the **Baseline** algorithm, for each arriving image (Img) we create a task which contains the image, a list of options of categories, and other data such as the time-to-live (TTL). The task is sent through the ISP to \(H\) peers. In Figure 2, the task flow between the ISP and the peers using the Baseline routing algorithm is colored in red. After receiving the task, the peers select a category from a list of options and send the responses to the server. Finally, the server checks whether the consensus reaches a given consensus threshold (\(C\)), that is, if at least a given percentage of the peers selected the same option for the image. If there is consensus, the image is marked as solved and stored in a database. Otherwise, the server selects a new set of \(H\) peers to send the images. This process is repeated at most three times. If there is no consensus for the image, then it is discarded. Moreover, if the TTL expires before completing the task processing, the image is discarded. In the second and third routing algorithms, named **Centralized** and **Distributed**, each STB--which is a peer in the network--has a global cache and a local cache memory to store the images. These cache memories are used to reduce the communication between the P2P network and the server. The local cache is used to store images processed by the peer and the global cache is used to store images assigned to the peer according to the space partition. The task flow between the ISP and the peers using the **Centralized** routing algorithm is colored in green in Figure 2. The server sends the image identifier (ID), the list of options, and the TTL to \(H\) peers. The peers receiving the message search for the image object inside the P2P network. That is, they search in the local cache and in the global cache memories of the peers using the communication protocol of the network. In the example in Figure 2, the blue peer receives a message from the server and searches for an image which is assigned to the red peer according to the space partition. First, the blue peer searches for the image ID in its local cache. If it is not found, using the communication protocol of the network, the blue peer sends the request to the green peer, which redirects it to the red peer. If the red peer has the image in its global cache, then the red peer retrieves the image and sends it back to the blue peer. Otherwise, the red peer requests the image from the server and after receiving the image, it is stored in the global cache and sent to the blue peer. Notice that the cache memories are useful for reducing the communication between the P2P network and the server at the cost of increasing the communication inside the P2P network. However, the communication latency inside the P2P network tends to be lower than the communication though the ISP. Subsequently, the blue peer selects an option from the list of options associated with the image and sends the result to the server. Finally, the server waits for all the \(H\) results associated with the image and checks whether the consensus is greater than or equal to \(C\). In the same way as in the Baseline, if the TTL is reached before completing the task processing, then the image is discarded. The third routing algorithm, named **Distributed**, executes the same steps as the Centralized algorithm until the blue peer receives the image \(j\) from the red peer. At this point, the blue peer selects an option for the image \(j\) and sends the result to the light blue peer. All the \(H\) peers processing the same \(j\) image send their results to the light blue peer, which will verify whether there is consensus for that image. Afterwards, it sends the result of the consensus (affirmative or negative) to the server.