A Peer-to-Peer (P2P) network is a distributed solution which uses the resources of its own users. In these networks, each node uses the resources of other users and also has the capability to provide resources for other nodes [1, 2]. These networks have many applications, including file sharing, distributed processing and messages passing to other nodes which can cause many security problems [3, 4]. P2P networks are highly dependent on resources of their own users . Therefore, the infrastructure of a P2P network should encourage users for contributions as well as using the resources of other members. The behavior of using resources of others without giving anything in return is called free-riding . As a consequence, free-riders cause slower download times for contributing peers. Thus, it is an essential need for a P2P network to guarantee fair bandwidth allocation, where a peer receives bandwidth equal to what it contributes. Accordingly, the system will be able to guarantee a certain level of performance for contributing peers.
Fair bandwidth allocation in P2P networks is not an easy task that can be tackled simply. This is due to the nature of P2P networks in which there is no central entity that can control and arbitrate access to all resources, and to schedule fair allocation of bandwidth for a router. Moreover, in P2P networks there is no perception in advance regarding the amount of bandwidth resources available and peers cannot be relied upon to specify their own resources honestly . Although free-riding can be a deliberate act, many users may become freeloaders or infringe fairness for lack of a proper infrastructure .
Since Seeders 111For simplicity, we call nodes with all packets, Seeder and nodes without all packets, Leecher. These terminologies are taken from BitTorrent protocol. are in the network only for altruistic reasons, a fair network should be designed in a way to put most of the traffics on the shoulder of Leechers. In this way, instead of getting free downloads, more users are encouraged to contribute to the network. Also, by mitigating the work of Seeders, we encourage them to stay longer in the network. For this purpose, we propose an incentive method which provides a proper infrastructure for fairness in P2P networks. This enables us to protect both Leecher-to-Leecher and Leecher-to-Seeder transactions. In other words, we do not only focus on protecting Leechers against freeloaders, but our goal is to protect Seeders as well. Furthermore, we show that by getting help and combining the standard methodology in cryptography, i.e. RSA, we can secure our channels against line spying, next to providing a fair network.
The rest of the paper is organized as follows. In section II we review the existing work for providing fairness in P2P networks. Section III introduces our proposed approach and its respective components as an incentive approach to provide fairness in P2P networks. In section IV we elaborate our proposed approach by improving it with proper use of cryptography. In this section, we show how it is possible to protect communication channels as well. In section V we analyze the functionality of our proposed method through simulations. Finally, we conclude the paper in section VI.
Ii Related Work
Incentive-based systems usually consider some form of reward to encourage users for more cooperation. BitTorrent is one of the first major attempts which used incentive in its protocol . It proposed a tit-for-tat (TFT) mechanism in order to incentivize peers to contribute resources to the system and discourage free-riders. As an important benefit, TFT encourages peers for more contribution without the need for centralized infrastructures. However, one important challenge regarding BitTorrent is that the robustness of the system is questionable. This is due to the fact that many of the contributions for improving the performance are unnecessary and can be reallocated or refused while still improving performance for strategic users. As a result, there are always some peers who contribute more data to the system than others.
It was shown that a cetralized authority can improve the fairness in BitTorrent . In  and , the authors used BitTorrent infrastructure to build their own fairness models. The main idea is to incentivize seeder stay longer in the BitTorrent network. The authors argued that download bandwidth of a leecher is the sum of all its associated peers’ upload bandwidth, so redistribution of its associated peers’ upload bandwidth could manage the leecher’s download bandwidth. Although these approaches can help those peers who stay longer in the network get better download speed, in some cases they increase the overall download completion time.
Next to BitTorrent and its derivatives, there are other incentive methods which take an independent approach such as [13, 14, 15]. In , the authors mainly focused on locating free-riders and taking actions against them. They proposed a framework in which each peer monitors its neighbors, decides if they are free-riders, and takes appropriate actions. Moreover, their approach does not require any permanent identification of peers or security infrastructures for maintaining a global reputation system. The results revealed that their proposed framework is able to reduce the effects of free- riding and can, therefore, increase the performance of a P2P network. Although this is an interesting approach, it suffers from a low number of downloads by contributors which arise from false detection in determining free-riders. This will ultimately influence the performance.
In , the authors have proposed a Gnutella-like unstructured P2P file sharing network that utilizes free-riders to index files. This method is aimed to assist route query messages to destination peers. The authors suggested modifying a peer’s neighbor table construction so that a free-rider has a lot of non-freeloaders as its overlay neighbors, while a non-freeloader’s neighbors are mostly free-riders. Moreover, each peer also keeps information about its neighbors’ files so that when a peer receives a query, it can determine if its neighbor has the queried file, or needs to forward query messages to continue the search. The findings obtained from this approach showed that the proposed method is able to improve search efficiency. However, one important security threat regarding this approach is that the authors assumed that peers faithfully execute the client program so that they follow the protocol designed by the program to build their neighbor tables and to relay query messages. If an adversary hacks the program, then it will be able to change the protocol. In , the authors suggested the use if a new P2P file sharing scheme based on the repeated Public Good (PG) game model. They mostly focused on trust evaluation, repeated interactions, and iterative self-learning techniques. The idea is to induce all peers to share files as many as possible by incorporating a trust-based P2P mechanism. The simulation results showed that the proposed scheme is able to maintain system efficiency as high as possible respond to current network conditions for adaptive management.
Trust management systems are methods to establish word-of-mouth for P2P networks. This means that based on transactions between nodes, they evaluate a degree of trust for each node which is mostly used for establishing a fair network. Finding a malicious user from its neighbors is a selection problem. Methods such as fuzzy decision making [17, 18] and genetic-based algorithms  can be used to select the free-riders from multiple criteria. A successful trust management system that uses this approach is . The [21, 16] are other examples of trust management systems. EigenTrust is the name of an approach proposed In . This method uses an algorithm to decrease the number of downloads of inauthentic files in a P2P network that assigns each peer a unique global trust value, based on the peer’s history of uploads. For this purpose, the authors proposed a distributed and secure method to compute global trust values, based on power iteration. These values are then used by peers to select the peers from whom they download.
As a result, the network will be able to identify malicious peers and isolates them from the network. EigenTrust is able to decrease the number of inauthentic files on the network, even under a variety of conditions where malicious peers cooperate in an attempt to subvert the system. In 
, the authors have introduced an approach to predict a peer’s cooperation level, focusing on the cooperation induced by the P2P protocol rather than the cooperation that results from user behavior or bandwidth limitation. This method mainly focuses on live streaming applications. By investigating the correlation between a peer’s cooperation level, the authors tried to show that three centrality metrics, namely out-degree, out-closeness, and betweenness, are positively correlated with the cooperation level. Based on this, they proposed a non-linear regression model to measure peer’s out-degree in the recent past to predict its cooperation level value in the near future.
Iii The Proposed Method
In this section, we propose an incentive model which can be used in versatile infrastructures. In our presented model, we increase fairness for both Leechers and Seeders. At first, we define how two Leechers should exchange packets and further demonstrate the mechanism for Leecher-to-Seeder transactions.
Iii-a Protecting Leecher-to-Leecher Transactions
In this procedure, we aim to force Leechers to upload as much as they download from others. To this end, we consider and as two separate keys which are required by all nodes in the network. We define , for encryption and for decryption of data . Each node in the network is represented as , . If wants to encrypt data , it should use . Therefore, we define function for encryption of data with key . On the other hand, for to decrypt data , it is always required to use , we have for decryption of data with key .
Suppose and are two Leechers which want to exchange data and . In the first step, sends the query package at which it requests data from . After receiving , sends for to ask for data . Before sending , encrypts with . Accordingly, before sending , encrypts with .
When the encryption process completes, package will be sent to . The decryption procedure for getting requires , so must continue the transaction. After receiving and performing the encryption process, will send the package to . To complete this procedure, nodes and need and respectively to decrypt their downloaded data. The process of exchanging the keys is done by which sends the package to . Doing this, it forwards to . Accordingly, receiving , sends to . As a result, gets .
At this stage, both nodes receive their requested data and have the keys for decryption. Using and , nodes and extract and respectively.
It is important to be pointed out that, afte receiving , can leave the process without sharing with . Since we forced him to upload, economically we take away the incentives for betrayal. In real world applications, such behavior can even become disadvantageous. As nodes can mark them and refuse the future transactions. In Fig. 1, a better view of this process is demonstrated.
Iii-B Protecting Leecher-to-Seeder Transactions
To protect Seeders, we need to reduce their workloads by relegating the traffics to Leechers. In this way, we force Leechers to take responsibility for their downloads and engage them to upload process. As a result, Seeders by reducing their work are encouraged to stay longer in the network. This concept is first introduced in  with a P2P management system. In this work, we show that it is still possible to protect Seeders in an incentive model.
Suppose that and are in contact with , as the Seeder. Suppose sends to ask for and from . In the same way, sends for asking the same data from . After Seeder receives , it encrypt with . In the same way, after receiving , it encrypst with . After encryption, sends to send the encrypted data for and to send the encrypted data for .
For decryption process , both and need to obtain . In order to do this, can force them to cooperate and upload for each other. Therefore, to obtain , sends to upload for . Accordingly, sends to upload for . In this stage, both and shared their resources. For to obtain , sends to indicate is received and is allowed to share with . Node after receiving , sends to the key for .
For to receive the key, should apply for the same process. This means that after receiving , sends to indicate it has received from . After receiving , node sends in order to forward to . In the last step, and which acquired , and their keys, decrypt and .
Iv Improving the Basic Design
We can use the common protocols in cryptography to further improve our basic model in the previous section. In practice, by using symmetric key encryption, only one key is required for doing both process of encryption and decryption. As a result, we do not need to have two separate keys for each node. Also, we can further improve this method and protect communications against line spying. To this end, we use RSA algorithm  which requires two new keys for each node. Suppose Alice () and Bob () want to exchange data , . First, sends the query package to request from . After receiving , generates three different keys, , and .
The key is the symmetric key which can be used to encrypt and decrypt data . Keys and are used as a public and private key respectively. They are essential parameters in the algorithm. After generating the keys, sends query package to exchange its public key with . After receives the package , it follows the same pattern by generating as its symmetric key, as the public key and as private key of algorithm. As like as the previous procedure, is for encrypting and decrypting data . After the keys are generated,, sends to complete the public key exchange with .
Once the process of exchanging and finishes, encrypts data with . When encryption process completes, sends the query package to and forward the encrypted data to it. After receiving , encrypts data with . Once this process completes, sends to in order to deliver encrypted data to it.
In this stage, both nodes received their data. To exchange and , we use methodology to be able to protect them from line spying. To exchange and , at first uses to encrypt with and uses to send the encrypted key for . After receiving , uses to open the first, and then uses to receive data . To complete the transaction, sends to send the encrypted key for . As the last step, at first uses to open the , and then uses to receive data .
The above protocol is shown in Fig. 3. All data exchanges for both Leecher-to-Leecher and Leecher-to-Seeder, described in previous section should adapt and follow these steps. In this way, next to providing fairness for the network we can shield the communication channels as well.
V Analysis and simulation results
In this section, we evaluate the effectiveness and functionality of our proposed approach through simulation. For this purpose, we use a network similar to Bitorrent protocol. In this environment, we initially compare our method with a network which only relies on willingness on the users. In order to appropriately examine the effectiveness of our approach, we mainly focus on the evaluation propagation, fairness for Seeders, fairness for all nodes (Seeders and Leechers) and free-riding prevention. In the next step (see Section V-D), by introducing tit-for-tat for nodes, we compare our method with Bittorrent.
V-a Propagation of Packets
Initially, we examine the packet propagation among nodes in the overlay. For this purpose, at each time interval, we calculated the average of all packets in the network. This shows how much time does it take for the nodes to complete their downloads tasks.
For this experiment, we used a static network of 1000 nodes and initialised it with 10 Seeders. The data were divided into 100 smaller packets. Simulation stopped when all nodes in the network completed their downloads. The result is shown in Fig. 4. As it can be seen, we compared our method with the willingness of users. By forcing users to upload more, they used the extra resources and could complete their downloads sooner. The results clearly shows that our approach enables nodes to download more packets in a certain time period compared to other willingness categories.
V-B Fairness for Users
To measure fairness for Seeders, the most important factor is their number of uploads. Therefore, we examine the mean of all uploaded packets for them at each time interval. For this experiment, a dynamic network of 1000 nodes is used. In this scenario, we assumed that Leechers would simply leave the network after completing their downloads. We used 10 Seeders and distributed them in the network evenly. Moreover, the data were divided into 100 smaller packets. Simulation was stopped when all nodes finished their downloads and left the network. The result of this experiment can be seen in Fig. 5.
Even though our method showed better performance compared to its rivals (except in one case), but the difference is not significant. This is mainly because we used only 10 Seeders against 990 Leechers. As a result, most of the transactions were between Leechers. It is expected when Seeders have more opportunities to relegate their uploads, the result will be more transparent. We further examine this situation in Section V-D when we put our method against Bittorrent.
The overall average of uploads is useful to see how traffic is relegated from Seeders. But using overall uploads does not reveal fairness. To better understand the situation consider two pairs of nodes. One pair with (90, 10) uploads and the other pair with (50, 50) uploads. Even though both of them have the same mean, in the first pair, fairness is not served. Therefore, we have to use the variance of uploads. Variance shows to which extent nodes deviated their uploads from the mean of all uploads.
For this experiment we used a network of 100 nodes and 10 Seeders with 100 packets. We made sure that network is completely static so we could examine the behaviors of every node in the network. Simulation was running until all Leechers finished their downloads. As we can see in Fig. 6
, when less users are willing to share, most probably other users (mostly Seeders) get abused. This shows that when network does not implement a proper fairness mechanism, altruistic users are most vulnerable entities which suffer from such infrastructure. The result shows that as much as the willingness level decreases, the variance increases which is an indicator about the deviation from the mean of all uploads. In this experiment, our approach showed the minimum variance among other examined methods.
V-C Freer-riding Prevention
Another important issue that we examine is free-riding prevention. The only way that freeloaders can live in a network shielded with our method is 1- using optimistic-unchock222In optimistic-unchoke, Leechers always uploads for a random node without considering if it is uploading back. In this way, new nodes also get a chance to acquire some packet. This helps newcomers to engage in future transactions[Cohen]. and 2- using Seeders when they do not have anyone to force them for contribution. Since the amount of downloads they can get from this way is significantly smaller, freeloaders have a hard time to finish their downloads.
For this experiment, we implemented a network with 500 nodes and 100 packets. We had 10 Seeders and 5 freeloaders which were distributed evenly in the network. Simulation was stopped when all freeloaders finished their downloads. We put our method against a 50% willingness network. As it can be seen in Fig. 7 with our method, freeloaders have to stay much longer in the network. Clearly, almost in all scenarios, in the network which benefits from our approach, the freeloaders have to stay three times longer than a 50% willingness network.
V-D A Comparison with Bittorrent
In a Leecher-to-Leecher transaction, unlike Bittorrent, we prevent betrayals before they take place. Another main advantage of our method comes from Leecher-to-Seeder transactions. The reason is that Bittorrent did not implement any mechanisms to help Seeders in the network. Therefore, we examine two main factors: 1- how much Leechers are forced to upload more and 2- how much Seeders upload less.
Since Seeders play a crucial role in this experiment, we chose a smaller network with 30 nodes and 6 Seeders which were distributed evenly in the network. We used 100 packets in the network. In the first experiment (Fig. 8), we show how much our method makes Leechers to take responsibility for their downloads. Simulation stopped when all of Leechers finished their downloads. After finishing downloads they could leave the network or stay and become another Seeder. For this purpose, 10 Leechers were chosen randomly for our analysis. The result is shown in Fig. 8. As we can see, in most cases, by using our method, Leechers uploaded more. In addition, compared to Bittorent, the reliance on Seeders is lower.
In the second experiment (Fig. 9), we aimed to analyse the number of uploads for Seeders. As we already mentioned, we had six Seeders in the network which were distributed evenly in the overlay. The average of uploads for all six Seeders at each time interval is shown in Fig. 9. As it can be seen, as the time increases, the average of uploads of Seeders increases as well. However, in a network which uses our approach, this increment is slightly lower than Bittorent. This confirms the functionality of our approach against Bittorent. At the end of the simulation time, this difference in the average number of uploads, reaches its maximum limit. This reveals how our approach performs better as the time increases.
Vi Conclusion and Future Work
Fairness is one of the most important challenges in P2P communications. In this paper, we proposed an incentive-based and fully distributed model that is aimed to accurately provide fairness in P2P networks. Our approach supports both Leechers and Seeders against freeloaders. The former is met by making Leechers upload as much as they download from others. The latter is guaranteed by reducing the workload of Seeders by relegating the traffics to Leechers. Consequently, we force Leechers to take responsibility for their downloads and engage in the uploading process. As a result, they are encouraged to stay longer in the network. We further showed that by combining the standard methodology in cryptography, i.e. RSA, we can secure our channels against line spying next to providing a fair network. Our findings obtained from the simulation results clearly shows the effectiveness and applicability of our approach by decreasing the download time, providing an appropriate level of fairness among peers, and preventing free-riding.
-  Y. Tang, H. Wang, and W. Dou, “ Trust based incentive in P2P network,” in Proceedings of the IEEE International Conference on E-Commerce Technology for Dynamic E-Business, China (2004)
-  Naghizadeh, A., & Shahbahrami, A. (2017). Binary search routing equivalent (BSRE): a circular design for structured P2P networks. Transactions on Emerging Telecommunications Technologies, 28(4), e3012.
-  Naghizadeh, A., Berenjian, S., Meamari, E., & Atani, R. E. (2016). Structural‐based tunneling: preserving mutual anonymity for circular P2P networks. International Journal of Communication Systems, 29(3), 602-619.
-  Naghizadeh, A., Berenjian, S., Razeghi, B., Shahanggar, S., & Pour, N. R. (2015, January). Preserving receiver’s anonymity for circular structured P2P networks. In 2015 12th Annual IEEE Consumer Communications and Networking Conference (CCNC) (pp. 71-76). IEEE.
-  D. Guo, Y. Kwok, X. Jin, and J. Deng, “A performance study of incentive schemes in peer-to-peer file-sharing systems,” The Journal of Supercomputing, vol. 72, no. 3, 1152–1178 (2016)
-  D. Hughes, G. Coulson, and J. Walkerdine, “Free riding on gnutella revisited: The bell tolls?,” IEEE Distributed Systems Online, vol. 6, no. 6 (2005)
-  N. Balouchzahi, M. Fathy, and A. Akbari, “An efficient infrastructure based service discovery in vehicular networks using P2P structures,” The Journal of Supercomputing, vol. 72, no. 3, 1013–1034 (2016)
-  K. Lu, J. Wang, and M. Li, “An Eigentrust dynamic evolutionary model in P2P file-sharing systems,” Peer-to-Peer Networking and Applications, vol. 9, no. 3, 599–612 (2016)
-  B. Cohen, “Incentives build robustness in BitTorrent,” in Proceedings of P2PEcon (2003)
-  Naghizadeh, A., Razeghi, B., Radmanesh, I., Hatamian, M., Atani, R. E., & Norudi, Z. N. (2015, April). Counter attack to free-riders: Filling a security hole in BitTorrent protocol. In 2015 IEEE 12th International Conference on Networking, Sensing and Control (pp. 128-133). IEEE.
-  R. R. Izhak-Ratzin, “Improving the BitTorrent protocol using different incentive techniques,” Ph.D. dissertation, Dept. CS., UCLA, USA (2010)
-  M. Li, “Improving performance of BitTorrent network through incentive mechanism,” M.Sc. thesis, San Jose State University, USA, (2011)
-  M. Karakaya, I. Körpeog, “Free riding in peer-to-peer networks,” Computer Networks, vol. 52, no. 3, 675–694 (2008)
-  Y. Joung, T. H. Chiu, S. Chen, “Cooperating with free riders in unstructured P2P networks,” Computer Networks, vol. 56, no. 1, 198–212 (2012)
-  S. Kim, “Repeated public goods game mode for trust based P2P networks,” Wireless Personal Communications, vol. 79, no. 1, 473–485 (2014)
-  S. D. Kamvar, M. T. Schlosser, and H. Garcia-Molina, “The Eigentrust algorithm for reputation management in P2P networks,” in Proceedings of the International Conference on World Wide Web, Hungary, 640–651 (2003)
-  Razeghi, B., Hatamian, M., Naghizadeh, A., Sabeti, S., & Hodtani, G. A. (2015, April). A novel relay selection scheme for multi-user cooperation communications using fuzzy logic. In 2015 IEEE 12th International Conference on Networking, Sensing and Control (pp. 241-246). IEEE.
-  Berenjian, S., Shajari, M., Farshid, N., & Hatamian, M. (2016, September). Intelligent automated intrusion response system based on fuzzy decision making and risk assessment. In 2016 IEEE 8th International Conference on Intelligent Systems (IS) (pp. 709-714). IEEE.
-  Hatamian, M., Barati, H., Movaghar, A., & Naghizadeh, A. (2016). CGC: centralized genetic-based clustering protocol for wireless sensor networks using onion approach. Telecommunication systems, 62(4), 657-674.
-  Naghizadeh, A., Razeghi, B., Meamari, E., Hatamian, M., & Atani, R. E. (2016). C-trust: A trust management system to improve fairness on circular P2P networks. Peer-to-Peer Networking and Applications, 9(6), 1128-1144.
-  G. D. Gonçalves, Í. Cunha, A. B. Vieira, and J. M. Almeida, “Predicting the level of cooperation in a Peer-to-Peer live streaming application,” Multimedia Systems, vol. 22, no. 2, 161–180 (2016)
-  Naghizadeh, A. (2016). Improving fairness in peer-to-peer networks by separating the role of seeders in network infrastructures. Turkish Journal of Electrical Engineering & Computer Sciences, 24(4), 2255-2266.
-  R. L. Rivest, A. Shamir, and L. Adleman, “A method for obtaining digital signatures and public-key cryptosystems,” Communications of the ACM, vol. 21, no. 2, 120–126 (1978)