# Peer-to-peer > "Take advantages of resources at the edges of the network" Alternative paradigm that promotes the sharing of resources and services through direct exchange between peers. Very popular in the early 2000s with hundreds of file-sharing applications developed. ### Napster Napster was the first P2P file sharing application that allowed users to download and share music for free over the Internet. Napster used small computers on the edges to contribute although they relied on the **centralized server** for lookup purposes (which some argued made it not a pure P2P system). The main operations in Napster were: - joining - publishing - searching - fetching. Napster's simplicity and `O(1)` search were advantageous. However, the **centralized** server for searching was a drawback since it was a single point of failure and a single point of control. ### Gnutella Gnutella has the advantage of being a fully decentralized network, eliminating the need for central coordination. This means that search costs are distributed among the network using a **query flooding** algorithm. When a node joins the Gnutella network, it connects to a known "anchor" node and sends a `PING` message to discover other nodes. These nodes respond with `PONG` messages, providing new connections to the joining node. The topology of the Gnutella network is **random** and constantly changing based on flooded queries. To join the network, a node needs to know the address of at least one anchor node. Peer nodes are used for both resource searching and recursively routing and flooding queries. To prevent congestion and endless queries, each query packet has a `HopToLive` field that decreases with each hop. Once this field reaches zero, the query stops. This parameter helps in limiting the scope of the search and prevents infinite loops or excessive network traffic. ### KaZaA KaZaA was created in 2001 from a Dutch company called Kazaa BV. Kazaa introduces a level of organization in the network by differentiating between regular nodes and "supernodes". In networks with a large number of nodes, simple query flooding (in Gnutella style) can quickly become inefficient and generate excessive traffic. Hierarchical query flooding can mitigate these issues by leveraging the capabilities of supernodes. - Pros: - Tries to consider node heterogeneity - Bandwidth - Host computational resources - Host availability - Kazaa rumored to consider network locality - Cons: - Still no real guarantees on search scope or search time - proprietary, not open source ### BitTorrent - Allows many people to download the same file without slowing down everyone else's download. - Downloaders swap portions of a file with one another, instead of all downloading from a single server. - **Pros**: - the tracking of the upload/download ratio gives peers an incentive to share resources. This mechanism in practice works and prevent free-riding. - **Cons**: - according to Approximate Pareto Efficiency if two peers get poor download rates for the uploads they are providing, they can start uploading to each other and get better download rates than before. But Pareto efficiency is actual a relatively weak condition. - central tracker server needed to **search** . The protocol main goal is indeed the sharing. ### Freenet - Secure Storage Freenet primary goal is **sharing** with an emphasis on secure storage and communication. The routing is intelligent, with a focus on the "small world" network paradigm. This means that while it doesn't exactly fit traditional P2P models, it might be closest to a mix of structured topologies and hierarchical systems (because of its emphasis on anonymity and its unique routing techniques). Main features: - **Search Scope**: - **Join**: New nodes contact known nodes and receive a unique ID. - **Publish**: Files are routed towards nodes that store files with closely matching IDs. - **Search**: Uses a hill-climbing search with backtracking. - **Fetch**: Once a query reaches a node containing the desired file, the file is sent back. - **Performance**: Intelligent routing ensures relatively short query durations, but no provable guarantees are given. Anonymity features may complicate metrics and debugging. - **Security & Anonymity**: Emphasis on anonymity and security. Messages are forwarded and sources modified to ensure the anonymity of communication. Uses cryptography extensively for security. Overall Freenet: **Pros**: - Intelligent routing ensures relatively short queries. - Provides anonymity. - Small search scope. - **Cons**: - No provable guarantees. - Anonymity features can complicate debugging and measurements. ### Final comparison of Peer to Peer architectures Compare the following approaches in terms of search expressivity and performance: |Example| Search expressivity| Performance | Fragility | |---:|---:|---:|---:| |**Napster** | **Centralized Search**| **Optimal** in terms of number of messages due to centralized nature | **Weak**: central server susceptible to takedown| |**Gnutella** | **Broad expressivity** since local data can be searched, and users can specify the type of search they prefer (even based on content) | **Query Flooding** leads to inefficiencies | **Robust** compared to centralized | |**Kazaa**| **Limited** | Hierarchical Query Flooding optimizes search by node distinction (supernodes) but lacks real guarantees on search scope or time| **More robust** due to supernodes (assumptions about **supernode higher stability**) | |**Chord** | **Limited** to the structure and rules of the DHT system (no queries based on content, only by key) | Structured Topology (DHT) gives efficient and predictable search times with logarithmic message number| **Robust**: queries can be forwarded to **successors if some nodes are offline** | |**Freenet** | **Small search scope** as similar files are stored on the same node | Anonymity can complicate metrics| Designed for **robustness and anonymity**: decentralized and dynamic routing.|