Chapter 2: P2P Architecture
"Hongik Ingan: Distributed networks empower everyone to be their own host."
2.1 Personal Web Server
Your PC as Server
=================
Traditional server:
- Runs 24/7 in data center
- Expensive hardware
- Managed by company
- You pay rent
WIA-HOME server:
- Runs on your PC/laptop
- Uses minimal resources
- You control everything
- Zero cost
Server Components
=================
1. HTTP Server
- Serves web pages
- Handles requests
- Optimized for low resources
2. P2P Node
- Connects to mesh network
- Handles NAT traversal
- Enables discovery
3. Content Manager
- Stores your pages
- Manages media
- Handles caching
4. Security Layer
- TLS encryption
- DDoS protection
- Firewall
Resource Usage
==============
Minimum requirements:
CPU: 5-10% when active
Memory: 128-256 MB
Storage: 100 MB + your content
Network: 1 Mbps upload
Your old laptop can do this!
Sleep Mode
==========
When no visitors:
- Server enters sleep mode
- Uses almost no resources
- Wakes on incoming request
- Seamless for visitors
Energy efficient hosting.
2.2 P2P Mesh Network
Network Topology
================
[Peer A]--------[Peer B]
/ \ / \
/ \ / \
/ \ / \
[Peer C]----[Your PC]----[Peer D]
\ / \ /
\ / \ /
\ / \ /
[Peer E]--------[Peer F]
\ /
\ /
[Relay Node]
No Central Server
=================
Traditional:
All traffic -> Central server -> Users
Server down = Website down
WIA-HOME:
Traffic distributed across network
Your PC down = Cached content served
Network resilient
Peer Discovery
==============
1. Bootstrap
- Connect to known peers
- Get peer list
- Join network
2. DHT (Distributed Hash Table)
- Store domain mappings
- No central DNS required
- Resilient to failures
3. Gossip Protocol
- Share peer information
- Health monitoring
- Load balancing
2.3 NAT Traversal
The NAT Problem
===============
Most home networks use NAT:
- Internal IP: 192.168.1.x
- External IP: Single public IP
- Incoming connections blocked
Need to punch through NAT.
NAT Types
=========
Open (10%):
[OK] Direct connection possible
[OK] No special handling needed
Full Cone (30%):
[OK] Port forwarding works
[OK] Predictable ports
[i] Some setup needed
Restricted (40%):
[i] Hole punching required
[i] Coordination needed
[OK] Usually works
Symmetric (20%):
[!] Most restrictive
[!] Different port per connection
[!] Relay required
Traversal Techniques
====================
1. STUN (Session Traversal)
- Discover external IP/port
- Works for most NATs
- Low overhead
2. TURN (Relay)
- Use relay server
- Works for all NATs
- Higher latency
3. ICE (Interactive Connectivity)
- Try all methods
- Select best option
- Automatic fallback
WIA Implementation
==================
Automatic detection:
1. Detect NAT type
2. Try direct connection
3. Try hole punching
4. Fallback to relay
User sees:
"Your site is live!"
(All complexity hidden)
2.4 WIA DNS
Domain System
=============
Traditional DNS:
- Centralized servers
- Annual renewal fees
- Can be seized/blocked
- Dependent on registrar
WIA DNS:
- Distributed across network
- Free forever
- Censorship resistant
- You control it
Domain Format
=============
yourname.wia.home
- Personal site
- Portfolio
- Blog
yourname.wia.shop
- E-commerce
- Business site
- Product catalog
yourname.wia.blog
- Blog focused
- Content site
- Publications
yourname.wia.page
- Single page
- Landing page
- Project page
Registration
============
Register domain:
1. Choose name
2. Generate keypair
3. Sign registration
4. Broadcast to network
Ownership:
- Proven by cryptographic key
- No central authority
- Cannot be taken away
Custom Domain (Optional)
========================
Already have domain?
- Point DNS to WIA network
- Both addresses work
- Gradual migration possible
2.5 Content Distribution
CDN Without CDN
===============
Traditional CDN:
- Edge servers worldwide
- Expensive ($50-500/month)
- Provider-dependent
WIA P2P Distribution:
- Peers cache popular content
- Automatic distribution
- Free and decentralized
How It Works
============
1. First Request
Visitor -> Your PC -> Content
2. Subsequent Requests (same area)
Visitor -> Nearby peer (cached) -> Content
3. You Go Offline
Visitor -> Multiple peers (cached) -> Content
Cache Strategy
==============
Hot content (popular):
- Cached on many peers
- Fast delivery
- High availability
Cold content (rare):
- Direct from origin
- On-demand caching
- Still accessible
Benefits
========
[OK] Fast delivery (nearby peers)
[OK] High availability (redundancy)
[OK] Free (no CDN costs)
[OK] Scales automatically
[OK] Works even when you sleep
Chapter Summary
- [OK] Personal server runs on your PC with minimal resources
- [OK] P2P mesh network eliminates central point of failure
- [OK] NAT traversal handles network complexity automatically
- [OK] WIA DNS provides free, censorship-resistant domains
- [OK] P2P content distribution replaces expensive CDN