From 9d2e6e64fa73205c352586ec8793c34ec265ba5c Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 26 Jun 2015 14:58:48 +0100 Subject: [PATCH 01/18] add initial DHT spec with some questions --- protocol/routing/README.md | 80 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 protocol/routing/README.md diff --git a/protocol/routing/README.md b/protocol/routing/README.md new file mode 100644 index 000000000..b3f0b4f1c --- /dev/null +++ b/protocol/routing/README.md @@ -0,0 +1,80 @@ +IPFS Routing Protocol Spec +========================== + +Authors: David Dias + +Reviewers: + +TODOS: + +----------------------- + +> This spec defines the routing protocol spec, covering `Peer discovery`, `Routing` and the `DHT`. The spec is a **Work In Progress**. + +## Supports + +- Peer discovery through + - mdns + - custom peers list + - random walking on the network +- Routing primitives + - Publish and fetch content (also providing) +- Maintaining partial state of the network + - DHT + - kbucket + +### Overview + +The Routing Protocol is divided in three major components, these are: +- Peer Discovery: Responsible for filling our kbucket with best candidates. +- Interface: Our routing primitives that are offered for the user, such as finding and publishing content, including the storage and lookup of metadata (Providers). +- Peer-to-peer Structured Overlay Network: Algorithm for the implicit network organization, based on [Coral](http://iptps03.cs.berkeley.edu/final-papers/coral.pdf) and [mainlineDHT](http://www.bittorrent.org/beps/bep_0005.html) + +Bootstrapping the routing happens by connecting to a predefined "railing" peers list, shipped with the go-ipfs release and/or by discovery through mDNS. Once at least one peer is found and added to the kbucket, the routing changes to an active state and our peer becomes able to route and receive messages. + +### Peer Discovery + +#### bootstrap peer list + +List with known and trusted peers shipped with IPFS. + +- _How is this list updated?_ +- _Is this list updated periodically_? + +#### random walk + +IPFS issues random Peer lookups periodically to refresh our kbucket if needed. For impl reference, see: https://github.com/ipfs/go-ipfs/blob/master/routing/dht/dht_bootstrap.go#L88-L109. + +#### mDNS + +In addition to known peers and random lookups, IPFS also performs Peer Discovery through mDNS ([MultiCast DNS](https://tools.ietf.org/html/rfc6762)) + +-_How offen do we issue this searches?_ + +### Routing + +For impl reference, check: https://github.com/ipfs/go-ipfs/blob/master/routing/routing.go#L19-L49 + +#### Find a peer + +_When searching for a peer, do we fetch the kbucket from a peer and see which peer we want to ping next or do we ask for a given Id to a peer and that peer replies to us with the best candidate (or itself if it is the case)?_ + +#### Ping + +#### Provide + +#### Get value + +#### Put value + +1. find peer +2. transfer +3. provide + +### DHT + +explain: +- dht/coral, how the algo works +- kbucket +- each time a contact is made with a new peer, we check to see if it is a better candidate for our kbucket +- xor metric From 1feb2cf7ccab75e6042d3c57a9ba741f46c82029 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 26 Jun 2015 14:59:00 +0100 Subject: [PATCH 02/18] add initial DHT spec with some questions --- protocol/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/README.md b/protocol/README.md index 9559a2f14..17eea286d 100644 --- a/protocol/README.md +++ b/protocol/README.md @@ -122,7 +122,7 @@ of implementations. For example: to one of a set of supernodes. This is roughly like federated routing. - **dns:** ipfs routing could even happen over dns. -See more in the routing spec (TODO). +See more in the [routing spec](https://github.com/ipfs/specs/tree/master/protocol/routing). ### Block Exchange -- transfering content-addressed data From 213573677832a7083d56ad1b5137464bb8c6ba08 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 26 Jun 2015 15:07:55 +0100 Subject: [PATCH 03/18] add ping --- protocol/routing/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/protocol/routing/README.md b/protocol/routing/README.md index b3f0b4f1c..076859902 100644 --- a/protocol/routing/README.md +++ b/protocol/routing/README.md @@ -61,6 +61,10 @@ _When searching for a peer, do we fetch the kbucket from a peer and see which pe #### Ping +Ping mechanism (for heartbeats). Ping a peer and log the time it took to answer. + +_what if the Id doesn't exist? Is there any rule for non existing peers? Should we log time for best matches as well?_ + #### Provide #### Get value From 751c906bf8e1feafabf673f7f218e2307be3ea61 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 26 Jun 2015 15:15:28 +0100 Subject: [PATCH 04/18] provinding segment --- protocol/routing/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/protocol/routing/README.md b/protocol/routing/README.md index 076859902..80cb3192a 100644 --- a/protocol/routing/README.md +++ b/protocol/routing/README.md @@ -67,6 +67,15 @@ _what if the Id doesn't exist? Is there any rule for non existing peers? Should #### Provide +Providing is the process of storing/updating the metadata (pointers) of where the blocks of a given file are stored/available in the IPFS network. What this means is that the DHT is not used for block discovery, but for the metadata which identifies where they are, instead. +When a node advertises a block available for download, IPFS stores a record in the DHT with its own Peer.ID. This is termed "providing". the node becomes a "provider". Requesters who wish to retrieve the content, query the DHT (or DSHT) and need only to retrieve a subset of providers, not all of them. (this works better with huge DHTs, and latency-aware DHTs like coral). + +We provide once per block, because every block (even sub-blocks) are independently addressable by their hash. (yes, this is expensive, but we can mitigate the cost with better DHT + record designs, bloom filters, and more) + +There is an optimistic optimization -- which is that if a node is storing a node that is the parent (root/ancestor) of other nodes, then it is much more likely to also be storing the children. So when a requester attempts to pull down a large dag, it first queries the DHT for providers of the root. Once the requester finds some and connects directly to retrieve the blocks, bitswap will optimistically send them the "wantlist", which will usually obviate any more dht queries for that dag. we haven't measured this to be true yet -- we need to -- but in practice it seems to work quite well, else we wouldnt see as quick download speeds. (one way to look at it, is "per-dag swarms that overlap", but it's not a fully correct statement as having a root doesn't necessarily mean a node has any or all children.) + +Providing a block happens as it gets added. Reproviding happens periodically, currently 0.5 * dht record timeout ~= 12 hours. + #### Get value #### Put value From 0e260f7b43ab583aadd500a540404af0b1d9749b Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 26 Jun 2015 19:01:51 +0100 Subject: [PATCH 05/18] put question --- protocol/routing/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protocol/routing/README.md b/protocol/routing/README.md index 80cb3192a..4fa8f1373 100644 --- a/protocol/routing/README.md +++ b/protocol/routing/README.md @@ -78,11 +78,11 @@ Providing a block happens as it gets added. Reproviding happens periodically, cu #### Get value + + #### Put value -1. find peer -2. transfer -3. provide +_not 100% about this happens exactly. From what I understand, the IPFS node that is adding the file, breaks the file into blocks, creates the hashes and provides each single one of them. When do we execute a Put? Replicas are done through "Get", right?_ ### DHT From dad0bb74735f4b9b473b088abb668d9d583bd31c Mon Sep 17 00:00:00 2001 From: David Dias Date: Tue, 30 Jun 2015 12:30:42 -0700 Subject: [PATCH 06/18] separate DHT, discovery and routing specs --- protocol/routing/DHT.md | 28 ++++++++ protocol/routing/README.md | 61 ++++++------------ protocol/routing/discovery.md | 41 ++++++++++++ .../routing/figs/routing-overview.monopic | Bin 0 -> 920 bytes protocol/routing/figs/routing-overview.txt | 6 ++ 5 files changed, 95 insertions(+), 41 deletions(-) create mode 100644 protocol/routing/DHT.md create mode 100644 protocol/routing/discovery.md create mode 100644 protocol/routing/figs/routing-overview.monopic create mode 100644 protocol/routing/figs/routing-overview.txt diff --git a/protocol/routing/DHT.md b/protocol/routing/DHT.md new file mode 100644 index 000000000..0f9ef8935 --- /dev/null +++ b/protocol/routing/DHT.md @@ -0,0 +1,28 @@ +IPFS DHT Protocol Spec +====================== + +Authors: David Dias + +Reviewers: + +TODOS: + +----------------------- + +> + +## Supports + +- Maintaining partial state of the network + - DHT + - kbucket + +## Overview + + + +explain: +- dht/coral, how the algo works +- kbucket +- each time a contact is made with a new peer, we check to see if it is a better candidate for our kbucket +- xor metric diff --git a/protocol/routing/README.md b/protocol/routing/README.md index 4fa8f1373..8f51666c7 100644 --- a/protocol/routing/README.md +++ b/protocol/routing/README.md @@ -9,63 +9,49 @@ TODOS: ----------------------- -> This spec defines the routing protocol spec, covering `Peer discovery`, `Routing` and the `DHT`. The spec is a **Work In Progress**. +> This spec defines the routing protocol spec. Routing offers an interface for the features exposed by `Peer discovery` and `DHT`. The spec is a **Work In Progress**. ## Supports -- Peer discovery through - - mdns - - custom peers list - - random walking on the network - Routing primitives - Publish and fetch content (also providing) - Maintaining partial state of the network - DHT - kbucket -### Overview +## Overview -The Routing Protocol is divided in three major components, these are: -- Peer Discovery: Responsible for filling our kbucket with best candidates. +The Routing Protocol is composed by three componenets, these are: - Interface: Our routing primitives that are offered for the user, such as finding and publishing content, including the storage and lookup of metadata (Providers). -- Peer-to-peer Structured Overlay Network: Algorithm for the implicit network organization, based on [Coral](http://iptps03.cs.berkeley.edu/final-papers/coral.pdf) and [mainlineDHT](http://www.bittorrent.org/beps/bep_0005.html) - -Bootstrapping the routing happens by connecting to a predefined "railing" peers list, shipped with the go-ipfs release and/or by discovery through mDNS. Once at least one peer is found and added to the kbucket, the routing changes to an active state and our peer becomes able to route and receive messages. - -### Peer Discovery - -#### bootstrap peer list - -List with known and trusted peers shipped with IPFS. - -- _How is this list updated?_ -- _Is this list updated periodically_? - -#### random walk - -IPFS issues random Peer lookups periodically to refresh our kbucket if needed. For impl reference, see: https://github.com/ipfs/go-ipfs/blob/master/routing/dht/dht_bootstrap.go#L88-L109. - -#### mDNS +- Peer Discovery: Responsible for filling our kbucket with best candidates. +- Peer-to-peer Structured Overlay Network (DHT): Algorithm for the implicit network organization, based on [Coral](http://iptps03.cs.berkeley.edu/final-papers/coral.pdf) and [mainlineDHT](http://www.bittorrent.org/beps/bep_0005.html) -In addition to known peers and random lookups, IPFS also performs Peer Discovery through mDNS ([MultiCast DNS](https://tools.ietf.org/html/rfc6762)) +``` +┌──────────────┐ +│ routing │ +└──────────────┘ +┌─────────┐┌───┐ +│discovery││DHT│ +└─────────┘└───┘ +``` --_How offen do we issue this searches?_ +In order for routing to work, we first have to pass the bootstrap state. Bootstrapping happens by connecting to a predefined "railing" peers list, shipped with the go-ipfs release and/or by discovery through mDNS. Once at least one peer is found and added to the kbucket, the routing changes to an active state and our peer becomes able to route and receive messages. -### Routing +## Routing For impl reference, check: https://github.com/ipfs/go-ipfs/blob/master/routing/routing.go#L19-L49 -#### Find a peer +### Find a peer _When searching for a peer, do we fetch the kbucket from a peer and see which peer we want to ping next or do we ask for a given Id to a peer and that peer replies to us with the best candidate (or itself if it is the case)?_ -#### Ping +### Ping Ping mechanism (for heartbeats). Ping a peer and log the time it took to answer. _what if the Id doesn't exist? Is there any rule for non existing peers? Should we log time for best matches as well?_ -#### Provide +### Provide Providing is the process of storing/updating the metadata (pointers) of where the blocks of a given file are stored/available in the IPFS network. What this means is that the DHT is not used for block discovery, but for the metadata which identifies where they are, instead. When a node advertises a block available for download, IPFS stores a record in the DHT with its own Peer.ID. This is termed "providing". the node becomes a "provider". Requesters who wish to retrieve the content, query the DHT (or DSHT) and need only to retrieve a subset of providers, not all of them. (this works better with huge DHTs, and latency-aware DHTs like coral). @@ -76,18 +62,11 @@ There is an optimistic optimization -- which is that if a node is storing a node Providing a block happens as it gets added. Reproviding happens periodically, currently 0.5 * dht record timeout ~= 12 hours. -#### Get value +### Get value -#### Put value +### Put value _not 100% about this happens exactly. From what I understand, the IPFS node that is adding the file, breaks the file into blocks, creates the hashes and provides each single one of them. When do we execute a Put? Replicas are done through "Get", right?_ -### DHT - -explain: -- dht/coral, how the algo works -- kbucket -- each time a contact is made with a new peer, we check to see if it is a better candidate for our kbucket -- xor metric diff --git a/protocol/routing/discovery.md b/protocol/routing/discovery.md new file mode 100644 index 000000000..88fac3897 --- /dev/null +++ b/protocol/routing/discovery.md @@ -0,0 +1,41 @@ +IPFS Peer Discovery Protocol Spec +================================= + +Authors: David Dias + +Reviewers: + +TODOS: + +----------------------- + +> + +## Supports + +- Peer discovery through + - mdns + - custom peers list + - random walking on the network + +## Overview + + +### bootstrap peer list + +List with known and trusted peers shipped with IPFS. + +- _How is this list updated?_ +- _Is this list updated periodically_? + +### random walk + +IPFS issues random Peer lookups periodically to refresh our kbucket if needed. For impl reference, see: https://github.com/ipfs/go-ipfs/blob/master/routing/dht/dht_bootstrap.go#L88-L109. + +### mDNS + +In addition to known peers and random lookups, IPFS also performs Peer Discovery through mDNS ([MultiCast DNS](https://tools.ietf.org/html/rfc6762)) + +-_How offen do we issue this searches?_ + + diff --git a/protocol/routing/figs/routing-overview.monopic b/protocol/routing/figs/routing-overview.monopic new file mode 100644 index 0000000000000000000000000000000000000000..631136ca66cc20e3d0fede6347a0cdb531ad8507 GIT binary patch literal 920 zcmV;J184mIO;1iwP)S1pABzY8000000t4k(%W|7A6#bQq)?@~WM{IA~Mc19~IvGZQ z3~DgA5_Xb$^6$M8k_^~MoCo7cvOrc8=|0YV9KjAX=^vK05-oOWdKsum+K8Nqq~&+4 zN?L&y2zjVwcWpu|UeqgAw`k#eC~N8#=1E$yI%hdrv|_`|PF_o%GrJ^9nm4zd#7-P- zTbh*=j@mr~t*Ox}z&KhLn~I90+kh6Khn9k_SVHTpY(yg15;iOAF+n3amF(nHO?IO! zT+&K{uDr?m$6!Or^PJUggYuy}nbPd05Y48}llFcM))H{MEn%f7-S*xlRx79WV9-Ki zrOqZCmWl7+XqHRKlp5djk#$P)f1m_m>;?B6lPJ2#ex!1QtYaODE9vc`R#t>Bl+|=>D znGl{XHLwbpSkjCoVCXm%hOSqK>9wy84aln5GFNLVItj~p+e4@?(1l`VkIP%eI>+>% z7CF6gSXM)09}H-|LdT^po*kywc-Lk8?d@AAYVMjBzui^3a@|3!QJq%bwpj?v)`Xy<}Qev;ZrxkxcN5MMo!! zhDv!0qPam)!jl(5DGL+VHQ0$$-%5SbL1>qqwBCaL_ zlYDHlntvLyiq6he!O2`j!t-*~+z=A+k?S^QVrh&7UxTYi^p0Fbf*1Fh`Ke8N{<~B(URw)yjOJe;m*c?3c1gp+S>n)XoEcJl_JR74o z5Y_=3Ibw-l3 Date: Tue, 30 Jun 2015 16:54:16 -0700 Subject: [PATCH 07/18] landing ideas --- protocol/figs/overview.monopic | Bin 0 -> 2548 bytes protocol/figs/overview.txt | 21 ++++++++ protocol/layers.md | 85 +++++++++++++++++++++++++++++++++ protocol/routing/README.md | 2 + 4 files changed, 108 insertions(+) create mode 100644 protocol/figs/overview.monopic create mode 100644 protocol/figs/overview.txt create mode 100644 protocol/layers.md diff --git a/protocol/figs/overview.monopic b/protocol/figs/overview.monopic new file mode 100644 index 0000000000000000000000000000000000000000..598bf1d8b8b7199d67d22744194a4235b649b74e GIT binary patch literal 2548 zcmV`kcKmsdA^ zn9S+zo9?tKX8L(gq*jHPg6MtH@6u$m(tQGVIBt_2*0oDCdiwaOoDqj12&KU|4&iu^ z)_gXt5kbM0p&ViohDP)o_H~Pk4ArY+4p+!u#UdRUphud0K31=PJw_SrUnG$T;ms7JH9->3N|Rn1g~=d^w@ z%gbz&y06MzvMIjX8f|q+RVC|PqF!~+bXvWyTh%>G^6m3JIjrmh;EqP%;gCG0t0Z6V zibHEuT!5o`H0^ag`(pi7_wXUvmuVj{cG+f==KcXa2K(lHvi`a~6wkSrLTcdEPJOf8 z`NvxirMVtdLyTnGoiYqPIf{n|Got`T5V%2=+5c1{0ON>h4f}kr9#*fa-jX&^x zbr;-Z997z(#-XN0cY^CLbJe;k{o7J}pMIjgPwV24Ys#ah8OPWbn-TSBamcorq98z# zp{RZJz3$wXE!H|7Pd&^`H>Xzi4>Rv=No>%CpLJ7^bs>hXfLsAOL8KeUJc&VVRs9%W% z^uAaywL6qR4dUKsxf)WXNWV9)zYAI1!`bEq+H9YDs&<6-Pe#Fwa^V#C6DQ6-kh zxQ~0_hwGgZawE3{@nZDw5$;5oO_g?hsG%o3`ShGA4{u<-;S)s#3MgFG63aKsF0jfJlc7; zB?g*R;z~Yl0L5*{NG;ZubZ8CO*>*&~Ftd@NDf&y9*$53=*?7px=FZUN&a&o??Klf) zVYizbXxi4KZcGF!~X^P(M}j&j#^ z)Z?)yx?zJAHdZ0b=i7LPS1deS_=3Q2x!H(^O0b8)oT4~TpG}YZmdiU!^Nl!fuWH_l z?D}PJzg%yty6%JRHDBwAesFfA1uO-fY;*B@;8Olvz|5KXwL8iAj=X{7V>v#V3iupi zZw=H1Z)$l<%NtrgKg-pu*yc-1AJiDMtAUU8t!IQmSW)Yzza{y%q%_LuSRH(EqGiY* z6N}mY7>ol2e`%O{1zI5Pf{+LYIWe7|GA6<$5{RpdJHKNOv%#n{^wI*NkP+tNc1A^* zAvr^Y8R9WEFvSZ5vWN({A&5_2eo9~XY$Z59u~LLXUveJUe5wIvQE!^m_jP^Wo3t8x zJp#SlBk)phu*}u9?E$4W$;Rf`*c2O^VPg|)eg#>Ld4p&n7SdgHe?7 zU=kN$F>&V;4u-L1JUy!2WDe^(lKqpC5~Ki;PY!+pqrPHrBc=2MM} zzqVS?z83?7I+97DE;sM9zy#RT>|3_j{97x#>_-nvk73|ej#udJ^%Ht|vmnsTUH;T|$S_=X5gnTz?tI)Atm64aCF( zl^}LYAwo1{5;5lqVa^l6oF|0IfF@GYoE#k@L}v&Q!ZGHNyh7`Gh?D3LCrRgAla8en z+ziJ+?dC=@kd)yWNQyBGgeab9EQmp29nTMLg!A@uK5e}6qVY8rzazUJ5!ofA8`(WC zzQ#_WVi#H<&OJyR^d>iw3QLwug~j2{CW`|FGH{?nvq-pezVKCUSu?@Gaa-1WLI&~~ z8P+6nW>a%0LBP;L(>8^pLksjAp#?fBv>?LefyEQ;M5WuBs3Dn{>?R{0R}iyIb?>~) z>np7tnpN%Kw7)ItpZ9V_hJ%1ahTFYG!UcLE8bI8X&)v@^11TLkOX>KS(Q}LE24g}e z?zL7o+2%8b!X*~LK!+R1X#pO_LhXBH0n;0<&RK>dlY7($0mu*ph@HZr*H1 z-fq{?`sV1^ChT(?r@5J2_2o`;gK;n;mdT;bt+SIUIT$9$XK9&~Dr z{4|k(`7w0DXGBiet$*y+KXzaVy9^`DZUZ#ocu~xR(ENP|2$AX8)2(xgX8nT$u&don zrExQjaV>clNE|K-!UF|vaJaME5Mq-YRPjWQH$m;qHW-CFa8t~7$&+wrupt!B-$g*L zGU&!e$K1Sn(ElbWYW=Go_wRfHM%r2}j&{2te1;q&y~W@p$J?tVk_HGr!8gsSum1 this is a temporary doc, just so I can write down all the spec/notes that has been talked and iterate over it until we figure out how to organize it. + +# Layers + +``` + ┌──────────────────────────────────────────────┐ + │ MerkleDAG │ + └──────────────────────────────────────────────┘ + ▷ ┌──────────────────────────────────────────────┐ + │ │ bitswap │ +exchange│ └──────────────────────────────────────────────┘ + │ ┌──────────────────────────────────────────────┐ + │ │ host │ + ▷ └──────────────────────────────────────────────┘ + ▷ ┌──────────────────────────────────────────────┐ + │ │ routing │ + routing│ └──────────────────────────────────────────────┘ + │ ┌────────────────────┐ ▲ ┌ ─ ─ ─ ─ ─ ─ ─ ─ + │ │ swarm │ │ ┌───────────────┐ + │ │ │◀─┴─────┤│ discovery │ + │ │ │ └───────────────┘ + ▷ └────────────────────┘ └ ─ ─ ─ ─ ─ ─ ─ ─ + ▷ ┌──────────┐┌────────┐ + │ │connection││protocol│ + network│ │ ││muxing │ + ▷ └──────────┘└────────┘ +``` + +## MerkleDAG layer + +## exchange layer + +### bitswap + +### host + +- holds connections open +- announces block interest to connections open +- api + - .openStream() + +## routing layer + +### routing + +![](https://cldup.com/gifxf20TnJ-3000x3000.png) + +- routing interface +- DHT (Kademlia) +- mDNS +- Delegated +- Tracker + +### discovery + +![](https://cldup.com/q3JsosI5zo-3000x3000.png) + +### swarm + +![](https://cldup.com/As4HG0h4d9-3000x3000.png) + +## network layer + +### protocol muxing + +![](https://cldup.com/o8CRUe2Y2U-1200x1200.png) + +### connection + +![](https://cldup.com/JpaKDIUxRS-1200x1200.png) + +### nat traversal + +![](https://cldup.com/3KMuGu3tEb-2000x2000.png) + +# execution example + + + +# refs + +- https://github.com/ipfs/specs/pull/15/files +- https://github.com/ipfs/go-ipfs/blob/master/routing/dht/dht.go +- https://github.com/ipfs/go-ipfs/blob/master/p2p/host/host.go +- https://github.com/ipfs/go-ipfs/blob/master/routing/dht/notif.go diff --git a/protocol/routing/README.md b/protocol/routing/README.md index 8f51666c7..e4c0a1e12 100644 --- a/protocol/routing/README.md +++ b/protocol/routing/README.md @@ -43,6 +43,8 @@ For impl reference, check: https://github.com/ipfs/go-ipfs/blob/master/routing/r ### Find a peer +Finding a peer happens through an iterative process. We query the best candidate in our kbucket for the awarness of the peer we are looking for, if that peer isn't the ideal candidate, it will return 3 possible candidates from his kbucket and it will query those to check for the best candidate. We repeat the process until we find that peer + _When searching for a peer, do we fetch the kbucket from a peer and see which peer we want to ping next or do we ask for a given Id to a peer and that peer replies to us with the best candidate (or itself if it is the case)?_ ### Ping From aae56f2917a7a3ca1c44d668168766426000c0ba Mon Sep 17 00:00:00 2001 From: David Dias Date: Sun, 5 Jul 2015 17:42:07 -0700 Subject: [PATCH 08/18] layers --- protocol/layers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/layers.md b/protocol/layers.md index fa6eb45d5..2bd57867f 100644 --- a/protocol/layers.md +++ b/protocol/layers.md @@ -41,7 +41,7 @@ exchange│ └───────────────────── ## routing layer -### routing +### router ![](https://cldup.com/gifxf20TnJ-3000x3000.png) From 2546f85710f4b27bd729637f96d81f347c2db30c Mon Sep 17 00:00:00 2001 From: David Dias Date: Sun, 5 Jul 2015 18:30:54 -0700 Subject: [PATCH 09/18] make swarm part of the network layer and put NAT traversal, connection, and protocol muxing as building blocks of swarm --- protocol/layers.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/protocol/layers.md b/protocol/layers.md index 2bd57867f..eb444548f 100644 --- a/protocol/layers.md +++ b/protocol/layers.md @@ -55,21 +55,21 @@ exchange│ └───────────────────── ![](https://cldup.com/q3JsosI5zo-3000x3000.png) +## network layer + ### swarm ![](https://cldup.com/As4HG0h4d9-3000x3000.png) -## network layer - -### protocol muxing +#### protocol muxing ![](https://cldup.com/o8CRUe2Y2U-1200x1200.png) -### connection +#### connection ![](https://cldup.com/JpaKDIUxRS-1200x1200.png) -### nat traversal +#### nat traversal ![](https://cldup.com/3KMuGu3tEb-2000x2000.png) From a601ddc62f47bc39ef6fd3e5ae98d5057830d6ba Mon Sep 17 00:00:00 2001 From: David Dias Date: Sun, 5 Jul 2015 18:35:29 -0700 Subject: [PATCH 10/18] some notes on swarm --- protocol/layers.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/protocol/layers.md b/protocol/layers.md index eb444548f..f822b4b9c 100644 --- a/protocol/layers.md +++ b/protocol/layers.md @@ -61,6 +61,14 @@ exchange│ └───────────────────── ![](https://cldup.com/As4HG0h4d9-3000x3000.png) +swarms offers the API for routing layer be able to open "streams" with other peers. The API should look like: + +- `.openStream(multiaddr, protocol)` +- `.registerHandle(protocol, cb)` + +swarm holds the collection of connections and respective open streams on top of these connections (for reusing purposes) +a connection should be an abstraction of a socket where spdy was already negotiated + #### protocol muxing ![](https://cldup.com/o8CRUe2Y2U-1200x1200.png) From 61bfe395745b2ab81f5f17601a32cdd631a394dd Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 17 Jul 2015 17:08:49 -0700 Subject: [PATCH 11/18] add chapters numbers to sections on the readme so it is more clear how they are separated --- protocol/README.md | 54 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/protocol/README.md b/protocol/README.md index f67822978..75cdebc3b 100644 --- a/protocol/README.md +++ b/protocol/README.md @@ -1,22 +1,31 @@ -# IPFS Protocol Spec (WIP!) +IPFS Protocol Spec +================== -Authors: [@jbenet](http://github.com/jbenet) +> **This spec is an Work In Progress (WIP)** + +Authors: + +- [@jbenet](http://github.com/jbenet) Reviewers: * * * -This [spec](../) document defines the IPFS protocol stack, the subsystems, the +This spec document defines the IPFS protocol stack, the subsystems, the interfaces, and how it all fits together. It delegates non-interface details to other specs as much as possible. This is meant as a top-level view of the protocol and how the system fits together. - Note, this document is not meant to be an introduction of the concepts in IPFS and is not recommended as a first pass to understanding how IPFS works. For that, please refer to the [IPFS paper](http://static.benet.ai/t/ipfs.pdf). -## IPFS and the Merkle DAG +# Index + +- []() +- []() + +## 1. IPFS and the Merkle DAG At the heart of IPFS is the MerkleDAG, a directed acyclic graph whose links are hashes. This gives all objects in IPFS useful properties: @@ -41,7 +50,7 @@ publish, distribute, serve, and download merkledags. It is the authenticated, decentralized, permanent web. -## Nodes and Network Model +## 2. Nodes and Network Model The IPFS network uses PKI based identity. An "ipfs node" is a program that can find, publish, and replicate merkledag objects. Its identity is defined @@ -54,7 +63,7 @@ nodeID := multihash(publicKey) TODO: constraints on keygen. -### multihash and upgradeable hashing +### 2.1 multihash and upgradeable hashing All hashes in ipfs are encoded with [multihash](https://github.com/jbenet/multihash/), a self-describing hash @@ -75,7 +84,7 @@ sha3 ``` -## The Stack +## 3. The Stack IPFS has a stack of modular protocols. Each layer may have multiple implementations, all in different modules. This spec will only address the @@ -94,7 +103,7 @@ IPFS has five layers: These are briefly described bottom-up. -### Network -- connecting to peers +### [3.1 Network](network) The **network** provides point-to-point transports (reliable and unreliable) between any two IPFS nodes in the network. It handles: @@ -105,7 +114,7 @@ between any two IPFS nodes in the network. It handles: See more in the [network spec](network). -### Routing -- finding peers and data +### [3.2 Routing -- finding peers and data](routing) The IPFS **Routing** layer serves two important purposes: - **peer routing** -- to find other nodes @@ -124,7 +133,7 @@ of implementations. For example: See more in the [routing spec](https://github.com/ipfs/specs/tree/master/protocol/routing). -### Block Exchange -- transfering content-addressed data +### [3.3 Block Exchange -- transfering content-addressed data](exchange) The IPFS **Block Exchange** takes care of negotiating bulk data transfers. Once nodes know each other -- and are connected -- the exchange protocols @@ -137,7 +146,7 @@ of implementations. For example: of BitTorrent to work with arbitrary (and not known apriori) DAGs. - **HTTP:** a simple exchange can be implemented with HTTP clients and servers. -### Merkledag -- making sense of data +### [3.4. Merkledag -- making sense of data](../merkledag) [As discussed above](#IPFS-and-the-Merkle-DAG), the IPFS **merkledag** is the datastructure at the heart of IPFS. It is an @@ -170,7 +179,7 @@ on top of the merkledag, such as: See more in the merkledag spec (TODO). -### Merkledag Paths +### [3.4.1 Merkledag Paths](../merkledag) The merkledag is enough to resolve paths: @@ -186,7 +195,7 @@ See more in the path resolution spec (TODO). ![](../media/ipfs-resolve/ipfs-resolve.gif) -### Naming -- PKI namespace and mutable pointers +### [3.5 Naming -- PKI namespace and mutable pointers]() IPFS is mostly concerned with content-addressed data, which by nature is immutable: changing an object would change its hash -- and thus its @@ -209,7 +218,7 @@ See more in the namin spec (TODO). -## Applications and Datastructures -- on top of IPFS +## [4. Applications and Datastructures -- on top of IPFS]() The stack described so far is enough to represent arbitrary datastructures and replicate them accross the internet. It is also enough to build and @@ -222,7 +231,7 @@ them to the rest of the world using any of the tools that understand IPFS. See more in the datastructures and applications specs (TODO). -### unixfs -- representing traditional files +### [4.1 unixfs -- representing traditional files]() The unix filesystem abstractions -- files and directories -- are the main way people conceive of files in the internet. In IPFS, `unixfs` is a datastructure @@ -235,7 +244,7 @@ to carry over information like: See more in the unixfs spec (TODO). -## Lifetime of fetching an object. +## [5 Lifetime of fetching an object.]() Suppose we ask an IPFS node to retrieve @@ -253,11 +262,7 @@ Then, the IPFS node resolves the components. The first component in an `/ipfs/...` path is always a multihash. The rest are names of links, to be resolved into multihashes. - - - - -## IPFS User Interfaces +## [6 IPFS User Interfaces]() IPFS is not just a protocol. It is also a toolset. IPFS implementations include various tools for working with the merkledag, how to publish @@ -271,9 +276,10 @@ design and implementation. Examples: - The IPFS libs - implementations in various languages - The IPFS gateways - nodes in the internet that serve HTTP over IPFS -## ~~WIP~~ +* * * + +### WIP Stack Dump: -WIP Stack Dump: - How the layers fit together - How they call on each other - Mention all the ports From c67ca713f25833d98c1452f436ff30953995a4ca Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 18 Jul 2015 11:09:17 -0700 Subject: [PATCH 12/18] moved the network layer part to its own spec/readme --- protocol/layers.md | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/protocol/layers.md b/protocol/layers.md index f822b4b9c..c41e10ce8 100644 --- a/protocol/layers.md +++ b/protocol/layers.md @@ -55,39 +55,3 @@ exchange│ └───────────────────── ![](https://cldup.com/q3JsosI5zo-3000x3000.png) -## network layer - -### swarm - -![](https://cldup.com/As4HG0h4d9-3000x3000.png) - -swarms offers the API for routing layer be able to open "streams" with other peers. The API should look like: - -- `.openStream(multiaddr, protocol)` -- `.registerHandle(protocol, cb)` - -swarm holds the collection of connections and respective open streams on top of these connections (for reusing purposes) -a connection should be an abstraction of a socket where spdy was already negotiated - -#### protocol muxing - -![](https://cldup.com/o8CRUe2Y2U-1200x1200.png) - -#### connection - -![](https://cldup.com/JpaKDIUxRS-1200x1200.png) - -#### nat traversal - -![](https://cldup.com/3KMuGu3tEb-2000x2000.png) - -# execution example - - - -# refs - -- https://github.com/ipfs/specs/pull/15/files -- https://github.com/ipfs/go-ipfs/blob/master/routing/dht/dht.go -- https://github.com/ipfs/go-ipfs/blob/master/p2p/host/host.go -- https://github.com/ipfs/go-ipfs/blob/master/routing/dht/notif.go From 6c508c6e91498ec7927c34318fd88e8b34932788 Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 18 Jul 2015 11:12:01 -0700 Subject: [PATCH 13/18] update network spec to latest --- protocol/network/README.md | 161 +++++++++++++++---------- protocol/network/figs/overview.monopic | Bin 0 -> 2011 bytes protocol/network/figs/overview.txt | 27 +++++ 3 files changed, 122 insertions(+), 66 deletions(-) create mode 100644 protocol/network/figs/overview.monopic create mode 100644 protocol/network/figs/overview.txt diff --git a/protocol/network/README.md b/protocol/network/README.md index a5141877f..72857ed15 100644 --- a/protocol/network/README.md +++ b/protocol/network/README.md @@ -1,20 +1,26 @@ -# IPFS Protocol Network Spec or `libp2p` +IPFS Protocol Network Spec +========================= -Authors: [Juan Benet](http://github.com/jbenet) +> This spec is a Work In Progress (WIP) -Reviewers: +Authors: +- [Juan Benet](http://github.com/jbenet) -TODOS: -- incorporate peer-routing, as discussed in https://github.com/ipfs/specs/issues/1 +Reviewers: * * * -This [spec](../../) describes the IPFS network protocol. The network layer -provides point-to-point transports (reliable and unreliable) between any two -IPFS nodes in the network. +This describes the IPFS network protocol. The network layer provides point-to-point transports (reliable and unreliable) between any two IPFS nodes in the network. + +# Index +- [1. Introduction and Goals]() +- [2. Requirements]() + - [2.1 NAT traversal] () +- [3. Datastructures]() +- ... -## Supports +## 1. Introduction and Goals It SHOULD support: - [NAT traversal](#NAT-traversal) @@ -23,35 +29,21 @@ It SHOULD support: - [Multiple Transports](#Transport-Agnostic) - [Multi-Multiplexing](#Multi-multiplexing) +## 2. Requirements -### NAT traversal +### 2.1 NAT traversal -Network Address Translation is ubiquitous in the internet. Not only are most -consumer devices behind many layers of NATs, but most datacenter nodes are -often behind NAT for security or virtualization reasons. As we move into -containerized deployments, this is getting worse. IPFS implementations SHOULD -provide a way to traverse NATs, otherwise it is likely that operation will be -affected. Even nodes meant to run with real IP addresses must implement NAT -traversal techniques, as they may need to establish connections to peers -behind NAT. +Network Address Translation is ubiquitous in the internet. Not only are most consumer devices behind many layers of NATs, but most datacenter nodes are often behind NAT for security or virtualization reasons. As we move into containerized deployments, this is getting worse. IPFS implementations SHOULD provide a way to traverse NATs, otherwise it is likely that operation will be affected. Even nodes meant to run with real IP addresses must implement NAT traversal techniques, as they may need to establish connections to peers behind NAT. -IPFS accomplishes full NAT traversal using an ICE-like protocol. It is not -exactly ICE, as ipfs networks provide the possibility of relaying communications over the IPFS protocol itself, for coordinating hole- -punching or even relaying communication. +IPFS accomplishes full NAT traversal using an ICE-like protocol. It is not exactly ICE, as ipfs networks provide the possibility of relaying communications over the IPFS protocol itself, for coordinating hole-punching or even relaying communication. -It is recommended that implementations use one of the many NAT traversal -libraries available, such as `libnice`, `libwebrtc`, or `natty`. However, -NAT traversal must be interoperable. +It is recommended that implementations use one of the many NAT traversal libraries available, such as `libnice`, `libwebrtc`, or `natty`. However, NAT traversal must be interoperable. -### Relay +### 2.2 Relay -Unfortunately, due to symmetric NATs, container and VM NATs, and other -impossible-to-bypass NATs, IPFS MUST fallback to relaying communication -to establish a full connectivity graph. To be complete, implementations -MUST support relay, though it SHOULD be optional and able to be turned -off by end users. +Unfortunately, due to symmetric NATs, container and VM NATs, and other impossible-to-bypass NATs, IPFS MUST fallback to relaying communication to establish a full connectivity graph. To be complete, implementations MUST support relay, though it SHOULD be optional and able to be turned off by end users. -### Encryption +### 2.3 Encryption Communications on IPFS may be: @@ -69,23 +61,13 @@ We recommend that: IPFS uses cyphersuites like TLS. -**NOTE:** we do not use TLS directly, because we do not want the CA system -baggage. Most TLS implementations are very big. Since the IPFS model begins -with keys, IPFS only needs to apply ciphers. This is a minimal portion of the -whole TLS standard. +**NOTE:** we do not use TLS directly, because we do not want the CA system baggage. Most TLS implementations are very big. Since the IPFS model begins with keys, IPFS only needs to apply ciphers. This is a minimal portion of the whole TLS standard. -### Transport Agnostic +### 2.4 Transport Agnostic -IPFS is transport agnostic, so it can run over any transport protocol. It does -not even depend on IP; it may run on top of NDN, XIA, and other new internet -architectures. +IPFS is transport agnostic, so it can run over any transport protocol. It does not even depend on IP; it may run on top of NDN, XIA, and other new internet architectures. -In order to reason about possible transports, IPFS uses -[multiaddr](https://github.com/jbenet/multiaddr), a self-describing addressing -format. This makes it possible for IPFS to treat addresses opaquely everywhere -in the system, and have support various transport protocols in the network -layer. The actual format of addresses in IPFS is `ipfs-addr`, a multiaddr that -ends with an ipfs nodeid. For example, these are all valid `ipfs-addrs`: +In order to reason about possible transports, IPFS uses [multiaddr](https://github.com/jbenet/multiaddr), a self-describing addressing format. This makes it possible for IPFS to treat addresses opaquely everywhere in the system, and have support various transport protocols in the network layer. The actual format of addresses in IPFS is `ipfs-addr`, a multiaddr that ends with an ipfs nodeid. For example, these are all valid `ipfs-addrs`: ``` # ipfs over tcp over ipv6 (typical tcp) @@ -104,19 +86,13 @@ ends with an ipfs nodeid. For example, these are all valid `ipfs-addrs`: /ether/ac:fd:ec:0b:7c:fe/ipfs/QmYJyUMAcXEw1b5bFfbBbzYu5wyyjLMRHXGUkCXpag74Fu ``` -**Note:** at this time, no unreliable implementations exist. The protocol's -interface for defining and using unreliable transport has not been defined. +**Note:** at this time, no unreliable implementations exist. The protocol's interface for defining and using unreliable transport has not been defined. **TODO:** define how unreliable transport would work. base it on webrtc. +### 2.5 Multi-Multiplexing -### Multi-Multiplexing - -The IPFS Protocol is a collection of multiple protocols available at the same -IPFS Node. In order to conserve resources, and to make connectivity easier, -the IPFS network layer can perform all its operations through a single TCP or -UDP port, depending on the transports used. IPFS can multiplex its many -protocols through point-to-point connections. This multiplexing is for both +The IPFS Protocol is a collection of multiple protocols available at the same IPFS Node. In order to conserve resources, and to make connectivity easier, the IPFS network layer can perform all its operations through a single TCP or UDP port, depending on the transports used. IPFS can multiplex its many protocols through point-to-point connections. This multiplexing is for both reliable streams and unreliable datagrams. IPFS is pragmatic. It seeks to be usable in as many settings as possible, to @@ -154,26 +130,27 @@ ensures that complex user or application constraints do not rule out IPFS as an option. -## Datastructures +## 3. Datastructures The network protocol deals with these datastructures: - a `PrivateKey`, the private key of a node. - a `PublicKey`, the public key of a node. - a `PeerID`, a hash of a node's public key. -- a `Node`[*], has a PeerID, and open connections to other `Nodes`. +- a `Node`[1], has a PeerID, and open connections to other `Nodes`. - a `Connection`, a point-to-point link between two Nodes (muxes 1 or more streams) - a `Stream`, a duplex message channel. -[*] currently called `PeerHost` in go-ipfs. +[1] currently called `PeerHost` in go-ipfs. + +## 4. Interface -## Interface +The network protocol's interface has two parts:A -The network protocol's interface has two parts: 1. the _client interface_, for clients (e.g. higher layers of IPFS) 2. the _service interface_, for remote peers (e.g. other IPFS nodes) -### Client Interface +### 4.1 Client Interface The **Client Interface** is exposed to the higher layers of IPFS. It is the entry point for other parts to open + handle streams. @@ -221,7 +198,7 @@ type StreamHandler func (Stream) TODO: incorporate unreliable message / packet streams. -### Protocol Interface +### 4.2 Protocol Interface The network protocol consists of: @@ -246,9 +223,9 @@ for interoperability. These are the default (TODO: unreliable transport) -## Properties +## 5 Properties -### Communication Model - Streams +### 5.1 Communication Model - Streams The Network layer handles all the problems of connecting to a peer, and exposes simple bidirectional streams. Users can both open a new stream @@ -282,7 +259,7 @@ stream.Read(buf2) // read what was sent back fmt.Println(buf2) // print what was sent back ``` -### Ports - Constrained Entrypoints +### 5.2 Ports - Constrained Entrypoints In the internet of 2015, we have a processing model where a program may be running without the ability to open multiple -- or even single -- network @@ -299,7 +276,7 @@ through Websockets or WebRTC. In a sense, the role of the TCP/UDP network stack -- i.e. multiplexing applications and connections -- may now be forced to happen at the application level. -### Transport Protocols +### 5.3 Transport Protocols IPFS is transport agnostic. It can run on any transport protocol. The `ipfs-addr` format (which is an ipfs-specific @@ -334,7 +311,7 @@ Some of the transport protocols we will be using: - Websockets - TCP Remy -### Non-IP Networks +### 5.4 Non-IP Networks Efforts like [NDN](http://named-data.net) and [XIA](http://www.cs.cmu.edu/~xia/) are new architectures for the internet, @@ -343,3 +320,55 @@ will be able to operate on top of these architectures trivially, as there is no assumptions made about the network stack in the protocol. Implementations will likley need to change, but changing implementations is vastly easier than changing protocols. + +## 6 Overview of the Software Stack + +The network is abstracted through the swarm which presents a simplified interface for the remaining layers to have access to the network. This interface should look like: + +- `.openStream(peer, protocol)` - peer should contain the ID of the peer and its respective multiaddrs known. +- `.registerHandler(protocol, handlerFunc)` - enable a protocol to be registered, so that another peer can open a stream to talk with us to that specific protocol +- `.listen()` - to start listening for incoming connections and therefore opening of streams + +The following figure represents how the network level pieces, are tied together: + +``` +┌ ─ ─ ─ ─ ┌ ─ ─ ─ ─ ┌ ─ ─ ─ ─ ┌───────────┐ + mounted │ mounted │ mounted ││Identify │ +│protocol │protocol │protocol │(mounted │ + 1 │ 2 │ ... ││ protocol) │ +└ ─ ─ ─ ─ └ ─ ─ ─ ─ └ ─ ─ ─ ─ └───────────┘ +┌─────────────────────────────────────────┐ +│ swarm │ +└─────────────────────────────────────────┘ +┌─────────────────────────────────────────┐ +│ connection │ +└─────────────────────────────────────────┘ +┌───────────────┐┌───────────┐┌───────────┐ +│Transport ││multistream││ stream │ +│(TCP, UDP, etc)││ ││ muxer │ +└───────────────┘└───────────┘│┌ ─ ─ ─ ─ ┐│ + │ spdy │ + │└ ─ ─ ─ ─ ┘│ + │┌ ─ ─ ─ ─ ┐│ + │ multiplex │ + │└ ─ ─ ─ ─ ┘│ + │┌ ─ ─ ─ ─ ┐│ + │ QUIC │ + │└ ─ ─ ─ ─ ┘│ + │┌ ─ ─ ─ ─ ┐│ + │ others │ + │└ ─ ─ ─ ─ ┘│ + └───────────┘ +``` + +**Identify** is one of the protocols mounted on top of swarm, our Connection handler, however, it follows and respects the same pattern as any other protocol when it comes to mounting it on top of swarm. Identify enables us to trade listenAddrs and observedAddrs between peers, this is crucial for the working of IPFS, since every socket open implements REUSEPORT, an observedAddr by another peer can enable a third peer to connect to us, since the port will be already open and redirect to us on a NAT. + +The stream muxer must implement the interface offered by [abstract-stream-muxer](https://github.com/diasdavid/abstract-stream-muxer). + +Every socket open (through the transport chosen), is "multistream'ed" into the stream muxer used, once a stream muxer connection + +## 7 Implementation Details + +Identify stream requests should be issued by the listenner as soon as it receives a valid connection, otherwise the listenner won't be able to identify who is that stream comming, disabling its ability for connection reuse. Identify is responsible for 'tagging' the incomming connection on swarm with the right Id. + +A peer only updates its own multiaddrs list with observedAddrs if it receives the same observedAddr twice, avoiding addr explosion (a phenomenon that happens when both peers are behind symmetric NAT). diff --git a/protocol/network/figs/overview.monopic b/protocol/network/figs/overview.monopic new file mode 100644 index 0000000000000000000000000000000000000000..c54bb898fde4f2ca56b1fbbf8995049099f03c14 GIT binary patch literal 2011 zcmV<12PF9aO;1iwP)S1pABzY8000000t4+_OK;;g5dJF*omxO!h)#ISBjMZBk;O@6CZR#+Q#yP3?&VxvqW z|N0!eC$`bGdGG*y$%~uJ4s0?;ftt*R@Qq6It1e4jlrEJnb@ZsZ2*rjEwpU`W)Lxmr za(!)DglRA#rZU)wx9Z7O>t!}Iob;HkmzjRAR{u4;_YERsU9|X9oZI-+aDTwCD04l6>re!r()x=6+vZ*vpTOldPC6%c|2|PNN+@MvI2es+@f>EnH-)TJ2N$GM~>?(GZwExHqTS?8|jkZj1TE zh%dU*LwB}W>L=IBhP*?h3e%}p7}<4S^jd`=j&iZEnu(G)iJ((;{;x9ljbdUDU^{iA z-;d_c&C5+az6qd=9i}~LR9+f=1^b7Eu3g{#?j*ia9}sC8H7l#ah#s}|z#MUcmuAdY z`E{;E80oRv_UF0wOzY0r+U=0${KEwr5*=Ew#EHc15)6$<4gp8QEGpZe$p!+E$BfrVQ@wj)Z>CSC2zs;r1gT!GtPAupx#L6i#9MbyCF|8d20VkPfm%elZn#+oR~%9t&OWbooJ- z8*htjJ2c9_XY81@w=}`}EIYQ%N|zsBWr4<#GhV#y5@Sn`Ej_mM*wSN5k1aj6^w`o9 zOHV94vGl~!6H8AlJ+buWD(w{|`lG=CB7==9jt6P&#%p8M(b(F5H=4N}LE^IK1)Q}> zC*|8Q=}62@ZPL+$O*(^49h(lj(RVbP&g$K@BZ*o-hdbQdk+JQ%wyFOo!ww~EM9U5( zXAKIJyd6+TV>%2JKBB>>fDT3lD!QQXkuVEsM?(dxcpq`~H{kM7aQSHZJR&3(5t6e< z1S&@a1kS?6^T=6a4aRQ#EaGf3#WEcdenTVPgqhF7~>EY-i;?|suY0QXV@k+$Q?evG+ ztwl1JKqwA_=Q14}WqT^_`MsFuPfZyTi5nXAY$QQhxLtfS!j>@=gEaMr*GA?wReKGU z{`tm7vJKrQU4GRi_R;G` zR_ZBp3CPI!h{!0CU~UFWM{qL)IhjLbS z*~F=F(r_9F(q?|Q;p%V^8IlH*Jx>B=>xD})sSi# z9tGq}2-t-XunVEV=^`9UG-gH>I%_Z>{4J$fB7X9es^svLD%AI;j+*B{00ju3009&r zuop>_3rVQLW9~unaJzZuZFeB{o=`QO-H{%iP?elAp$dWBfdFw3APxe=LGnTps>U=t zxE$mU|K_(*f3e%Ehx)wjHa#Bx_cD|QgG!o&i=Bttv83d6Le+58{<};D+UcM?T)$Zz#H_f7|B`^kchc1(haFcrfg1oLoz`#o!8D;4iSo|6Q5 z1lh5+jvD1j!K6yTi4(AGCSco4;ERaz2s&o^!0S(AYFB24!|k-O!OPLwZ;IU=oIBSh zL5Oh27@%NQhoE7s4uZoqIh@5zSQu%Tzw8Ff@Dstr!BH^7!di~|Q0y7Re6-AV!Itk+ z)e~#u{`IzNg7gWyQ0&+5y{pmg>g-P-fJ{u-Hv`kk3mFzGSeYQft@)F8)CAf6P4oY6 z;E8O?N3-C%{_NN|yB1BOr6&zHZvlL=CyISAweK#spPTU=XyR}>Lh=MU??WK)n>qx7 zp4f_&2OF`3o^Wdd!}KRG{RvEe(jW@CjEEr_^Y90L-X1M_&-y$`)@RCh&iEro^=M)4 zr!e txXIYOZ4O3$tlLAfF`v_9yPp*zkgRzxRc6<<`{=8E@*mb0b5%oJ000l;@gD#H literal 0 HcmV?d00001 diff --git a/protocol/network/figs/overview.txt b/protocol/network/figs/overview.txt new file mode 100644 index 000000000..ecc37f9a6 --- /dev/null +++ b/protocol/network/figs/overview.txt @@ -0,0 +1,27 @@ +┌ ─ ─ ─ ─ ┌ ─ ─ ─ ─ ┌ ─ ─ ─ ─ ┌───────────┐ + mounted │ mounted │ mounted ││Identify │ +│protocol │protocol │protocol │(mounted │ + 1 │ 2 │ ... ││ protocol) │ +└ ─ ─ ─ ─ └ ─ ─ ─ ─ └ ─ ─ ─ ─ └───────────┘ +┌─────────────────────────────────────────┐ +│ swarm │ +└─────────────────────────────────────────┘ +┌─────────────────────────────────────────┐ +│ connection │ +└─────────────────────────────────────────┘ +┌───────────────┐┌───────────┐┌───────────┐ +│Transport ││multistream││ stream │ +│(TCP, UDP, etc)││ ││ muxer │ +└───────────────┘└───────────┘│┌ ─ ─ ─ ─ ┐│ + │ spdy │ + │└ ─ ─ ─ ─ ┘│ + │┌ ─ ─ ─ ─ ┐│ + │ multiplex │ + │└ ─ ─ ─ ─ ┘│ + │┌ ─ ─ ─ ─ ┐│ + │ QUIC │ + │└ ─ ─ ─ ─ ┘│ + │┌ ─ ─ ─ ─ ┐│ + │ others │ + │└ ─ ─ ─ ─ ┘│ + └───────────┘ \ No newline at end of file From 1c17e08282c32a67249f5c05f61dd04a2dcf21f4 Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 18 Jul 2015 11:13:01 -0700 Subject: [PATCH 14/18] remove layers.md --- protocol/layers.md | 57 ---------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 protocol/layers.md diff --git a/protocol/layers.md b/protocol/layers.md deleted file mode 100644 index c41e10ce8..000000000 --- a/protocol/layers.md +++ /dev/null @@ -1,57 +0,0 @@ -> this is a temporary doc, just so I can write down all the spec/notes that has been talked and iterate over it until we figure out how to organize it. - -# Layers - -``` - ┌──────────────────────────────────────────────┐ - │ MerkleDAG │ - └──────────────────────────────────────────────┘ - ▷ ┌──────────────────────────────────────────────┐ - │ │ bitswap │ -exchange│ └──────────────────────────────────────────────┘ - │ ┌──────────────────────────────────────────────┐ - │ │ host │ - ▷ └──────────────────────────────────────────────┘ - ▷ ┌──────────────────────────────────────────────┐ - │ │ routing │ - routing│ └──────────────────────────────────────────────┘ - │ ┌────────────────────┐ ▲ ┌ ─ ─ ─ ─ ─ ─ ─ ─ - │ │ swarm │ │ ┌───────────────┐ - │ │ │◀─┴─────┤│ discovery │ - │ │ │ └───────────────┘ - ▷ └────────────────────┘ └ ─ ─ ─ ─ ─ ─ ─ ─ - ▷ ┌──────────┐┌────────┐ - │ │connection││protocol│ - network│ │ ││muxing │ - ▷ └──────────┘└────────┘ -``` - -## MerkleDAG layer - -## exchange layer - -### bitswap - -### host - -- holds connections open -- announces block interest to connections open -- api - - .openStream() - -## routing layer - -### router - -![](https://cldup.com/gifxf20TnJ-3000x3000.png) - -- routing interface -- DHT (Kademlia) -- mDNS -- Delegated -- Tracker - -### discovery - -![](https://cldup.com/q3JsosI5zo-3000x3000.png) - From 5a108f6be63a780d4e56b1f821dd4b50fff580d2 Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 18 Jul 2015 11:14:06 -0700 Subject: [PATCH 15/18] remove outdated protocol overview --- protocol/figs/overview.monopic | Bin 2548 -> 0 bytes protocol/figs/overview.txt | 21 --------------------- 2 files changed, 21 deletions(-) delete mode 100644 protocol/figs/overview.monopic delete mode 100644 protocol/figs/overview.txt diff --git a/protocol/figs/overview.monopic b/protocol/figs/overview.monopic deleted file mode 100644 index 598bf1d8b8b7199d67d22744194a4235b649b74e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2548 zcmV`kcKmsdA^ zn9S+zo9?tKX8L(gq*jHPg6MtH@6u$m(tQGVIBt_2*0oDCdiwaOoDqj12&KU|4&iu^ z)_gXt5kbM0p&ViohDP)o_H~Pk4ArY+4p+!u#UdRUphud0K31=PJw_SrUnG$T;ms7JH9->3N|Rn1g~=d^w@ z%gbz&y06MzvMIjX8f|q+RVC|PqF!~+bXvWyTh%>G^6m3JIjrmh;EqP%;gCG0t0Z6V zibHEuT!5o`H0^ag`(pi7_wXUvmuVj{cG+f==KcXa2K(lHvi`a~6wkSrLTcdEPJOf8 z`NvxirMVtdLyTnGoiYqPIf{n|Got`T5V%2=+5c1{0ON>h4f}kr9#*fa-jX&^x zbr;-Z997z(#-XN0cY^CLbJe;k{o7J}pMIjgPwV24Ys#ah8OPWbn-TSBamcorq98z# zp{RZJz3$wXE!H|7Pd&^`H>Xzi4>Rv=No>%CpLJ7^bs>hXfLsAOL8KeUJc&VVRs9%W% z^uAaywL6qR4dUKsxf)WXNWV9)zYAI1!`bEq+H9YDs&<6-Pe#Fwa^V#C6DQ6-kh zxQ~0_hwGgZawE3{@nZDw5$;5oO_g?hsG%o3`ShGA4{u<-;S)s#3MgFG63aKsF0jfJlc7; zB?g*R;z~Yl0L5*{NG;ZubZ8CO*>*&~Ftd@NDf&y9*$53=*?7px=FZUN&a&o??Klf) zVYizbXxi4KZcGF!~X^P(M}j&j#^ z)Z?)yx?zJAHdZ0b=i7LPS1deS_=3Q2x!H(^O0b8)oT4~TpG}YZmdiU!^Nl!fuWH_l z?D}PJzg%yty6%JRHDBwAesFfA1uO-fY;*B@;8Olvz|5KXwL8iAj=X{7V>v#V3iupi zZw=H1Z)$l<%NtrgKg-pu*yc-1AJiDMtAUU8t!IQmSW)Yzza{y%q%_LuSRH(EqGiY* z6N}mY7>ol2e`%O{1zI5Pf{+LYIWe7|GA6<$5{RpdJHKNOv%#n{^wI*NkP+tNc1A^* zAvr^Y8R9WEFvSZ5vWN({A&5_2eo9~XY$Z59u~LLXUveJUe5wIvQE!^m_jP^Wo3t8x zJp#SlBk)phu*}u9?E$4W$;Rf`*c2O^VPg|)eg#>Ld4p&n7SdgHe?7 zU=kN$F>&V;4u-L1JUy!2WDe^(lKqpC5~Ki;PY!+pqrPHrBc=2MM} zzqVS?z83?7I+97DE;sM9zy#RT>|3_j{97x#>_-nvk73|ej#udJ^%Ht|vmnsTUH;T|$S_=X5gnTz?tI)Atm64aCF( zl^}LYAwo1{5;5lqVa^l6oF|0IfF@GYoE#k@L}v&Q!ZGHNyh7`Gh?D3LCrRgAla8en z+ziJ+?dC=@kd)yWNQyBGgeab9EQmp29nTMLg!A@uK5e}6qVY8rzazUJ5!ofA8`(WC zzQ#_WVi#H<&OJyR^d>iw3QLwug~j2{CW`|FGH{?nvq-pezVKCUSu?@Gaa-1WLI&~~ z8P+6nW>a%0LBP;L(>8^pLksjAp#?fBv>?LefyEQ;M5WuBs3Dn{>?R{0R}iyIb?>~) z>np7tnpN%Kw7)ItpZ9V_hJ%1ahTFYG!UcLE8bI8X&)v@^11TLkOX>KS(Q}LE24g}e z?zL7o+2%8b!X*~LK!+R1X#pO_LhXBH0n;0<&RK>dlY7($0mu*ph@HZr*H1 z-fq{?`sV1^ChT(?r@5J2_2o`;gK;n;mdT;bt+SIUIT$9$XK9&~Dr z{4|k(`7w0DXGBiet$*y+KXzaVy9^`DZUZ#ocu~xR(ENP|2$AX8)2(xgX8nT$u&don zrExQjaV>clNE|K-!UF|vaJaME5Mq-YRPjWQH$m;qHW-CFa8t~7$&+wrupt!B-$g*L zGU&!e$K1Sn(ElbWYW=Go_wRfHM%r2}j&{2te1;q&y~W@p$J?tVk_HGr!8gsSum1 Date: Sat, 18 Jul 2015 22:37:20 -0700 Subject: [PATCH 16/18] add myself as an author, normalize how authors are written --- protocol/README.md | 3 ++- protocol/network/README.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/protocol/README.md b/protocol/README.md index 75cdebc3b..ab31eac4e 100644 --- a/protocol/README.md +++ b/protocol/README.md @@ -5,7 +5,8 @@ IPFS Protocol Spec Authors: -- [@jbenet](http://github.com/jbenet) +- [Juan Benet](https://github.com/jbenet) +- [David Dias](https://github.com/diasdavid) Reviewers: diff --git a/protocol/network/README.md b/protocol/network/README.md index 72857ed15..9b0ad3172 100644 --- a/protocol/network/README.md +++ b/protocol/network/README.md @@ -4,7 +4,8 @@ IPFS Protocol Network Spec > This spec is a Work In Progress (WIP) Authors: -- [Juan Benet](http://github.com/jbenet) +- [Juan Benet](https://github.com/jbenet) +- [David Dias](https://github.com/diasdavid) Reviewers: From fea3fde95e4c68ff249ef95e4f9ae3854ec5a210 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 24 Jul 2015 13:50:59 -0700 Subject: [PATCH 17/18] merge wire in, first steps on the libp2p full spec --- protocol/network/README.md | 108 +++++++++++++++++++++++++++++++++++-- protocol/network/wire.md | 105 ------------------------------------ 2 files changed, 104 insertions(+), 109 deletions(-) delete mode 100644 protocol/network/wire.md diff --git a/protocol/network/README.md b/protocol/network/README.md index 9b0ad3172..3696e8d48 100644 --- a/protocol/network/README.md +++ b/protocol/network/README.md @@ -1,8 +1,6 @@ IPFS Protocol Network Spec ========================= -> This spec is a Work In Progress (WIP) - Authors: - [Juan Benet](https://github.com/jbenet) - [David Dias](https://github.com/diasdavid) @@ -11,9 +9,17 @@ Reviewers: * * * +# Abstract + This describes the IPFS network protocol. The network layer provides point-to-point transports (reliable and unreliable) between any two IPFS nodes in the network. -# Index +This document defines the spec implemented in libp2p. + +# Status of this spec + +> This spec is a Work In Progress (WIP) + +# Table of Contents - [1. Introduction and Goals]() - [2. Requirements]() @@ -322,7 +328,98 @@ is no assumptions made about the network stack in the protocol. Implementations will likley need to change, but changing implementations is vastly easier than changing protocols. -## 6 Overview of the Software Stack +### 5.5 On the wire + +We have the **hard constraint** of making IPFS work across _any_ duplex stream (an outgoing and an incoming stream pair, any arbitrary connection) and work on _any_ platform. + +To make this work, IPFS has to solve a few problems: + +- [Protocol Multiplexing](#protocol-multiplexing) - running multiple protocols over the same stream + - [multistream](#multistream) - self-describing protocol streams + - [multistream-select](#multistream-select) - a self-describing protocol selector + - [Stream Multiplexing](#stream-multiplexing) - running many independent streams over the same wire. +- [Portable Encodings](#portable-encodings) - using portable serialization formats +- [Secure Communications](#secure-communication) - using ciphersuites to establish security and privacy (like TLS). + +#### 5.5.1 Protocol-Multiplexing + +Protocol Multiplexing means running multiple different protocols over the same stream. This could happen sequentially (one after the other), or concurrently (at the same time, with their messages interleaved). We achieve protocol multiplexing using three pieces: + +- [multistream](#multistream) - self-describing protocol streams +- [multistream-select](#multistream-select) - a self-describing protocol selector +- [Stream Multiplexing](#stream-multiplexing) - running many independent streams over the same wire. + +#### 5.5.2 multistream - self-describing protocol stream + +[multistream](https://github.com/jbenet/multistream) is a self-describing protocol stream format. It is extremely simple. Its goal is to define a way to add headers to protocols that describe the protocol itself. It is sort of like adding versions to a protocol, but being extremely explicit. + +For example: + +``` +/ipfs/QmVXZiejj3sXEmxuQxF2RjmFbEiE9w7T82xDn3uYNuhbFb/ipfs-dht/0.2.3 + + +... +``` + +#### 5.5.3 multistream-selector - self-describing protocol stream selector + +[multistream-select](https://github.com/jbenet/multistream/tree/master/multistream-select) is a simple [multistream](https://github.com/jbenet/multistream) protocol that allows listing and selecting other protocols. This means that Protomux has a list of registered protocols, listens for one, and then _nests_ (or upgrades) the connection to speak the registered protocol. This takes direct advantage of multistream: it enables interleaving multiple protocols, as well as inspecting what protocols might be spoken by the remote endpoint. + +For example: + +``` +/ipfs/QmdRKVhvzyATs3L6dosSb6w8hKuqfZK2SyPVqcYJ5VLYa2/multistream-select/0.3.0 +/ipfs/QmVXZiejj3sXEmxuQxF2RjmFbEiE9w7T82xDn3uYNuhbFb/ipfs-dht/0.2.3 + + +... +``` + +#### 5.5.4 Stream Multiplexing + +Stream Multiplexing is the process of multiplexing (or combining) many different streams into a single one. This is a complicated subject because it enables protocols to run concurrently over the same wire. And all sorts of notions regarding fairness, flow control, head-of-line blocking, etc. start affecting the protocols. In practice, stream multiplexing is well understood and there are many stream multiplexing protocols. To name a few: + +- HTTP/2 +- SPDY +- QUIC +- SSH + +IPFS nodes are free to support whatever stream multiplexors they wish, on top of the default one. The default one is there to enable even the simplest of nodes to speak multiple protocols at once. The default multiplexor will be HTTP/2 (or maybe QUIC?), but implementations for it are sparse, so we are beginning with SPDY. We simply select which protocol to use with a multistream header. + +For example: + +``` +/ipfs/QmdRKVhvzyATs3L6dosSb6w8hKuqfZK2SyPVqcYJ5VLYa2/multistream-select/0.3.0 +/ipfs/Qmb4d8ZLuqnnVptqTxwqt3aFqgPYruAbfeksvRV1Ds8Gri/spdy/3 + +/ipfs/QmVXZiejj3sXEmxuQxF2RjmFbEiE9w7T82xDn3uYNuhbFb/ipfs-dht/0.2.3 + + + +/ipfs/QmVXZiejj3sXEmxuQxF2RjmFbEiE9w7T82xDn3uYNuhbFb/ipfs-bitswap/0.3.0 + + + + + + + + + + + + +... +``` + +#### 5.5.5 Portable Encodings + +In order to be ubiquitous, we _must_ use hyper-portable format encodings, those that are easy to use in various other platforms. Ideally these encodings are well-tested in the wild, and widely used. There may be cases where multiple encodings have to be supported (and hence we may need a [multicodec](https://github.com/jbenet/multicodec) self-describing encoding), but this has so far not been needed. + +For now, we use [protobuf](https://github.com/google/protobuf) for all protocol messages exclusively, but other good candidates are [capnp](https://capnproto.org), [bson](http://bsonspec.org/), [ubjson](http://ubjson.org/). + +## 6 Software Stack The network is abstracted through the swarm which presents a simplified interface for the remaining layers to have access to the network. This interface should look like: @@ -373,3 +470,6 @@ Every socket open (through the transport chosen), is "multistream'ed" into the s Identify stream requests should be issued by the listenner as soon as it receives a valid connection, otherwise the listenner won't be able to identify who is that stream comming, disabling its ability for connection reuse. Identify is responsible for 'tagging' the incomming connection on swarm with the right Id. A peer only updates its own multiaddrs list with observedAddrs if it receives the same observedAddr twice, avoiding addr explosion (a phenomenon that happens when both peers are behind symmetric NAT). + + +## References diff --git a/protocol/network/wire.md b/protocol/network/wire.md deleted file mode 100644 index 9f4ad61b2..000000000 --- a/protocol/network/wire.md +++ /dev/null @@ -1,105 +0,0 @@ - -# IPFS Protocol on the Wire - -Authors: [Juan Benet](http://github.com/jbenet) - -Reviewers: - - -* * * - -This [spec](../../) describes the IPFS protocol on the wire. - -As explained in the [network spec](./), IPFS is [transport agnostic](./#transport-agnostic). We have the **hard constraint** of making IPFS work across _any_ duplex stream (an outgoing and an incoming stream pair, any arbitrary connection) and work on _any_ platform. - -To make this work, IPFS has to solve a few problems: - -- [Protocol Multiplexing](#protocol-multiplexing) - running multiple protocols over the same stream - - [multistream](#multistream) - self-describing protocol streams - - [multistream-select](#multistream-select) - a self-describing protocol selector - - [Stream Multiplexing](#stream-multiplexing) - running many independent streams over the same wire. -- [Portable Encodings](#portable-encodings) - using portable serialization formats -- [Secure Communications](#secure-communication) - using ciphersuites to establish security and privacy (like TLS). - -## Protocol-Multiplexing - -Protocol Multiplexing means running multiple different protocols over the same stream. This could happen sequentially (one after the other), or concurrently (at the same time, with their messages interleaved). We achieve protocol multiplexing using three pieces: - -- [multistream](#multistream) - self-describing protocol streams -- [multistream-select](#multistream-select) - a self-describing protocol selector -- [Stream Multiplexing](#stream-multiplexing) - running many independent streams over the same wire. - -### multistream - self-describing protocol stream - -[multistream](https://github.com/jbenet/multistream) is a self-describing protocol stream format. It is extremely simple. Its goal is to define a way to add headers to protocols that describe the protocol itself. It is sort of like adding versions to a protocol, but being extremely explicit. - -For example: - -``` -/ipfs/QmVXZiejj3sXEmxuQxF2RjmFbEiE9w7T82xDn3uYNuhbFb/ipfs-dht/0.2.3 - - -... -``` - -### multistream-selector - self-describing protocol stream selector - -[multistream-select](https://github.com/jbenet/multistream/tree/master/multistream-select) is a simple [multistream](https://github.com/jbenet/multistream) protocol that allows listing and selecting other protocols. This means that Protomux has a list of registered protocols, listens for one, and then _nests_ (or upgrades) the connection to speak the registered protocol. This takes direct advantage of multistream: it enables interleaving multiple protocols, as well as inspecting what protocols might be spoken by the remote endpoint. - -For example: - -``` -/ipfs/QmdRKVhvzyATs3L6dosSb6w8hKuqfZK2SyPVqcYJ5VLYa2/multistream-select/0.3.0 -/ipfs/QmVXZiejj3sXEmxuQxF2RjmFbEiE9w7T82xDn3uYNuhbFb/ipfs-dht/0.2.3 - - -... -``` - -### Stream Multiplexing - -Stream Multiplexing is the process of multiplexing (or combining) many different streams into a single one. This is a complicated subject because it enables protocols to run concurrently over the same wire. And all sorts of notions regarding fairness, flow control, head-of-line blocking, etc. start affecting the protocols. In practice, stream multiplexing is well understood and there are many stream multiplexing protocols. To name a few: - -- HTTP/2 -- SPDY -- QUIC -- SSH - -IPFS nodes are free to support whatever stream multiplexors they wish, on top of the default one. The default one is there to enable even the simplest of nodes to speak multiple protocols at once. The default multiplexor will be HTTP/2 (or maybe QUIC?), but implementations for it are sparse, so we are beginning with SPDY. We simply select which protocol to use with a multistream header. - -For example: - -``` -/ipfs/QmdRKVhvzyATs3L6dosSb6w8hKuqfZK2SyPVqcYJ5VLYa2/multistream-select/0.3.0 -/ipfs/Qmb4d8ZLuqnnVptqTxwqt3aFqgPYruAbfeksvRV1Ds8Gri/spdy/3 - -/ipfs/QmVXZiejj3sXEmxuQxF2RjmFbEiE9w7T82xDn3uYNuhbFb/ipfs-dht/0.2.3 - - - -/ipfs/QmVXZiejj3sXEmxuQxF2RjmFbEiE9w7T82xDn3uYNuhbFb/ipfs-bitswap/0.3.0 - - - - - - - - - - - - -... -``` - -## Portable Encodings - -In order to be ubiquitous, we _must_ use hyper-portable format encodings, those that are easy to use in various other platforms. Ideally these encodings are well-tested in the wild, and widely used. There may be cases where multiple encodings have to be supported (and hence we may need a [multicodec](https://github.com/jbenet/multicodec) self-describing encoding), but this has so far not been needed. - -For now, we use [protobuf](https://github.com/google/protobuf) for all protocol messages exclusively, but other good candidates are [capnp](https://capnproto.org), [bson](http://bsonspec.org/), [ubjson](http://ubjson.org/). - - -## Secure Communications - -The wire protocol is -- of course -- wrapped with encryption. We use cyphersuites similar to TLS. This is explained further in the [network spec](./#encryption). From 7117a9b48dbbaffe273202d996e6a90dda074679 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 24 Jul 2015 14:48:55 -0700 Subject: [PATCH 18/18] moar stuff --- protocol/network/README.md | 54 ++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 5 deletions(-) diff --git a/protocol/network/README.md b/protocol/network/README.md index 3696e8d48..42bd2a6cd 100644 --- a/protocol/network/README.md +++ b/protocol/network/README.md @@ -21,11 +21,31 @@ This document defines the spec implemented in libp2p. # Table of Contents -- [1. Introduction and Goals]() -- [2. Requirements]() +- [1 Introduction and Goals]() +- [2 Requirements]() - [2.1 NAT traversal] () -- [3. Datastructures]() -- ... + - [2.2 Relay]() + - [2.3 Ecryption]() + - [2.4 Transport Agnostic]() + - [2.5 Multi-Multiplexing]() +- [3 Datastructures]() +- [4 Interface]() + - [4.1 Client Interface]() + - [4.2 Protocol Interface]() +- [5 Properties]() + - [5.1 Communication Model - Streams]() + - [5.2 Ports - Constrained Entrypoints]() + - [5.3 Transport Protocol]() + - [5.4 Non-IP Networks]() + - [5.5 On the wire]() + - [5.5.1 Protocol-Multiplexing]() + - [5.5.2 multistream - self-describing protocol stream]() + - [5.5.3 multistream-selector - self-describing protocol stream selector]() + - [5.5.4 Stream Multiplexing]() + - [5.5.5 Portable Encodings]() +- [6 Software Stack]() +- [7 Implementation Details]() +- [References]() ## 1. Introduction and Goals @@ -421,7 +441,21 @@ For now, we use [protobuf](https://github.com/google/protobuf) for all protocol ## 6 Software Stack -The network is abstracted through the swarm which presents a simplified interface for the remaining layers to have access to the network. This interface should look like: +### 6.1 Overview + +### 6.2 Discovery + +goal: find more peers, keep routing table fresh (if Kad-Router is not being used, discovery doens't necessary has a use) + +### 6.3 Peer Routing + +goal: get ref to other peers, that then can be used by swarm to open a stream. Also is free to open streams to other peers to traverse the DHT + +### 6.4 Swarm (aka Connectivity) + +goal: open stream, NAT traversal, Relay + +~~The network is abstracted through the swarm which presents a simplified interface for the remaining layers to have access to the network. This interface should look like:~~ - `.openStream(peer, protocol)` - peer should contain the ID of the peer and its respective multiaddrs known. - `.registerHandler(protocol, handlerFunc)` - enable a protocol to be registered, so that another peer can open a stream to talk with us to that specific protocol @@ -465,11 +499,21 @@ The stream muxer must implement the interface offered by [abstract-stream-muxer] Every socket open (through the transport chosen), is "multistream'ed" into the stream muxer used, once a stream muxer connection +### 6.5 libp2p + ## 7 Implementation Details +### 7.1 Discovery + +### 7.2 Peer Routing + +### 7.3 Swarm + Identify stream requests should be issued by the listenner as soon as it receives a valid connection, otherwise the listenner won't be able to identify who is that stream comming, disabling its ability for connection reuse. Identify is responsible for 'tagging' the incomming connection on swarm with the right Id. A peer only updates its own multiaddrs list with observedAddrs if it receives the same observedAddr twice, avoiding addr explosion (a phenomenon that happens when both peers are behind symmetric NAT). +### 7.4 libp2p + ## References