Peer-to-peer
0-day streakReview

Your progress

Level 1

0 XP100 XP to level 2
0day streak
0best streak
0topics started
0cards reviewed
    Review cards

    Progress is stored only in this browser. No account is required.

    Peer-to-peer (P2P) architecture: the 60-second story

    Peer-to-peer architecture

    500 students want the topper’s notes before tomorrow’s exam.

    If the topper copies for everyone, most get nothing. If each student with a copy copies for two others, more students means more copiers.

    53 min

    vs 18.5 days from one server

    A 2 GB patch to a million players. Each brings 5 Mbit/s of upload, 5,000 Gbit/s in all. A lower bound; real swarms are slower.

    Does P2P mean no servers?

    Bad: Pure P2P

    Every node equal, like early Gnutella: no central fallback, no relay.

    Good: Hybrid P2P

    Trackers and signalling handle kilobytes; peers carry gigabytes. Almost every successful system works this way.

    Before any download: who has the file?

    A DHT like Kademlia won: no special node, and any exact key in about log₂ n steps. The price: no keyword search.

    Every byte comes from a stranger. Why can’t a fake piece poison your download?

    The trick

    The metainfo lists every piece’s SHA-1. A piece that doesn’t match is discarded and fetched from someone else.

    Want to download fast? Upload.

    Every 10 s, your 4 upload slots go to the peers you download from fastest. One rotates every 30 s, so newcomers get a first piece. Free-riders get choked.

    Neither phone can accept a connection. How do they talk?

    STUN reveals each public address. ICE tries hole punching first; only if that fails does a TURN relay forward every packet, on your bill.

    When should you propose P2P?

    Bad: Needs consistency or control

    Transactions, moderation, instant revocation, or phones on metered plans uploading for strangers.

    Good: Big bytes or a direct path

    Patches, updates, 1:1 calls. Users carry the bandwidth.

    Remember

    Keep control and integrity central; let users carry the bandwidth. Hash every piece, reward uploaders, and keep a server fallback.