Wiki source code of Networks

Version 37.1 by Zenna Elfen on 2026/01/05 19:54

Hide last authors
Zenna Elfen 19.1 1 (% class="jumbotron" %)
2 (((
3 (% class="container" %)
4 (((
Zenna Elfen 20.1 5 = Peer-for-Peer Networks =
Zenna Elfen 19.1 6
Zenna Elfen 20.1 7 P4P, short for Peer-4-Peer (which in turn is short for Peer-for-Peer) are a family of networks which build on principles of local-first, peer-2-peer, open-source, routing agnostic (offline-first) and mutual-aid principles. The above is a lot of terms which in and of themselves carry a lot of meaning, yet when combined they enable censorship-resistant, resilient and adaptive, sustainable and energy-efficient communication infrastructures.
Zenna Elfen 19.1 8 )))
9 )))
10
Zenna Elfen 27.1 11
Zenna Elfen 28.1 12
Zenna Elfen 34.1 13
14
Zenna Elfen 35.1 15
16
Zenna Elfen 36.1 17
18
Zenna Elfen 28.1 19
Zenna Elfen 32.1 20
Zenna Elfen 37.1 21
22 (% class="col-xs-12 col-sm-8" %)
Zenna Elfen 33.1 23 (((
Zenna Elfen 27.1 24 {{box title="==== Contents ====
25
26 ====== ======"}}
Zenna Elfen 28.1 27 {{toc depth="5"/}}
Zenna Elfen 27.1 28 {{/box}}
29 )))
30
31
Zenna Elfen 11.1 32
Zenna Elfen 1.1 33
Zenna Elfen 24.1 34
Zenna Elfen 35.1 35
36
37
38
Zenna Elfen 37.1 39 (% class="row" %)
40 (((
Zenna Elfen 35.1 41
Zenna Elfen 37.1 42 == Building Blocks of P4P Networks ==
43 To fully assemble a P4P network one needs a few different building blocks, below is an overview of 15 of those building blocks. Lost in translation? Take a look at the [[terminology>>doc:P4P.Definitions.WebHome]].
44 )))
Zenna Elfen 36.1 45
Zenna Elfen 25.1 46 (((
Zenna Elfen 35.1 47 ==== ====
48
Zenna Elfen 15.1 49 ==== **1. Data Synchronization** ====
Zenna Elfen 11.1 50
Zenna Elfen 13.1 51 > Synchronization answers **how updates flow between peers** and how they determine what data to exchange. This layer is about **diffing, reconciliation, order, causality tracking, and efficient exchange**, not persistence or user-facing collaboration semantics.
Zenna Elfen 11.1 52
Zenna Elfen 15.1 53 * //How do peers detect differences and synchronize state?//
54 * Examples: Range-Based Set Reconciliation, RIBLT, Gossip-based sync, State-based vs op-based sync, Lamport/Vector/HLC clocks, Braid Protocol
Zenna Elfen 11.1 55
56
57
Zenna Elfen 15.1 58 ==== **2. Collaborative Data Structures & Conflict Resolution** ====
Zenna Elfen 11.1 59
Zenna Elfen 13.1 60 > This layer defines **how shared data evolves** when multiple peers edit concurrently. It focuses on **conflict-free merging, causality, and consistency of meaning**, not transport or storage. CRDTs ensure deterministic convergence, while event-sourced or stream-driven models maintain a history of all changes and derive consistent state from it.
61
Zenna Elfen 15.1 62 * //How do peers collaboratively change shared data and merge conflicts?//
63 * Examples: CRDTs (Yjs, Automerge), OT, Event Sourcing, Stream Processing, Version Vectors, Peritext
Zenna Elfen 13.1 64
65
66
Zenna Elfen 15.1 67 ==== **3. Data Storage & Replication** ====
Zenna Elfen 13.1 68
69 > This layer focuses on **durability, consistency, and redundancy**. It handles write-paths, crash-resilience, and replication semantics across nodes. It is the “database/storage engine” layer where **data lives and survives over time**, independent of sync or merging logic.
70
Zenna Elfen 15.1 71 * //How is data persisted locally and replicated between peers?//
72 * Examples: SQLite, IndexedDB, LMDB, Hypercore (append-only logs), WALs, Merkle-DAGs (IPFS/IPLD), Blob/media storage
Zenna Elfen 13.1 73
74
75
Zenna Elfen 15.1 76 ==== **4. Peer & Content Discovery** ====
77
Zenna Elfen 13.1 78 > Discovery occurs in two phases:
79 > 1. **Peer Discovery** → finding _any_ nodes
80 > 2. **Topic Discovery** → finding _relevant_ nodes or resources
81 > These mechanisms enable decentralized bootstrapping and interest-based overlays.
82
Zenna Elfen 15.1 83 * //How do peers find each other, and how do they discover content in the network?//
84 * Examples: DHTs (Kademlia, Pastry), mDNS, DNS-SD, Bluetooth scanning, QR bootstrapping, static peer lists, Interest-based routing, PubSub discovery (libp2p), Rendezvous protocols
Zenna Elfen 13.1 85
86
87
Zenna Elfen 15.1 88 ==== **5. Identity & Trust** ====
Zenna Elfen 13.1 89
90 > Identity systems ensure reliable mapping between peers and cryptographic keys. They underpin authorization, federated trust, and secure overlays.
91
Zenna Elfen 15.1 92 * //How peers identify themselves, authenticate, and establish trustworthy relationships?//
93 * Examples: PKI, Distributed Identities (DIDs), Web-of-Trust, TOFU (SSH-style), Verifiable Credentials (VCs), Peer key fingerprints (libp2p PeerIDs), Key transparency logs
Zenna Elfen 13.1 94
95
Zenna Elfen 16.1 96
Zenna Elfen 15.1 97 ==== **6. Transport Layer** ====
Zenna Elfen 13.1 98
Zenna Elfen 15.1 99 > This layer provides logical connections and flow control. QUIC and WebRTC bring modern congestion control and encryption defaults; Interpeer explores transport beyond IP assumptions.
Zenna Elfen 13.1 100
Zenna Elfen 16.1 101 * //How do peers establish end-to-end byte streams and reliable delivery?//
Zenna Elfen 15.1 102 * Examples: TCP, UDP, QUIC, SCTP, WebRTC DataChannels, Interpeer transport stack
Zenna Elfen 13.1 103
104
Zenna Elfen 16.1 105
Zenna Elfen 15.1 106 ==== **7. Underlying Transport (Physical/Link Layer)** ====
107
108 > Highly relevant for **offline-first / edge networks**, device-to-device communication, and mesh networks and relates to the hardware which facilitates connections.
109
Zenna Elfen 16.1 110 * //How does data move across the medium?//
Zenna Elfen 15.1 111 * Examples: Ethernet, Wi-Fi Direct / Wi-Fi Aware (post-AWDL), Bluetooth Mesh, LoRa, NFC, Cellular, CSMA/CA, TDMA, FHSS
112
Zenna Elfen 16.1 113
114
Zenna Elfen 15.1 115 ==== **8. Session & Connection Management** ====
116
117 > Manages **connection lifecycle**, including authentication handshakes, reconnection after drops, and session continuation—especially important in lossy or mobile networks.
118
Zenna Elfen 16.1 119 * //How are connections initiated, authenticated, resumed, and kept alive?//
Zenna Elfen 15.1 120 * Examples: TLS handshake semantics, Noise IK/XX patterns, session tokens, keep-alive heartbeats, reconnection strategies, session resumption tickets
121
122
Zenna Elfen 16.1 123
Zenna Elfen 15.1 124 ==== **9. Content Addressing** ====
125
126 > Content addressing ensures **immutability, verifiability, and deduplication**. Identity of data = cryptographic hash, enabling offline-first and tamper-evident systems.
127
Zenna Elfen 16.1 128 * //How is data addressed and verified by content, not location?//
Zenna Elfen 15.1 129 * Examples: IPFS CIDs, BitTorrent infohashes, Git hashes, SHA-256 addressing, Named Data Networking (NDN)
130
Zenna Elfen 16.1 131
132
Zenna Elfen 15.1 133 ==== **10. P2P Connectivity** ====
134
Zenna Elfen 16.1 135 > Connectivity ensures peers bypass NATs/firewalls to reach each other. 
Zenna Elfen 15.1 136
Zenna Elfen 16.1 137 * //How can two peers connect directly across networks, firewalls, and NATs?//
Zenna Elfen 15.1 138 * Examples: IPv6 direct, NAT Traversal, STUN, TURN, ICE (used in WebRTC), UDP hole punching, UPnP
139
Zenna Elfen 16.1 140
141
Zenna Elfen 15.1 142 ==== **11. Session & Connection Management** ====
143
144 > Manages **connection lifecycle**, including authentication handshakes, reconnection after drops, and session continuation.
145
Zenna Elfen 16.1 146 * //How are connections initiated, authenticated, resumed, and kept alive?//
Zenna Elfen 15.1 147 * Examples: TLS handshake semantics, Noise IK/XX patterns, session tokens, keep-alive heartbeats, reconnection strategies, session resumption tickets
148
Zenna Elfen 16.1 149
150
Zenna Elfen 15.1 151 ==== **12. Message Format & Serialization** ====
152
153 > Serialization ensures **portable data representation**, forward-compatible schemas, and efficient messaging. IPLD provides content-addressed structuring for P2P graph data.
154
Zenna Elfen 16.1 155 * //How is data encoded, structured, and made interoperable between peers?//
Zenna Elfen 15.1 156 * Examples: CBOR, Protocol Buffers, Cap’n Proto, JSON, ASN.1, IPLD schemas, Flatbuffers
157
Zenna Elfen 16.1 158
159
Zenna Elfen 15.1 160 ==== **13. File / Blob Synchronization** ====
161
162 > Bulk data syncing has **different trade-offs** than small collaborative state (chunking, deduplication, partial transfer, resume logic). Critical for media and archival P2P use-cases.
163
Zenna Elfen 16.1 164 //How are large objects transferred and deduplicated efficiently across peers?//
Zenna Elfen 15.1 165 Examples: BitTorrent chunking, IPFS block-store, NDN segments, rsync-style delta sync, ZFS send-receive, streaming blob transfers
166
Zenna Elfen 16.1 167
Zenna Elfen 15.1 168 ==== **14. Local Storage & Processing Primitives** ====
169
170 > Provides durable on-device state and local computation (event sourcing, materialization, compaction). Enables offline-first writes and deterministic replay.
171
Zenna Elfen 16.1 172 * //How do nodes persist, index, and process data locally—without external servers?//
Zenna Elfen 15.1 173 * Examples: RocksDB, LevelDB, SQLite, LMDB, local WALs/append-only logs, embedded stream processors (NATS Core JetStream mode, Actyx-like edge runtimes), Kafka-like libraries
174
175
Zenna Elfen 16.1 176
Zenna Elfen 15.1 177 ==== **15. Crash Resilience & Abortability** ====
178
179 > Ensures P2P apps don’t corrupt state on crashes. Tied to **local storage & stream-processing**, and critical in offline-first and distributed update pipelines. Abortability is the updated term for Atomicity as part of the ACID abbreviation.
180
Zenna Elfen 16.1 181 * //How do nodes recover and maintain correctness under failure?//
Zenna Elfen 15.1 182 * Examples: WALs, idempotent ops, partial log replay, transactional journaling, write fences
183
184
185
186
Zenna Elfen 11.1 187 == Distributed Network Types ==
188
189
190 [[Flowchart depicting distributed network variants, under development. Building on work from Z. Elfen, 2024: ~[~[https:~~~~/~~~~/doi.org/10.17613/naj7d-6g984~>~>https://doi.org/10.17613/naj7d-6g984~]~]>>image:P4P_Typology.png||alt="Flowchart depicting typologies of distributed networks, such as Friend-2-Friend, Grassroots Networks, Federated Networks, Local-First, P2P and P4P Networks" data-xwiki-image-style-alignment="center" height="649" width="639"]]
191
Zenna Elfen 35.1 192 == ==
Zenna Elfen 11.1 193
Zenna Elfen 35.1 194 == Overview of P4P Networks ==
195
196 {{include reference="Projects.WebHome"/}}
Zenna Elfen 24.1 197 )))
Zenna Elfen 11.1 198
199
Zenna Elfen 32.1 200
Zenna Elfen 33.1 201
Zenna Elfen 34.1 202
Zenna Elfen 25.1 203
Zenna Elfen 23.1 204
Zenna Elfen 36.1 205 ~)~)~)