What is the algorithm of a P2P application?

15

There are several P2P programs, I know the concept is that each computer is like a client and server at the same time, and that they communicate with each other. About this type of communication:

  • If you do not have a server, how does the program know where your siblings are?
  • What would be the algorithm of a P2P program for transmission of messages?
  • Is it possible to create P2P communication on a local network?
  • Is there a default port for this type of connection or can I choose any "available"?
asked by anonymous 24.06.2015 / 20:36

2 answers

10

There are several implementations of peer to peer protocols. In general, they are characterized by:

  • Nonlinear content communication : Large content can be broken into smaller packages, and sent out of order (the client is in charge of organizing the packages);
  • Self-service resolution : The client knows by itself how to search for and initiate communication with other elements equal to itself present in the same logical mesh;
  • Non-trust : The client assumes no external aspect as immutable and reliable (packets can be corrupted, peers can disconnect, or send wrong packets);
  • Control routing : The client knows how to pass forward requests that it can not fulfill.
Some services also implement the concept of trackers that are services where certain information (such as routing tables and correlations between peers and content) are compiled and can be checked for faster resolution .

Note that trackers only work as a hint; the client, in possession of the peers list of a certain content, attempts to connect to them and validate the information they actually have. Trackers with a lot of misinformation can enter a blacklist , for example.

Let's assume the graph below as a practical description of a peer-to-peer mesh, and simulate some cases:

    Peer resolution: The machine 7 sends a broadcast-style message to the network, with no specific target, asking by members of the same mesh. The machines 5 and 6 respond, and are added to the list of peers that 7 can see.
  • Content resolution: 7 asks both 6 and 5 where content A can be found. 6 responds that content exists in 2 and 1 , while 5 replies that 2 has content. Machine 7 then attempts to directly establish a connection with 2 and 1 , and marks them as likely repositories of A .

    li>
  • Content stream: 7 asks 2 for the number of packages that make up A . The answer, 5 packets, comes with the 2 indication that has only the AP1 and AP2 packages. 7 then requests the AP1 package 2 while asking 1 he has; 7 will then attempt to coordinate the packet request to cover all content (AP1-AP5).

  • Ads: 4 , which also has A content, enter the mesh, announcing your presence to 5 . 5 , in turn, tells 7 that another client containing A is available.

Note that at no time does any of the machines treat your peers as a classic server. This type of structure can be implemented in a local area network, and benefit from the (generally) greater reliability, speed and stability of the environment.

    
24.06.2015 / 22:04
4

There is no server, but there is a "queue", called Tracker .

What are Trackers?

Trackers are responsible servers to tell your P2P program the IP of seeders and leechers. The more trackers, more seeders and leechers.

Therefore, your P2P client sends the tracker (probably webservice) the information of your connection (IP, PORT, etc.). Another user with the same client, searching for a small part of the file, receives this information from the tracker (s) and therefore, downloads it. The more trackers, repeating, the more parts available because these in turn multiply the customer information (and therefore, the parts).

The algorithm should only follow this workflow and of course, there is not just one algorithm, since trackers also use their own programs following the P2P standard.

    
24.06.2015 / 20:47