I've tried to look for an answer to this online and haven't found any. My question is: how does bitcoin establish a peer to peer network. Establishing a centralized network with a server in the middle between all clients is trivial. However, establishing a fully peer to peer network isn't that easy. This is mostly due to NATs and Firewalls. How does bitcoin core get around NATs and Firewalls. Does it use holepunching, and, if so, is there a central server that dynamically updates public and private Ip/ports? I guess I would just like to know how the peer to peer network is established.
-
3Does this answer your question? How do Bitcoin clients find each other? and What is the NAT traversal technique used by bitcoin?– RedGrittyBrickJul 10, 2020 at 9:45
-
Not really. None of the two explain how bitcoin deals with NATs and firewalls. Or what set of protocols from the OSI model does it use to communicate with other peers. Does it use http? Websockets? Does it use it's own application layer protocol?– JUAN FELIPE SUÁREZ BURGOSJul 10, 2020 at 16:51
1 Answer
The Bitcoin P2P protocol is an application-specific layer over TCP/IP.
If a node does not have an open port by themselves, they can only make outgoing connections. Node software uses things like UPnP to request NATs to open ports, but if that fails, a node's connections will be unidirectional.
-
If a node's connection becomes unidirectional, then it can only make requests to other nodes with public IPs and Ports. Is that how unidirectionally connected nodes update their blockchain? Jul 11, 2020 at 19:32
-
Could you briefly elaborate on what UPnP is please. Jul 11, 2020 at 19:33
-
Yes, but the protocol is symmetric. So if a node can only make outbound connections, that is still a fully-featured connection between two nodes - it doesn't matter who established the connection. There isn't a "server" and "client" side to the connection. Jul 11, 2020 at 20:23
-
1Yes, in terms of connectivity you are right, but not in terms of functionality. If A connects B, then it will be both the case that A requests things from B, and B requests things from A. Jul 11, 2020 at 21:41
-
1let me go a bit OT @PieterWuille to show gratitude for the effort you put in cryptospace and your attitude you keep showing to help people since long time Jul 12, 2020 at 18:07