P2P communication protocols

·

P2P protocols

Overview of the popular P2P (peer-to-peer) file-sharing protocols, including Napster, Gnutella, and BitTorrent. These protocols were developed in a sequence and each one took inspiration from the previous one while adding its own unique features. Each protocol was a significant advancement in file sharing during its time. Gnutella was the first decentralized file-sharing network to introduce the world to the power of P2P data exchange protocols. BitTorrent, which remains the most popular P2P protocol to this day, solidified the dominance of peer-to-peer data exchange and made several modifications to improve its usability. However, it’s worth noting that there are other P2P data exchange protocols. Such as eDonkey, Freenet, and Direct Connect, that is equally fascinating. Let’s dive into each protocol in more detail.

P2P

To start with, it is important to clarify the meaning of the P2P file-sharing protocol. According to Wikipedia, it refers to a type of protocol that facilitates the distribution and exchange of information. Through a specialized program designed to search for other users on the network. In contrast to the client-server information exchange model, all users or peers are equal participants in P2P networks. Some hybrid P2P protocols, like Napster or BitTorrent. Require a connection to a server for finding information about files or other users from whom a specific file can be borrowed. The exchange of data itself happens between the users on the network, which is the primary characteristic of P2P.

Nowadays, cryptocurrencies are thriving with a continuous increase in their value and numbers. Most existing cryptocurrencies use P2P transaction confirmation protocols that were inspired by the P2P file-sharing networks. It’s worth noting that there are many other interesting P2P data exchange protocols such as eDonkey, Freenet, Direct Connect, and more.

Napster

The history of file sharing has been well-documented, with several P2P protocols that have been noteworthy. While P2P networks have existed since the early 90s (such as IRC, and Hotline). It was Napster that became widely popular among WAN users. This utility, co-founded by Sean Parker, and played by Justin Timberlake in David Fincher’s The Social Network, had a massive impact in 1999.

Napster was based on central servers (Index Server), which had a list of all files and addresses of clients (peers) from which they can be downloaded. After sending a search request, the peer connected to the server would receive the addresses of other peers with the requested file, and a connection between peers was established through the same server. While this was a breakthrough in audio distribution, the presence of the company’s central server made it vulnerable to legal action from copyright holders, leading to its eventual decline. Nonetheless, Napster demonstrated the potential of P2P protocols, and we continue to evolve toward more modern options.

Gnutella

In the early 2000s, Gnutella was developed by Justin Frankel and Tom Pepper as a P2P communications protocol. Which was fully decentralized and did not have a central server like Napster. Gnutella has several specifications, and version 0.6 is particularly notable.

Ordinary users

The network is comprised of ordinary users, referred to as leaf, and ultrapeers, referred to as ultrapeer. Leaves and other ultrapeers are connected to these ultrapeers. Since Gnutella is decentralized, any user can declare themselves an ultrapeer if they meet certain requirements. Such as bandwidth, system configuration, and lack of a firewall. However, to become an ultrapeer, the user must be confirmed by existing ultrapeers.

New users

To gain access to the network, a new user connects to an already-existing ultrapeer. The user can obtain the address of the ultrapeer through ping messages, by contacting the list specified in the program, or by updating it with special Gnutella Web Cashing requests via HTTP to volunteers who run GWebCashes on their machine.

Query Routing Protocol

Afterward, the Query Routing Protocol (QRP) is used to facilitate interaction between users. Users exchange a Request Routing Table (QRT) containing the names of the files they wish to exchange. These names are truncated to exclude grammatical features of words and hashed with SHA-1. A boolean variable is then entered into the table, indicating whether the user has the file with the given hash. The table is then sent to the nearest ultrapeer, which aggregates the tables of its leaves and exchanges it between ultrapeers.

To initiate a search, a request for a file name is sent to the ultrapeer, which then hashes it using a known algorithm and compares it with the Query Routing Table (QRT). If there is a match, the request is forwarded to the corresponding leaf or neighboring ultrapeer, until it reaches the right user who then directly contacts the requesting user.

File exchange

For file exchange, a direct connection is established between users and the transfer takes place through HTTP. If a user is behind a firewall or NAT, then the connection is made via a push proxy, with the ultrapeers acting as a proxy server.

It should be noted that the Gnutella protocol is currently being finalized, and a newer version, Gnutella2, exists. While it retains the concept of decentralizing the network and dividing users into ordinary and ultra categories, it has more sophisticated communication algorithms and network maintenance and management algorithms to protect against DDoS attacks. Nevertheless, the original Gnutella protocol still maintains its lead in terms of millions of users.

BitTorrent

The widely-known and frequently-used protocol, BitTorrent, was developed in 2001 by Bram Cohen, drawing inspiration from Gnutella. Its primary purpose was to enhance the speed of centralized HTTP distributions. When numerous clients connect to the server in the client-server model, the server’s outgoing traffic must be restricted, significantly reducing the download speed. The process of data transfer can be explained as follows:

BitTorrent network

