Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
libp2p
Search
wshino
May 23, 2019
Technology
1.4k
7
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
libp2p
wshino
May 23, 2019
More Decks by wshino
See All by wshino
Past, Present and Future
wshino
1
500
Superiority of Rust
wshino
3
410
Try Cross Compile Then Fail
wshino
0
180
GORMOS - A high performance and scalable design for decentralized applications -
wshino
4
1.9k
DAppのデプロイ戦略 / DApp Deployment Strategy
wshino
3
1.8k
Sharding
wshino
4
1.2k
Plasma Debit
wshino
2
2.1k
ブロックチェーン技術の登場とスマートコントラクト化する社会
wshino
5
5.4k
Truffle + Drizzle と、Ethereumの概況について
wshino
2
1.3k
Other Decks in Technology
See All in Technology
データエンジニアの次の戦場は "プロセスエンジニアリング"
sansantech
PRO
1
150
QAエンジニアがSoutherを使ってみたの〜10分でわかるSouther〜
mhlyc
0
110
LLM-as-a-Judgeは本当に信頼できるのか――評価器を評価する話
taka_aki
3
1k
AI時代のGraphQL
joere
2
340
企画を Software Factory-ready にする——開発が高速になったとき、PdMの仕事はどう変わったか
yachibit
1
130
AI コーディングと人間の認知スループット / CTO Night & Day 2026 Morning Session / AI Coding and Human Cognitive Throughput
prog893
5
1.5k
ガチで放置できるClaude Code実行環境の作り方.pdf
lamaglama39
1
5.4k
Codex を使った障害対応机上演習の実際
orgachem
PRO
0
270
国際カードブランドルール変更に伴うクレジットカード決済取引仕様変更について
k1style
0
150
Code for Security プロジェクト紹介 2026年10月
yu23ki14
0
120
AI × アーキテクト 第1・2章|生成AIの課題とアーキテクトの素養
daidaidai
1
230
20261017福岡devIO 「AIは"良いダッシュボード"を作れるか?
jtakeda
0
240
Featured
See All Featured
Facilitating Awesome Meetings
lara
57
7.2k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.1k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
1k
Six Lessons from altMBA
skipperchong
29
4.5k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.2k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
720
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
Skip the Path - Find Your Career Trail
mkilby
1
260
Transcript
libp2p Powered by DMM Blockchain Labs 1
自己紹介 - About me @ DMM.com Shinohara Wataru ・DMM.com Blockchain
Engineer ・I really love Roller Coasters. @shinanonozenji_ 2
書籍紹介 - Publishing @ DMM.com 3
libp2pとは @ DMM.com • p2p分散アプリケーションを作るフレームワーク • 元々はIPFSのプロトコル • 今はIPFSから独立したプロジェクト 4
多言語での実装 @ DMM.com • Rust • Go • JavaScript •
Java • Haskell • Python 5 substrate-network-libp2p
p2pおさらい 6
p2pとは @ DMM.com • 対等の者同士が対等な立場で相互にやり取りをおこなう ◦ 対等の者(Peer = Node) •
ネットワークの参加者はクライアント、サーバー両方の役割を担える • システムの中心となる存在がいない ◦ ≠ クライアント/サーバーネットワークモデル • ノードが停止しても一台さえあればサービスが止まることはない 7
p2pの代表的なサービス @ DMM.com • Blockchain • Skype • WebRTC •
BitTorrent 8
p2pのメリット @ DMM.com • 参照性能の向上 ◦ 状態を持つ処理はまた別の困難が存在 • 耐障害性 ◦
一部のノードが障害を起こしてもシステムは停止しない • Overlay Network ◦ 異なるネットワーク間でも同一ネットワークとして通信可能 →中央管理者がいらない 9
p2pアプリケーション開発の問題 @ DMM.com • 実現するために必要な機能が多い ◦ Transport ◦ Discovery ◦
Peer Routing ◦ NAT Traversal(UDP Hole punching...) ◦ and more. 10
NAT Traversal 11
NAT Traversalとは @ DMM.com ネットワークの中から他のネットワークの中へ通信する技術 12 private IP global IP
private IP
NAT Traversalの用語説明 @ DMM.com • NAT ◦ private IP ←→
public IPの変換 • STUN ◦ 外から見た自分のアドレス(Refrective Addrress)を返す • UDP ホールパンチング ◦ STUNで得られたアドレスを使ってコネクションを張る 13
NAT Traversalの用語説明(2) @ DMM.com • ICE(Interactive Connectivity Establishment) (WebRTCで使う) ◦
ホールパンチしてくれる ▪ vanilla(ホールパンチの結果をまとめて送信) ▪ trickle(ホールパンチの結果を逐次送信) • 早くコネクションを張る可能性がある 14
NAT Traversalの困難 @ DMM.com NATは統一規格がない • full cone NAT •
address restricted cone NAT • port restricted cone NAT • sequential port symmetric NAT • random port symmetric NAT ホールパンチができないものもある 15
NAT Traversalの用語説明(3) @ DMM.com • TURN ◦ ホールパンチングができない場合にデータ中継をリレーする 16 TURN
libp2p 17
libp2pは何を解決するか @ DMM.com p2pアプリケーションを実現するために必要なモジュールを提供する 18
• p2pアプリケーション、通信以外の全て • そこは実装しよう libp2pは何を解決しないか @ DMM.com 19
• 効率性 • 可用性 • 発展性 libp2pの主な特徴 @ DMM.com 20
libp2pの主な特徴 @ DMM.com • 効率性 ◦ 基礎となるトランスポートの効率的使用 ◦ 接続の再利用性(ソケットの効率的な利用) ◦
ピア間の通信を1つのコネクションで多重化する ▪ ハンドシェイクのオーバーヘッド回避 ▪ ポートの枯渇回避 21
libp2pの主な特徴 @ DMM.com • 可用性 ◦ ネゴシエーションプロセスで、ピア間でマルチプロトコルとそれぞれの バージョンを使用可能 ◦ 後方互換性
現状のLinuxなどで動作する ◦ 現在のネットワーク技術の全機能を使用可能 22
libp2pの主な特徴 @ DMM.com • 発展性 ◦ NAT Traversal ◦ 接続中継
▪ Relay ◦ 暗号化 23
モジュール @ DMM.com • 必要な機能をモジュールを選択することで実現する • プロトコルの修正があってもモジュールでアップデートできる 24
Relay Protocol @ DMM.com • 暗号化されたTURN ◦ NAT越えできないノードを中継ノードででつなぐ ◦ 通信は暗号化されて身元確認(identity)がある
• 通信間のノードが中間者攻撃できない ◦ secioでend-to-endで暗号化している • 許可すれば他のアプリケーションのlibp2p通信のrelayになれる 25
レイヤー @ DMM.com 26 Application Stream Multiplex Encryption Transport
Transport @ DMM.com • transportでコネクションを確立してconnectionを作成する 27 dial listen connection確立 Connection
Transport
あらゆるプロトコルに対応 @ DMM.com 暗号化されてないプロトコル • TCP • UDP • SCTP(ストリーム処理)
• UDT(UDPベースのデータ転送) • uTP(torrentでデータ転送に使ってる) 28 uTP https://www.bittorrent.org/beps/bep_0029.html
あらゆるプロトコルに対応 @ DMM.com 暗号化されたプロトコル • TLS • QUIC(TCP and TLS
+ HTTP/2 over UDP) • CurveCP(楕円曲線を使った通信) • SSH • Noise ◦ lightning networkのBOLT仕様で利用 29 CurveCP https://curvecp.org/ Noise http://noiseprotocol.org/
自己記述アドレス(マルチアドレス) @ DMM.com • /ip4/90.46.231.22/udp/25000 ◦ IPv4の90.46.231.22でUDP 25000 • /ip6/fe80::0202:b3ff:fe1e:8329/udp/1567/quic
◦ IPv6のfe80::0202:b3ff:fe1e:8329でUDP 1567でQUICを使う 30 QUIC UDP : 1567 IPv6 : fe80::0202:b3ff:fe1e:8329 multiaddr transport
暗号化 @ DMM.com • secio ◦ 通信の暗号化をサポート ◦ 暗号化してないプロトコルも暗号化して通信する ◦
そのうちTLS1.3になるのかな? 31 Application Stream Multiplex Encryption Transport
Stream(仮想双方向チャネル) @ DMM.com • connection自体を使うのではなくその上にstreamを作成する • streamは複数作成できる • connectionを使い回すため 32
stream stream stream Stream Multiplex
Stream Multiplex(多重化、逆多重化) @ DMM.com 複数のstreamを一つのコネクションにまとめる • SPDY • mplex(バックプレッシャーなし) •
yamux(バックプレッシャー付き) 33 stream stream stream Application Stream Multiplex Encryption Transport
Streamの選択 @ DMM.com • streamのプロトコルをmultistreamで複数定義する • 接続の際にmultistream-selectでプロトコルを選択 ◦ 相手がそれにOKしたら接続完了 34
sshです echoです
Swarm @ DMM.com • 複数Transportの管理 • 複数Connectionの保持 • Peerの情報管理(Peer Store)
• ConnectionとStreamのハンドラ 35
Discovery @ DMM.com • 起動時のノード探索 ◦ bootstrapを使用 • ローカルのノード探索 ◦
mDNS(multicast DNS)を使用 • その他 ◦ Kademliaの分散ハッシュテーブルを使用 36 Application Stream Multiplex Encryption Transport
PubSub @ DMM.com • FloodSub ◦ 簡易実装 ◦ 全てのsubscriberにpublishするので帯域を圧迫する可能性 •
GossipSub ◦ メッシュ内に伝播してメッシュ外はgossipプロトコル ◦ gossipはrandomなので到達の不確実性がある(気がする 37
独自プロトコルの作成 @ DMM.com 例えば以下のような独自プロトコルを定義できる • bbq on BBQ Birch test
net on Substrate • dot on Polkadot 38
話さなかったこと - I did not speak @ DMM.com • Network
Layer • Swarmの詳細 ◦ Dial Synchronization System • 諸々のシーケンス 39
総括 - Conclusion @ DMM.com • Network Layer理解不足 • これあればアプリが作れる、アプリ間も繋げやすいぞ
• モジュールを各レイヤーでプラガブルに利用できるのは面白い • コネクション一つを使い回すのは良い ◦ streamの詰まりは起きないのだろうか? • 抽象化が過ぎる 40
参考 @ DMM.com 41 https://github.com/libp2p/specs https://github.com/libp2p/js-libp2p https://qiita.com/kikuchi_kentaro/items/1cfcb8 65b97cd2b309aa https://github.com/multiformats/multiaddr https://www.slideshare.net/iwashi86/webrtcic
e https://www.parity.io/why-libp2p/ https://github.com/libp2p/js-libp2p-floodsub https://github.com/libp2p/go-libp2p-secio/issu es/7 http://www.wata-lab.meijo-u.ac.jp/file/seminar /2006/2006-Semi2-Shoichi_Kuzuya.pdf http://tutorials.jenkov.com/p2p/peer-routing-ta ble.html
Thank you for the attention. Powered by DMM Blockchain Labs
42