How to establish a P2P connection?

Asked

Viewed 578 times

1

On a normal connection, it is necessary that whoever will receive the connection is with an open port on the router (transmitting to a computer from the internal network). But in a P2P connection this does not happen.

How do P2P programs work independently of this open door? For example, programs like torrent or Gnutella make various connections with network nodes, in the case of torrent has the tracker that can somehow work as a mediator and create a connection between the machines, but in the case of Gnutella there is nothing centralizing, there is only a list of nodes to connect.

How can I implement this initial connection? Assuming that it is not a local connection and that there is no open port on the router (as usually occurs) (It does not necessarily need the code, only the concept is sufficient)

  • Take a look at this project https://pypi.org/project/pyp2p/

1 answer

-1

First, You can use any Python method to create P2P network communication, you can use socket if you want to program at a lower level, or you can use flask as a server and request as clients, or any library that allows the creation of a client and a server, you can use threading to program in parallel and maintain multiple connections at the same time.

According to, the Tracker of Torrent is an intermediate server that stores the information of peers, which makes it easier for them to find others on the Internet, when there is no such server, a type of search method is required in the peers themselves which is much more difficult to implement, but there are ways how IRC or websites providing such information.

Third, has a million techniques to create a P2P connection, can use Port-Forward to redirect packets received by public IP to a private IP on your network, or you can use servers ICE(Interactive Connectivity Establishment) that uses Turn and Stun, among others just search.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.