The BitTorrent network includes a web server that holds meta-data about files, a BitTorrent tracker (which contains information about users who distribute specific files), the original file distributor (either a user or a network peer), and other peers who have launched the torrent client (a program that utilizes the protocol). Peers communicate with each other using the TCP protocol, which was subsequently substituted by the advanced uTP. It is significant to note that peers concurrently distribute and download available files, which facilitates more efficient exchange interactions among users since it ensures that all peers who have a file will not only download but also distribute it.

More about BitTorrent network

To include a file in the distribution, the peer must launch the tracker, create a file with the .torrent extension that stores meta-data about the original file and a URL link to its tracker, and upload it to the web server.

To download and upload the source file, other peers connect to the server to get the torrent file, which the torrent client uses to download the source file onto their computer. Users then connect to the file distribution.

The .torrent meta-information file includes a link to the sharing users’ tracker and a dictionary with information about the files being shared. Such as their size, name, and hash sums of all file parts. It is important to note that the protocol divides files into small parts (about 5MB), which can be transferred separately from different distributors. The original protocol utilizes SHA-1, which later became a hindrance and led to further modifications of the protocol.

All messages between peers begin with a special identifier with the following values:

0 – choke

1 – unchoke

These messages indicate whether the recipient can or cannot distribute the requested information.

2 – interested

3 – not interested

These messages are sent to the distributor, indicating a desire or unwillingness to receive the requested information.

4 – have

Sent by the requester to notify the distributor of the received and authenticated portion of the file.

5 – bitfield

This message is sent as the first message in a connection. Informing the recipient that the message includes a Boolean string with a value of 1 at the position of the part of the file already received by the requester.

6 – request

The request message contains the index and length of the requested file part.

7 – piece

Sent by the distributor, this message contains the index, length, and the file part being transferred.

8 – cancel

This message is utilized at the end of a hand when only a few parts of the file remain (in “endgame mode”). In this mode, the recipient requests all remaining parts from possible peers. As the last parts are usually downloaded from a single peer and take a long time. When downloading each part, the recipient sends a cancel message indicating that they already received this part.

Download and torrent file

To download the corresponding data, a peer that has received a torrent file first searches for the tracker link in the meta-information and requests information about the seeders from it.

Once this is done, the peer can connect to several seeders and request various parts of the file. The parts usually arrive in random order to distribute the load between the seeders.

After receiving a part, the peer checks its hash sum against the one in the metafile and either confirms receipt or requests the part again if there are any errors.

Finally, when only a few pieces are left, the “endgame” mode is activated as described above. Once the download is complete, the peer can start distributing the received file, and its link is added to the trackers.

Protocol


The protocol used an innovative method to decrease the load on a single user by breaking down the file into smaller parts that could be obtained from various distributors. This approach also increased the security of the protocol by preventing servers from accessing the contents of the files.

However, the anonymity of the protocol was still in question, and the reliability of the SHA-1 hash function was also a concern. To address these issues, a protocol modification called BitTorrent protocol encryption was introduced in 2005. This modification encrypts message headers and transmitted parts using the RC4 cipher which was selected for its speed. Additionally, the hash function was changed to SHA-256 in the new version of the protocol (BitTorrent v2) to improve file hashing reliability. Although it is still considered vulnerable today. Despite ongoing development, the second version of the BitTorrent protocol is currently only supported by a small number of clients, much like Gnutella.

Legislative issues

The utilization of P2P protocols like BitTorrent for distributing copyrighted content has resulted in numerous legal and regulatory concerns. The consequences of using these protocols vary depending on the location of the users. The use of these protocols could potentially lead to legal accountability for both. The original file distributor and users who have downloaded the file as contributors.

In Finland, system administrators and owners of a torrent sites were fined huge amounts of money for copyright infringement. The Pirate Bay, which is one of the oldest trackers located in Sweden, was subjected to searches in 2006. The four co-founders were sentenced to imprisonment and fines, with two of them serving time in prison. Nevertheless, the site was back online within 72 hours of the searches and arrests, and the government’s actions were met with criticism from the public and the press.

In 2005, Bram Cohen, the creator of the BitTorrent protocol and the CEO of BitTorrent, Inc. Worked on developing the protocol and new P2P network applications before being acquired by the cryptocurrency startup TRON. Made a deal with the Motion Picture Association of America to remove links to copyrighted content from the official BitTorrent website.

Nevertheless, the responsibility for copyright infringement falls on trackers and pirate sites with metafiles. However, these issues are subject to the legislation of different countries. In Russia, there have been recent attempts to block the functionality of the protocol along with VPN protocols, in accordance with the requirements of Roskomnadzor.

Conclusion

Throughout this review, we have covered the legal standing of various P2P communication protocols in different countries. Following their development in chronological order. I hope you found this overview informative and engaging. It is important to note that this review is not intended to be comprehensive. And only highlights some of the significant moments in the evolution of these protocols. There is still much more to explore. And I encourage you to research other protocols like eDonkey and Freenet to continue your understanding of this fascinating field.

You can read more interesting, useful, and relevant articles in our blog section.