P2P networking architecture
P2P networking is an architecture where each peer acts as a server and a client simultaneously. Since a blockchain network is often implemented on a public network, it is difficult to create a physical topology that is suitable for P2P networking. To create this kind of architecture, a virtual or logical network overlay has to be constructed over the actual physical network topology. A logical network is created to achieve a convenient index of resources and peer discovery in a public network. Although an overlay is formed, data will be exchanged over the TCP/IP network.
Although the underlying physical network could follow any networking topology, the logical network in a P2P architecture will form a mesh-like topology in order to achieve better communication between the peers:
There are two main classifications of a P2P network, based on how the nodes are linked: unstructured and structured P2P networks.
In an unstructured network, the peers aren't linked to each other in an organized way. Each node is randomly connected to the peers, forming a logical mesh. It is easy to build unstructured networks, and they are very robust due to the redundant distribution of nodes. However, these networks have drawbacks, such as the possibility of request flooding, an effect caused by a lack of knowledge about the distribution of resources.
A structured P2P network overlay is formed by following a specific network topology to make sure that nodes can efficiently perform activities on the network. Creating a structured network ensures that a resource can be fetched from somewhere on the network in a certain time. A distributed hash table (DHT) is a widely used structured network implementation that provides decentralized lookup service. Resource information in a DHT can be retrieved from hash tables using the key of a key/value pair stored in the table. The value associated with the key provides information about the peer that owns the resource. DHTs are also used in the BitTorrent filesharing protocol as a substitute for centralized lookup services, such as trackers.
Now that we have an overview of the P2P networking architecture, let's dive into some of the concepts of blockchain technology that are used in P2P networks to form a decentralized blockchain network.