Does Bitcoin Use UDP or TCP?

It is well-known that the Bitcoin system doesn’t have one single network protocol. In Bitcoin network, any way of obtaining the block is equivalently valid to the blocks over the P2P network, over satellite broadcast and over Freenet.

Thus, Bitcoin uses TCP. However, UDP is used with bitcoin too, but by the Fibre protocol.

As far as common Bitcoin Peer-to-Peer protocol is concerned UDP isn’t a good fit for most operations that it performs. Bitcoin needs to send the messages reliably far larger than an IP packet, such as transactions and blocks. Though the internet is ‘reliable, yet the packet loss rates of 1 to 3% are common, which means that any application in need of large message communication with UDP needs to implement packetization, reordering, retransmission, etc. These are the same things that TCP already implements for us all. A number of applications have rolled their own TCP in userspace have ended up with exploitable bugs. Thus, it’s not something that needs to be done without good cause.

You May Also Read: Is Bitcoin A Ponzi Scheme?

UDP Issues

UDP has issues of NAT traversal. Obtaining bidirectional communication across a NAT with UDP is something that’s not a simple matter. Crossing anything which is more complicated than a full cone, NAT requires a considerable amount of unique code. But, without it, there will so many hosts who can’t talk to other peers with UDP.

In Bitcoin P2P, we use a consistent relationship between nodes for making the network efficient and reliable. Nodes have an idea of what their peers know already, and what they can avoid sending them redundant data. Also, nodes know which peers have been the fastest to send them blocks in the past and handle them particularly.

Similarly, even if the protocol is connectionless, yet there are costs involved to process messages from peers by prioritizing handling messages from the peer. And, Bitcoin is capable of reducing the impact of some kinds of DDoS attack.

Handling larger than one-packet messages mean that even with a connectionless transport, still there needs to be a sort of persistent state.

You May Also Read: What Is The Best and Safest Bitcoin Wallet?

How is TCP Better?

Yes, TCP is reliable!

If a single bit is disrupted amid the communication, then TCP will take care of the retransmission. Thus, from a programming point of view, you can see the TCP connection as a tunnel which assures you that the data will get on the other side.

Unless you have reliability, you can’t be assured that a transaction succeeded, and the entire system will ultimately collapse.

As Alec Cawley said –

“You should always try to use TCP because you are going to want reliability all the time. Well, I believe this is an overstatement. UDP is simple and fast, and this makes it perfect for real-time traffic like video and audio streams, or VoIP. On top of that, it has just the minimum overhead. So, in case the links are performant and we have no drops, it is more bandwidth efficient than TCP.”

In simple words, Bitcoin uses the TCP protocol to ensure absolute reliability.

Here are a Few Articles for You to Read Next: