It is said that the nodes communicate over tcp but how is that acheived across networks over different Nats
Ordinary plain IP routing.
The Bitcoin network protocol uses standard TCP sockets with a typical destination TCP-port number of 8333.
The use of Network Address Translation (NAT) by many last-hop routers makes it harder to connect to Bitcoin nodes that use IPV4 private addresses behind a router. In theory the use of IPV6 addresses should make this issue go away.
I believe the NAT traversal for Bitcoin IPV4 TCP connections probably uses whatever features are provided by the underlying network libraries and/or are configured in the OS by the end-user.
So far as I know, there isn't a Bitcoin-specific solution for this. There are a lot of general solutions that may be appropriate to use.
- What is the NAT traversal technique used by bitcoin - which has answers mentioning specific support for UPNP if configured.
- Can exist bitcoin network with all nodes behind NAT?
- How does bitcoin core establish a peer to peer network
- Running a Bitcoin node (behind Firewall / NAT or anything else? disallowing inbound connections)