diff options
Diffstat (limited to 'draft-schanzen-r5n.xml')
-rw-r--r-- | draft-schanzen-r5n.xml | 102 |
1 files changed, 82 insertions, 20 deletions
diff --git a/draft-schanzen-r5n.xml b/draft-schanzen-r5n.xml index 1ae0da0..7b60cb6 100644 --- a/draft-schanzen-r5n.xml +++ b/draft-schanzen-r5n.xml | |||
@@ -361,7 +361,45 @@ peer-public-key := [A-HJ-NP-Z1-9]+ | |||
361 | The following is a non-normative example of a HELLO containing three | 361 | The following is a non-normative example of a HELLO containing three |
362 | HELLO URIs: | 362 | HELLO URIs: |
363 | </t> | 363 | </t> |
364 | <!-- FIXME peer id type | length | id payload | 0-terminated strings for addresses --> | 364 | <figure anchor="figure_hello"> |
365 | <artwork name="" type="" align="left" alt=""><![CDATA[ | ||
366 | 0 8 16 24 32 40 48 56 | ||
367 | +-----+-----+-----+-----+-----+-----+-----+-----+ | ||
368 | | TYPE | SIZE | NODEID / | ||
369 | +-----+-----+-----+-----+ (variable length) / | ||
370 | / / | ||
371 | +-----+-----+-----+-----+-----+-----+-----+-----+ | ||
372 | | ADDRESSES / | ||
373 | / (variable length) | | ||
374 | +-----+-----+-----+-----+-----+-----+-----+-----+ | ||
375 | ]]></artwork> | ||
376 | </figure> | ||
377 | <dl> | ||
378 | <dt>TYPE</dt> | ||
379 | <dd> | ||
380 | is the type of HELLO. A 16-bit number in network byte order. | ||
381 | This value determines the type of the NODEID field. | ||
382 | </dd> | ||
383 | <dt>SIZE</dt> | ||
384 | <dd> | ||
385 | is the SIZE of the following fields NODEID and ADDRESSES in bytes. | ||
386 | In network byte order. | ||
387 | </dd> | ||
388 | <dt>NODEID</dt> | ||
389 | <dd> | ||
390 | is the Node ID of the peer which has generated this HELLO. | ||
391 | The length content of the NODEID is determined by the TYPE field. | ||
392 | Usually, this is a cryptographic public key which allows the | ||
393 | Underlay to uniquely identify and authenticate the node. | ||
394 | </dd> | ||
395 | <dt>ADDRESSES</dt> | ||
396 | <dd> | ||
397 | is a list of strings which can be used as addresses to contact the | ||
398 | node. The strings MUST be 0-terminated. | ||
399 | FIXME: Examples? Format determined? | ||
400 | </dd> | ||
401 | </dl> | ||
402 | <!-- FIXME peer id type | length | id payload | 0-terminated strings for addresses | ||
365 | <figure> | 403 | <figure> |
366 | <artwork name="" type="" align="left" alt=""><![CDATA[ | 404 | <artwork name="" type="" align="left" alt=""><![CDATA[ |
367 | Y924NSHMMZ1N1SQCE5TXF93ED6S6JY311K0QT86G9WJC68F6XVZ0 \ | 405 | Y924NSHMMZ1N1SQCE5TXF93ED6S6JY311K0QT86G9WJC68F6XVZ0 \ |
@@ -371,7 +409,7 @@ Y924NSHMMZ1N1SQCE5TXF93ED6S6JY311K0QT86G9WJC68F6XVZ0 \ | |||
371 | tor+onionv3://rasdflkjasdfliasduf.onion/ | 409 | tor+onionv3://rasdflkjasdfliasduf.onion/ |
372 | ]]></artwork> | 410 | ]]></artwork> |
373 | </figure> | 411 | </figure> |
374 | 412 | --> | |
375 | 413 | ||
376 | <!-- | 414 | <!-- |
377 | 1) The current API is always fire+forget, it doesn't allow for flow | 415 | 1) The current API is always fire+forget, it doesn't allow for flow |
@@ -465,8 +503,37 @@ see how we can offer even the most minimal protections against peer | |||
465 | 503 | ||
466 | <section anchor="routing" numbered="true" toc="default"> | 504 | <section anchor="routing" numbered="true" toc="default"> |
467 | <name>Routing</name> | 505 | <name>Routing</name> |
468 | <section anchor="peer_selection" numbered="true" toc="default"> | 506 | <section> |
469 | <name>Peer selection</name> | 507 | <name>Distance Metric</name> |
508 | <t> | ||
509 | The distance between two keys <tt>KeyA</tt> and <tt>KeyB</tt> is | ||
510 | calculated relative to their shared prefix. | ||
511 | The prefix length is determined by the number of low order bits | ||
512 | that succesively match between <tt>KeyA</tt> and <tt>KeyB</tt> | ||
513 | starting from the first bit. | ||
514 | </t> | ||
515 | <t> | ||
516 | Relative to the (identical) bits in the shared prefix, differences | ||
517 | in the lower bits must count stronger than higher bits. | ||
518 | The resulting distance value is a FIXME: I think we wanted to | ||
519 | move to a 512-bit distance value. And I think we may have decided | ||
520 | to use a "regular" xor. | ||
521 | </t> | ||
522 | </section> | ||
523 | |||
524 | |||
525 | <section anchor="routing_table"> | ||
526 | <name>Routing Table</name> | ||
527 | <t> | ||
528 | R5N stores the information of all connected peers in a a set of lists | ||
529 | similar to the k-buckets data structure of <xref target="Kademlia"/>. | ||
530 | The size of this set is determined by the number of connected peers. | ||
531 | A k-bucket contains a list of connected node IDs which share the same | ||
532 | bit prefix length with the local <tt>PeerID</tt>. | ||
533 | This number is called the <tt>index</tt> of the k-bucket. | ||
534 | The index which determines in which of the k-buckets to add a given | ||
535 | peer is calculated using the <tt>FindBucket</tt> procedure. | ||
536 | </t> | ||
470 | <t> | 537 | <t> |
471 | In order to select peers from the routing table which are suitable | 538 | In order to select peers from the routing table which are suitable |
472 | destinations for sending messages, R5N uses a hybrid approach: | 539 | destinations for sending messages, R5N uses a hybrid approach: |
@@ -486,13 +553,8 @@ see how we can offer even the most minimal protections against peer | |||
486 | </t> | 553 | </t> |
487 | <!-- Fixme: We may want to propose our modified, optimized XOR metric here or reference Kademlia --> | 554 | <!-- Fixme: We may want to propose our modified, optimized XOR metric here or reference Kademlia --> |
488 | <t> | 555 | <t> |
489 | R5N stores the information of all connected peers in a a set of lists | 556 | The buckets serve implicitly as a routing table for messages by |
490 | similar to the k-buckets data structure of <xref target="Kademlia"/>. | 557 | calculating the shortest distance from a message key to node ID. |
491 | The index which determines in which of the k lists to add a given peer | ||
492 | is calculated using the <tt>FindBucket</tt> procedure. | ||
493 | </t> | ||
494 | <t> | ||
495 | The buckets serve implicitly as a routing table for messages: | ||
496 | In order to select a peer for a given message key and bloomfilter, | 558 | In order to select a peer for a given message key and bloomfilter, |
497 | the <tt>PEER-SELECT</tt> is used (see <xref target="peer-select"/>. | 559 | the <tt>PEER-SELECT</tt> is used (see <xref target="peer-select"/>. |
498 | </t> | 560 | </t> |
@@ -516,16 +578,16 @@ END | |||
516 | ]]></artwork> | 578 | ]]></artwork> |
517 | </figure> | 579 | </figure> |
518 | <t> | 580 | <t> |
519 | R5N requires the following procedures for its routing table: | 581 | Apart from the k-bucket datastructure, |
582 | the R5N routing component MUST implement the following functions: | ||
520 | </t> | 583 | </t> |
521 | <dl> | 584 | <dl> |
522 | <dt><tt>FindBucket(PeerID, Key) -> k-bucket as List</tt></dt> | 585 | <dt><tt>FindBucket(PeerID, Key) -> k-bucket as List</tt></dt> |
523 | <dd> | 586 | <dd> |
524 | The <tt>FindBucket</tt> procedure determines how many low | 587 | The <tt>FindBucket</tt> function determines how many low |
525 | order bits succesively match between a <tt>PeerID</tt> and a | 588 | order bits succesively match between a <tt>PeerID</tt> and a |
526 | <tt>Key</tt> starting from the first bit. The procedure returns | 589 | <tt>Key</tt> starting from the first bit. The procedure returns |
527 | the k-bucket for this index. It contains all connected nodes which | 590 | the k-bucket for this index. |
528 | share the same prefix length with <tt>PeerID</tt>. | ||
529 | </dd> | 591 | </dd> |
530 | <dt><tt>GetDistance(NodeKey_A, NodeKey_B) -> Distance as Integer</tt></dt> | 592 | <dt><tt>GetDistance(NodeKey_A, NodeKey_B) -> Distance as Integer</tt></dt> |
531 | <dd> | 593 | <dd> |
@@ -534,26 +596,26 @@ END | |||
534 | </dd> | 596 | </dd> |
535 | <dt><tt>SelectClosestPeer(Key) -> NodeID</tt></dt> | 597 | <dt><tt>SelectClosestPeer(Key) -> NodeID</tt></dt> |
536 | <dd> | 598 | <dd> |
537 | This procedure determines the closest node ID to <tt>Key</tt> | 599 | This function determines the closest node ID to <tt>Key</tt> |
538 | of all connected nodes using <tt>GetDistance</tt>. | 600 | of all connected nodes using <tt>GetDistance</tt>. |
539 | FIXME: Also has a bloomfilter. Isn't AmClosestNode simply | 601 | FIXME: Also has a bloomfilter. Isn't AmClosestNode simply |
540 | !SelectClosestPeer == myID ? | 602 | !SelectClosestPeer == myID ? |
541 | </dd> | 603 | </dd> |
542 | <dt><tt>SelectRandomPeer() -> NodeID</tt></dt> | 604 | <dt><tt>SelectRandomPeer() -> NodeID</tt></dt> |
543 | <dd> | 605 | <dd> |
544 | This procedure selects a random node ID from all connected | 606 | This function selects a random node ID from all connected |
545 | nodes. FIXME find elegant way to handle bloomfilter | 607 | nodes. FIXME find elegant way to handle bloomfilter |
546 | </dd> | 608 | </dd> |
547 | <dt><tt>SelectPeer(Key, NumberOfHops)</tt></dt> | 609 | <dt><tt>SelectPeer(Key, NumberOfHops)</tt></dt> |
548 | <dd> | 610 | <dd> |
549 | This procedure selects a peer depending on the <tt>NumberOfHops</tt> | 611 | This function selects a peer depending on the <tt>NumberOfHops</tt> |
550 | Parameter. If <tt>NumberOfHops < NETWORK_SIZE_ESTIMATE</tt> | 612 | Parameter. If <tt>NumberOfHops < NETWORK_SIZE_ESTIMATE</tt> |
551 | this procedure returns <tt>SelectRandomPeer()</tt> and | 613 | this function returns <tt>SelectRandomPeer()</tt> and |
552 | <tt>SelectClosestPeer(Key)</tt> otherwise. | 614 | <tt>SelectClosestPeer(Key)</tt> otherwise. |
553 | </dd> | 615 | </dd> |
554 | <dt><tt>AmClosestNode(NodeID, Key, Bloom) -> true | false</tt></dt> | 616 | <dt><tt>AmClosestNode(NodeID, Key, Bloom) -> true | false</tt></dt> |
555 | <dd> | 617 | <dd> |
556 | This procedure first determines which k-bucket contains the | 618 | This function first determines which k-bucket contains the |
557 | closest node IDs to <tt>Key</tt>. | 619 | closest node IDs to <tt>Key</tt>. |
558 | Any node IDs which match the bloom filter are not considered. | 620 | Any node IDs which match the bloom filter are not considered. |
559 | If there is a node ID <tt>NodeID'</tt> in the k-bucket where | 621 | If there is a node ID <tt>NodeID'</tt> in the k-bucket where |