<p>The Bitcoin P2P protocol is an application-specific layer over TCP/IP.</p>
<p>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.</p>

CC BY-SA 4.0
2020-07-11T19:32:27.723Z
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?
JUAN FELIPE SUÁREZ BURGOS
CC BY-SA 4.0
2020-07-11T19:33:16.723Z
Could you briefly elaborate on what UPnP is please.
JUAN FELIPE SUÁREZ BURGOS
CC BY-SA 4.0
2020-07-11T20:23:43.617Z
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.
Pieter Wuille
CC BY-SA 4.0
2020-07-11T21:40:13.413Z
But it does, ultimately, resemble a client server architecture in the sense that nodes that are behind NATs, just like clients in a client server architecture, can only make outgoing transactions but cannot listen to incoming transactions. It's similar to a REST API.
JUAN FELIPE SUÁREZ BURGOS
CC BY-SA 4.0
2020-07-11T21:41:19.897Z
Yes, 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.
Pieter Wuille
CC BY-SA 4.0
2020-07-12T17:47:06.793Z
based on my knowledge, bitcoin core connections aren't technically symmetric and there are comments in code that prove this, like on GETADDR message that gets ignored if the sender is a peer different than inbound. So basically a peer that can only have outbound connection will never send other peers its known addresses (this is an example but I think there are other cases where there aren't asymmetric behaviors)
Not Important
CC BY-SA 4.0
2020-07-12T17:47:50.033Z
Sure, and transaction relay also works slightly differently in both directions. Still, both parties will learn each other's transactions and blocks.
Pieter Wuille
CC BY-SA 4.0
2020-07-12T18:07:44.380Z
let 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
Not Important
CC BY-SA 4.0
2020-07-10T18:05:33.477Z
2020-07-10T18:05:33.477Z
Pieter Wuille
<p>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.</p>

CC BY-SA 4.0
2020-07-10T09:45:47.557Z
Does this answer your question? [How do Bitcoin clients find each other?](https://bitcoin.stackexchange.com/questions/3536/how-do-bitcoin-clients-find-each-other) and [What is the NAT traversal technique used by bitcoin?](https://bitcoin.stackexchange.com/q/61546/13866)
RedGrittyBrick
CC BY-SA 4.0
2020-07-10T16:51:58.027Z
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 BURGOS
<bitcoin-core><peers>
How does bitcoin core establish a peer to peer network
JUAN FELIPE SUÁREZ BURGOS
# How does bitcoin core establish a peer to peer network

(Asked by: username_0 on 2020-07-09)

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.

**Tags:** bitcoin-core, peers

> **Comments:**
> **username_1**: Does this answer your question? [How do Bitcoin clients find each other?](https://bitcoin.stackexchange.com/questions/3536/how-do-bitcoin-clients-find-each-other) and [What is the NAT traversal technique used by bitcoin?](https://bitcoin.stackexchange.com/q/61546/13866)  
> **username_0**: 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?  

---

## 1 answers

### Answer by username_2 on 2020-07-10. Score: 2 | Accepted 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.

> **Comments:**
> **username_0**: 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?  
> **username_0**: Could you briefly elaborate on what UPnP is please.  
> **username_2**: 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.  
> **username_0**: But it does, ultimately, resemble a client server architecture in the sense that nodes that are behind NATs, just like clients in a client server architecture, can only make outgoing transactions but cannot listen to incoming transactions. It's similar to a REST API.  
> **username_2**: Yes, 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.  
> **username_3**: based on my knowledge, bitcoin core connections aren't technically symmetric and there are comments in code that prove this, like on GETADDR message that gets ignored if the sender is a peer different than inbound. So basically a peer that can only have outbound connection will never send other peers its known addresses (this is an example but I think there are other cases where there aren't asymmetric behaviors)  
> **username_2**: Sure, and transaction relay also works slightly differently in both directions. Still, both parties will learn each other's transactions and blocks.  
> **username_3**: let me go a bit OT @username_2 to show gratitude for the effort you put in cryptospace and your attitude you keep showing to help people since long time  

---

