summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <schanzen@gnunet.org>2022-01-03 15:16:39 +0100
committerMartin Schanzenbach <schanzen@gnunet.org>2022-01-03 15:16:39 +0100
commita231f2087141c0729dc66d3eb3c1267e13c12eac (patch)
treefb51f58b134fe55148d08b19a5b7041de1a26355
parent7167e8e4066a761c7cbb86cda4dac558502ae8b3 (diff)
downloadlsd0004-a231f2087141c0729dc66d3eb3c1267e13c12eac.tar.gz
lsd0004-a231f2087141c0729dc66d3eb3c1267e13c12eac.zip
various
-rw-r--r--draft-schanzen-r5n.xml163
1 files changed, 65 insertions, 98 deletions
diff --git a/draft-schanzen-r5n.xml b/draft-schanzen-r5n.xml
index 41428d0..b6ca63c 100644
--- a/draft-schanzen-r5n.xml
+++ b/draft-schanzen-r5n.xml
@@ -479,18 +479,12 @@ see how we can offer even the most minimal protections against node
479 <section anchor="routing_table"> 479 <section anchor="routing_table">
480 <name>Routing Table</name> 480 <name>Routing Table</name>
481 <t> 481 <t>
482 R5N stores the information of all connected nodes in a a set of lists 482 A R5N implementation must store the information on connected nodes.
483 similar to the k-buckets data structure of <xref target="Kademlia"/>. 483 The data structure for managing connected nodes and their
484 The size of this set is determined by the number of connected nodes. 484 metadata may be implemented using the k-buckets concept of
485 A k-bucket contains a list of connected node IDs which share the same 485 <xref target="Kademlia"/>.
486 bit prefix length with the local <tt>nodeID</tt>. 486 In order to select nodes which are suitable destinations for
487 This number is called the <tt>index</tt> of the k-bucket. 487 routing messages, R5N uses a hybrid approach:
488 The index which determines in which of the k-buckets to add a given
489 node is calculated using the <tt>FindBucket</tt> procedure.
490 </t>
491 <t>
492 In order to select nodes from the routing table which are suitable
493 destinations for sending messages, R5N uses a hybrid approach:
494 Given an estimated network size N, the node selection for the 488 Given an estimated network size N, the node selection for the
495 first N hops is random. After the initial N hops, node selection 489 first N hops is random. After the initial N hops, node selection
496 follows an XOR-based node distance calculation. 490 follows an XOR-based node distance calculation.
@@ -505,78 +499,44 @@ see how we can offer even the most minimal protections against node
505 case, any node which is in the bloomfilter for the respective message 499 case, any node which is in the bloomfilter for the respective message
506 is not included in the node selection process. 500 is not included in the node selection process.
507 </t> 501 </t>
508 <!-- Fixme: We may want to propose our modified, optimized XOR metric here or reference Kademlia -->
509 <t> 502 <t>
510 The buckets serve implicitly as a routing table for messages by 503 The R5N routing component MUST implement the following functions:
511 calculating the shortest distance from a message key to node ID.
512 In order to select a node for a given message key and bloomfilter,
513 the <tt>node-select</tt> is used (see <xref target="node-select"/>.
514 </t>
515 <figure anchor="node-select">
516 <artwork name="" type="" align="left" alt=""><![CDATA[
517node-SELECT(key, bloomfilter)
518 nodes := <Select all known peers NOT in message bloomfilter>
519 IF hops >= N
520 dist := MAX_VALUE
521 FOR EACH p IN nodes
522 IF XOR(p, key) < dist
523 dist := XOR(p, key)
524 target := p
525 END
526 END
527 ELSE
528 r := rand()
529 target := nodes[r]
530 END
531END
532 ]]></artwork>
533 </figure>
534 <t>
535 Apart from the k-bucket datastructure,
536 the R5N routing component MUST implement the following functions:
537 </t> 504 </t>
538 <dl> 505 <dl>
539 <dt><tt>FindBucket(NodeID, Key) -> k-bucket as List</tt></dt> 506 <dt><tt>GetDistance(A, B) -> Distance as Integer</tt></dt>
540 <dd>
541 The <tt>FindBucket</tt> function determines how many low
542 order bits succesively match between a <tt>nodeID</tt> and a
543 <tt>Key</tt> starting from the first bit. The procedure returns
544 the k-bucket for this index.
545 </dd>
546 <dt><tt>GetDistance(NodeID_A, NodeID_B) -> Distance as Integer</tt></dt>
547 <dd> 507 <dd>
548 FIXME: We do NOT do XOR here. We do some kind of 508 this function calculates the binary XOR between A and B.
549 fancy calculation. See get_distance() 509 The resulting distance is interpreted as an integer where
510 the leftmost bit is the most significant bit.
550 </dd> 511 </dd>
551 <dt><tt>SelectClosestNode(Key) -> NodeID</tt></dt> 512 <dt><tt>SelectClosestNode(K, B) -> N</tt></dt>
552 <dd> 513 <dd>
553 This function determines the closest node ID to <tt>Key</tt> 514 This function selects the connected node <tt>N</tt> from our
554 of all connected nodes using <tt>GetDistance</tt>. 515 routing table with the shortest XOR-distance to the key <tt>K</tt>.
555 FIXME: Also has a bloomfilter. Isn't AmClosestNode simply 516 This means that for all other nodes <tt>N'</tt> in the routing table
556 !SelectClosestnode == myID ? 517 <tt>GetDistance(N, K) &lt; GetDistance(N',K)</tt>.
518 Nodes in the bloomfilter <tt>B</tt> are not considered.
557 </dd> 519 </dd>
558 <dt><tt>SelectRandomnode() -> NodeID</tt></dt> 520 <dt><tt>SelectRandomNode(B) -> N</tt></dt>
559 <dd> 521 <dd>
560 This function selects a random node ID from all connected 522 This function selects a random node <tt>N</tt> from all connected
561 nodes. FIXME find elegant way to handle bloomfilter 523 nodes.
524 Nodes in the bloomfilter <tt>B</tt> are not considered.
562 </dd> 525 </dd>
563 <dt><tt>Selectnode(Key, NumberOfHops)</tt></dt> 526 <dt><tt>SelectNode(K, H, B) -> N</tt></dt>
564 <dd> 527 <dd>
565 This function selects a node depending on the <tt>NumberOfHops</tt> 528 This function selects a node <tt>N</tt> depending on the
566 Parameter. If <tt>NumberOfHops &lt; NETWORK_SIZE_ESTIMATE</tt> 529 number of hops <tt>H</tt> parameter.
567 this function returns <tt>SelectRandomnode()</tt> and 530 If <tt>H &lt; NETWORK_SIZE_ESTIMATE</tt>
568 <tt>SelectClosestnode(Key)</tt> otherwise. 531 this function MUST return <tt>SelectRandomNode()</tt> and
532 <tt>SelectClosestnode(K)</tt> otherwise.
533 Nodes in the bloomfilter <tt>B</tt> are not considered.
569 </dd> 534 </dd>
570 <dt><tt>AmClosestNode(NodeID, Key, Bloom) -> true | false</tt></dt> 535 <dt><tt>IsClosestNode(N, K, B) -> true | false</tt></dt>
571 <dd> 536 <dd>
572 This function first determines which k-bucket contains the 537 checks if <tt>N</tt> is the closest node for <tt>K</tt>
573 closest node IDs to <tt>Key</tt>. 538 (cf. <tt>SelectClosestNode(K)</tt>).
574 Any node IDs which match the bloom filter are not considered. 539 Nodes in the bloomfilter <tt>B</tt> are not considered.
575 If there is a node ID <tt>NodeID'</tt> in the k-bucket where
576 <tt>GetDistance(NodeID, Key) > GetDistance(NodeID', Key)</tt>,
577 then <tt>false</tt> is returned, otherwise <tt>true</tt>.
578 FIXME: Currently, GDS_am_closest_node checks for longer matching
579 bits. Not GetDistance. Why?
580 </dd> 540 </dd>
581 </dl> 541 </dl>
582 </section> 542 </section>
@@ -591,8 +551,8 @@ END
591 node IDs along the route. 551 node IDs along the route.
592 A Bloom filter "bf" is initially empty, consisting only of zeroes. 552 A Bloom filter "bf" is initially empty, consisting only of zeroes.
593 There are two functions which can be invoked on the Bloom filter: 553 There are two functions which can be invoked on the Bloom filter:
594 BF-SET(bf, e) and BF-TEST(bf, e) where "e" is an element which is to added 554 BF-SET(bf, e) and BF-TEST(bf, e) where "e" is an element which is to
595 to the Bloom filter or queried against the set. 555 be added to the Bloom filter or queried against the set.
596 Any bloom filter uses k=16 different hash functions each of which is 556 Any bloom filter uses k=16 different hash functions each of which is
597 defined as follows: 557 defined as follows:
598 </t> 558 </t>
@@ -685,7 +645,8 @@ END
685 <dt>PATH_LEN</dt> 645 <dt>PATH_LEN</dt>
686 <dd> 646 <dd>
687 is a 16-bit number indicating the length of the PUT path recorded 647 is a 16-bit number indicating the length of the PUT path recorded
688 in PUTPATH. As PUTPATH is optiona, this value may be zero. 648 in PUTPATH.
649 As PUTPATH is optional, this value may be zero.
689 In network byte order. 650 In network byte order.
690 </dd> 651 </dd>
691 <dt>EXPIRATION</dt> 652 <dt>EXPIRATION</dt>
@@ -696,7 +657,7 @@ END
696 </dd> 657 </dd>
697 <dt>BLOOMFILTER</dt> 658 <dt>BLOOMFILTER</dt>
698 <dd> 659 <dd>
699 A bloomfilter (for node identities) to stop circular routes. 660 A bloomfilter (for node IDs) to stop circular routes.
700 </dd> 661 </dd>
701 <dt>KEY</dt> 662 <dt>KEY</dt>
702 <dd> 663 <dd>
@@ -723,42 +684,46 @@ END
723 </t> 684 </t>
724 <ol> 685 <ol>
725 <li> 686 <li>
726 The EXPIRATION field is evaluated. If the message is expired, 687 The <tt>EXPIRATION</tt> field is evaluated.
727 it MUST be discarded. 688 If the message is expired, it MUST be discarded.
728 </li> 689 </li>
729 <li> 690 <li>
730 If the BTYPE is not supported by the implementation, no validation 691 If the <tt>BTYPE</tt> is not supported by the implementation,
731 of the block payload is performed and processing continues at (4). 692 no validation of the block payload is performed and processing
693 continues at (4).
732 Else, the block MUST be validated as defined in (3). 694 Else, the block MUST be validated as defined in (3).
733 </li> 695 </li>
734 <li> 696 <li>
735 The block payload of the message is evaluated using according 697 The block payload of the message is evaluated using according
736 to the BTYPE using the respective <tt>ValidateBlockStoreRequest</tt> 698 to the <tt>BTYPE</tt> using the respective
737 procedure. 699 <tt>ValidateBlockStoreRequest</tt> procedure.
738 If the block payload is invalid or does not match the key, 700 If the block payload is invalid or does not match the key,
739 it MUST be discarded. 701 it MUST be discarded.
740 </li> 702 </li>
741 <li> 703 <li>
742 The sender node ID SHOULD be in the BLOOMFILTER. If not, the 704 The sender node ID SHOULD be in <tt>BLOOMFILTER</tt>.
743 implementation MAY log an error, but MUST continue. 705 If not, the implementation MAY log an error, but MUST continue.
744 </li> 706 </li>
745 <li> 707 <li>
746 If the <tt>RecordRoute</tt> flag is set in OPTIONS, the local node ID 708 If the <tt>RecordRoute</tt> flag is set in OPTIONS,
747 MUST be appended to the <tt>PUTPATH</tt> of the message. 709 the local node ID MUST be appended to the <tt>PUTPATH</tt>
710 of the message.
748 </li> 711 </li>
749 <li> 712 <li>
750 If the local node is the closest node (<tt>AM-CLOSEST-NODE</tt> is true) or the 713 If the local node is the closest node
751 <tt>DemultiplexEverywhere</tt> options flag ist set, the message MUST 714 (cf. <tt>IsClosestNode</tt>) or the <tt>DemultiplexEverywhere</tt>
715 options flag ist set, the message MUST
752 be stored locally in the block storage. 716 be stored locally in the block storage.
753 </li> 717 </li>
754 <li> 718 <li>
755 Given the value in REPL_LVL, the number of nodes to forward to 719 Given the value in <tt>REPL_LVL</tt>, the number of nodes to
756 MUST be calculated (NUM-FORWARD-nodeS). If there is at least one 720 forward to MUST be calculated. If there is at least one
757 node to forward to, the implementation SHOULD select up to this 721 node to forward to, the implementation SHOULD select up to this
758 number of nodes to forward the message to. The implementation MAY 722 number of nodes to forward the message to. The implementation MAY
759 forward to fewer or no nodes in order to handle resource constraints 723 forward to fewer or no nodes in order to handle resource constraints
760 such as bandwidth. 724 such as bandwidth.
761 The message BLOOMFILTER MUST be updated with the local node ID. 725 Finally, the local node ID MUST be added to the
726 <tt>BLOOMFILTER</tt> of the forwarded message.
762 </li> 727 </li>
763 </ol> 728 </ol>
764 </section> 729 </section>
@@ -797,8 +762,7 @@ END
797 </dd> 762 </dd>
798 <dt>MTYPE</dt> 763 <dt>MTYPE</dt>
799 <dd> 764 <dd>
800 is the 16-bit message type. This type can be one of the DHT message 765 is the 16-bit message type. It must be set to
801 types but for put messages it must be set to
802 the value 147 in network byte order. 766 the value 147 in network byte order.
803 </dd> 767 </dd>
804 <dt>BTYPE</dt> 768 <dt>BTYPE</dt>
@@ -851,7 +815,7 @@ END
851 <section anchor="p2p_get_processing"> 815 <section anchor="p2p_get_processing">
852 <name>Processing</name> 816 <name>Processing</name>
853 <t> 817 <t>
854 Upon receiving a <tt>GetMmessage</tt> from a connected node an 818 Upon receiving a <tt>GetMmessage</tt> from a peer an
855 implementation MUST process it step by step as follows: 819 implementation MUST process it step by step as follows:
856 </t> 820 </t>
857 <ol> 821 <ol>
@@ -869,19 +833,22 @@ END
869 </li> 833 </li>
870 <li> 834 <li>
871 <t> 835 <t>
872 If the local node is the closest node (AM-CLOSEST-NODE) or the 836 If the local node is the closest node
837 (cf. <tt>IsClosestNode</tt>) or the
873 <tt>DemultiplexEverywhere</tt> options flag is set, a reply 838 <tt>DemultiplexEverywhere</tt> options flag is set, a reply
874 MUST be produced: 839 MUST be produced:
875 </t> 840 </t>
876 <ol> 841 <ol>
877 <li> 842 <li>
878 If OPTIONS indicate a <tt>Findnode</tt> request, FIXME the node selection 843 If <tt>OPTIONS</tt> indicate a <tt>FindNode</tt> request,
844 FIXME the node selection
879 foo from buckets that probably needs fixing. Take into account 845 foo from buckets that probably needs fixing. Take into account
880 <tt>REPLY_BF</tt> 846 <tt>REPLY_BF</tt>
881 </li> 847 </li>
882 <li> 848 <li>
883 Else, if there is a BLOCK in the local Block Storage which is 849 Else, if there is a block in the local Block Storage which is
884 not already in the RESULT_BF, a RESULT message MUST be sent. 850 not already in the <tt>RESULT_BF</tt>,
851 a ResultMessage MUST be sent.
885 FIXME link to how the result is sent? 852 FIXME link to how the result is sent?
886 </li> 853 </li>
887 </ol> 854 </ol>