The second phase in creating a peer-to-peer network is to assign a GUID (Globally Unique ID) to each peer in the network. This GUID is used to uniquely identify a given peer in the network, so you know what peer you are communicating with. The GUID is also used when searching for peers. I'll get back to that later.
Here is a diagram illustrating the GUID phase:
|A P2P network where each peer has been assigned a GUID.|
A GUID is typically a bit string, e.g. 64 or 128 bits.
You might be wondering how GUIDs are assigned to a peer, when there is no central server. There are two ways to do this:
- Peers create a GUID themselves.
- Peers are assigned a GUID when they join an existing network.
If peers create their own GUID, you risk that two peers create the same GUID. Even if you create a smart algorithm for creating GUIDs, a peer may still cheat and just assign itself a GUID from another peer in the network, and thus attempt to take over it's identity. This is not necessarily smart.
A different solution is to give a peer a GUID when it joins an existing network. A peer outside the network has to contact at least one peer in the network to join it. The contacted peer could generate a GUID for the new peer.
Even so, the newly joining peer could attempt to use the GUID of other peers in the network. I will get back to security issues in P2P networks in a later text. For now, just assume that no malicious peers join the network.