They employ a globally consistent protcol to ensure that every node can efficiently route a search to some other peer that had the desired file. This allows it an advantage that no matter how rare a file any node of the network can find it.
A common method for doing the same is using a Distributed Hash Table (DHT) to assign ownership analogous to a particular peer. DHTs are a class of decentralized distributed systems that provide a lookup service similar to a hash table
The above image gives an example of a Hash function where in different inputs when passed through the Hash Function give different keys which are indicative of the location of the peers having that particular desired input.
The nodes have a responsibility of maintaining the mapping from the keys to the values such that a change in participants causes minimal disruption. This allows structured systems to scale to huge networks capable of handling large numbers of nodes, and node arrival, departure, and failures.
An unstructured P2P network is formed when the overlay links are established arbitrarily. Such networks can be easily constructed as a new peer that wants to join the network can copy existing links of another node and then form its own links over time. In an unstructured P2P network, if a peer wants to find a desired piece of data in the network, the query has to be flooded through the network to find as many peers as possible that share the data. The main disadvantage with such networks is that the queries may not always be resolved. Popular content is likely to be available at several peers and any peer searching for it is likely to find the same thing. But if a peer is looking for rare data shared by only a few other peers, then it is highly unlikely that search will be successful. Flooding also causes a high amount of signaling traffic in the network and hence such networks typically have very poor search efficiency. Many of the popular P2P networks are unstructured.1