<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>DHT on Mi&amp;Bee Blog</title><link>/en/tags/dht/</link><description>Recent content in DHT on Mi&amp;Bee Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><managingEditor>蓝宝石的傻话</managingEditor><lastBuildDate>Mon, 05 Jun 2023 00:00:00 +0000</lastBuildDate><atom:link href="/en/tags/dht/rss.xml" rel="self" type="application/rss+xml"/><item><title>P2P Network Core Principles</title><link>/en/posts/network/p2p-core-principles/</link><pubDate>Sun, 15 Mar 2020 00:00:00 +0000</pubDate><guid>/en/posts/network/p2p-core-principles/</guid><description>&lt;p&gt;Peer-to-Peer (P2P) networking is a decentralized architecture where every node acts as both a provider (Server) and consumer (Client). This architecture is widely used in file distribution (BitTorrent), cryptocurrency (Bitcoin), decentralized storage (IPFS), and many other domains.&lt;/p&gt;
&lt;h2 id="p2p-vs-client-server-architecture"&gt;P2P vs Client-Server Architecture&lt;/h2&gt;
&lt;p&gt;Before diving into P2P principles, let&amp;rsquo;s understand the fundamental differences through comparison:&lt;/p&gt;
&lt;table&gt;
	&lt;thead&gt;
			&lt;tr&gt;
					&lt;th&gt;Feature&lt;/th&gt;
					&lt;th&gt;Client-Server&lt;/th&gt;
					&lt;th&gt;P2P Network&lt;/th&gt;
			&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tbody&gt;
			&lt;tr&gt;
					&lt;td&gt;Centralization&lt;/td&gt;
					&lt;td&gt;Highly centralized&lt;/td&gt;
					&lt;td&gt;Decentralized / Hybrid&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Single Point of Failure&lt;/td&gt;
					&lt;td&gt;Exists&lt;/td&gt;
					&lt;td&gt;Does not exist&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Scalability&lt;/td&gt;
					&lt;td&gt;Limited by server&lt;/td&gt;
					&lt;td&gt;Linear with node count&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Bandwidth Cost&lt;/td&gt;
					&lt;td&gt;Borne by server&lt;/td&gt;
					&lt;td&gt;Shared by nodes&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Fault Tolerance&lt;/td&gt;
					&lt;td&gt;Low&lt;/td&gt;
					&lt;td&gt;High&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
					&lt;td&gt;Lookup Complexity&lt;/td&gt;
					&lt;td&gt;O(1)&lt;/td&gt;
					&lt;td&gt;O(log N)&lt;/td&gt;
			&lt;/tr&gt;
	&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The core advantage of P2P lies in eliminating single points of bottleneck and failure, at the cost of introducing more complex node discovery and data routing mechanisms.&lt;/p&gt;</description></item><item><title>Kademlia DHT Protocol Deep Dive</title><link>/en/posts/network/kademlia-dht-protocol/</link><pubDate>Wed, 20 Jan 2021 00:00:00 +0000</pubDate><guid>/en/posts/network/kademlia-dht-protocol/</guid><description>&lt;p&gt;Kademlia is one of the most influential DHT (Distributed Hash Table) protocols, proposed by Petar Maymounkov and David Mazières in 2002. It is widely used in IPFS, BitTorrent, Ethereum, and many other systems. Kademlia&amp;rsquo;s revolutionary innovation lies in using XOR (exclusive or) as its distance metric, offering elegant mathematical properties and efficient routing algorithms.&lt;/p&gt;
&lt;h2 id="xor-distance-metric"&gt;XOR Distance Metric&lt;/h2&gt;
&lt;p&gt;Kademlia maps nodes and resources to the same 160-bit identifier space and defines the XOR distance function:&lt;/p&gt;</description></item><item><title>Go P2P Development: From Basics to PubSub</title><link>/en/posts/network/golang-p2p-development/</link><pubDate>Mon, 05 Jun 2023 00:00:00 +0000</pubDate><guid>/en/posts/network/golang-p2p-development/</guid><description>&lt;p&gt;Go&amp;rsquo;s simple concurrency model and fast compilation make it a popular choice for P2P network development. go-libp2p is one of the most complete libp2p implementations and is widely used in large projects like IPFS (Kubo).&lt;/p&gt;
&lt;h2 id="environment-setup"&gt;Environment Setup&lt;/h2&gt;
&lt;div class="code-block-wrapper" data-lang="bash"&gt;
 &lt;div class="code-block-header"&gt;
 &lt;div class="code-block-meta"&gt;&lt;span class="code-language"&gt;bash&lt;/span&gt;&lt;/div&gt;
 
 &lt;button class="copy-button" aria-label="Copy code"&gt;
 &lt;svg class="copy-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"&gt;&lt;rect x="9" y="9" width="13" height="13" rx="2" ry="2"/&gt;&lt;path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/&gt;&lt;/svg&gt;
 &lt;svg class="check-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"&gt;&lt;polyline points="20 6 9 17 4 12"/&gt;&lt;/svg&gt;
 &lt;/button&gt;
 
 &lt;/div&gt;
 &lt;div class="code-block-body"&gt;&lt;div class="highlight"&gt;&lt;div class="chroma"&gt;
&lt;table class="lntable"&gt;&lt;tr&gt;&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code&gt;&lt;span class="lnt"&gt;1
&lt;/span&gt;&lt;span class="lnt"&gt;2
&lt;/span&gt;&lt;span class="lnt"&gt;3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class="lntd"&gt;
&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;go get github.com/libp2p/go-libp2p
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;go get github.com/libp2p/go-libp2p-kad-dht
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;go get github.com/libp2p/go-libp2p-pubsub&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;&lt;code&gt;go.mod&lt;/code&gt; configuration:&lt;/p&gt;</description></item></channel></rss>