RFC 6940
REsource LOcation And Discovery (RELOAD) Base Protocol
REsource LOcation And Discovery (RELOAD) Base Protocol ๐
Okay bestie, this is RFC 6940 ๐, and it's giving Standards Track โจ. It was published in January 2014 and carries the ISSN 2070-1721. The authors are C. Jennings (Cisco), B. Lowekamp, Ed. (Skype), E. Rescorla (RTFM, Inc.), S. Baset, and H. Schulzrinne (Columbia University). The "Ed." just means B. Lowekamp was the editor ๐ซถ
Abstract ๐ธ
So this spec defines REsource LOcation And Discovery (RELOAD) ๐ฆ, a peer-to-peer (P2P) signaling protocol for the Internet. The main idea is that a P2P signaling protocol gives its clients an abstract storage and messaging service, shared across a group of cooperating peers that together make up the overlay network. It's the girl who runs the whole group chat without anyone noticing ๐
RELOAD is built to support a P2P Session Initiation Protocol (P2PSIP) network ๐. But other apps with similar needs can use it too, by defining new usages that spell out which Kinds of data need to be stored for that particular app ๐ง
It also comes with a security model based on a certificate enrollment service, which gives every user a unique identity ๐. NAT traversal is a core, fundamental service of the protocol ๐. And RELOAD lets "client" nodes join without having to route traffic or store data for anyone else. Basically they get the perks without doing the chores ๐๐
Status of This Memo ๐
This is an Internet Standards Track document โจ.
It's a product of the Internet Engineering Task Force (IETF) and represents the consensus of the IETF community. It went through public review and was approved for publication by the Internet Engineering Steering Group (IESG) ๐. If you want more on Internet Standards, check out Section 2 of RFC 5741 ๐.
For the current status, any errata, and how to send feedback, go to http://www.rfc-editor.org/info/rfc6940 ๐
Copyright Notice ๐
Copyright (c) 2014 IETF Trust and the persons identified as the document authors. All rights reserved ๐
This document falls under BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents, which you can find at http://trustee.ietf.org/license-info as they stood on the publication date. Please read these carefully, because they spell out your rights and restrictions for this document ๐ซถ Any Code Components pulled out of this document must include the Simplified BSD License text, as described in Section 4.e of the Trust Legal Provisions. They come with no warranty, as the Simplified BSD License describes โจ
This document may include material from IETF Documents or IETF Contributions published or made publicly available before November 10, 2008 ๐ธ The people who hold the copyright on some of that older material may never have given the IETF Trust permission to allow modifications outside the IETF Standards Process ๐ญ So unless you get a proper license from those copyright holders, this document can't be modified outside the IETF Standards Process, and derivative works can't be made outside it either. The one exceptions are formatting it for publication as an RFC or translating it into languages other than English ๐
Table of Contents ๐ฆ
Hey bestie ๐ I can't do part 2 yet because the text you sent is only the table of contents, and that was already covered in part 1. โจ
Could you paste the body of RFC 6940 that comes after the TOC? Part 2 should pick up wherever part 1 stopped, so the next chunk would start in Section 1 (Introduction) or wherever the text breaks off. Once I have it, I'll keep every section number, BCP 14 keyword, ABNF block, and citation exactly as written ๐
1. Introduction โจ
okay bestie, let's get into it ๐ This document defines REsource LOcation And Discovery (RELOAD), which is a peer-to-peer (P2P) signaling protocol for the Internet ๐ฆ RELOAD gives you a generic, self-organizing overlay network service, so nodes can route messages to each other and store and retrieve data in the overlay. It has a bunch of features that are basically critical for a P2P protocol that actually works on the real Internet ๐
- Security Framework: A P2P network is often set up among peers that don't trust each other ๐ So RELOAD uses a central enrollment server to hand out credentials for each peer, and those credentials can then be used to authenticate every operation. This greatly reduces the possible attack surface ๐ฅ
- Usage Model: RELOAD is built to support lots of applications, including P2P multimedia communications with the Session Initiation Protocol (SIP) [SIP-RELOAD] ๐ It lets you define new application usages, and each one can define its own data types and the rules for using them. So new applications can plug in through a simple documentation process that supplies the details for each application โจ
- NAT Traversal: RELOAD is designed to work even when many, if not most, of the nodes are behind NATs or firewalls ๐งฑ NAT traversal operations are part of the base design, including using Interactive Connectivity Establishment (ICE) [RFC5245] to set up new RELOAD or application protocol connections ๐
- Optimized Routing: Overlay algorithms mean that peers have to route requests on behalf of other peers in the network, and that puts load on them in the form of bandwidth and processing power ๐ญ So RELOAD has a simple, lightweight forwarding header, which keeps the effort for intermediate peers as small as possible ๐
- Pluggable Overlay Algorithms: RELOAD has an abstract interface to the overlay layer, which makes it easier to implement a variety of structured (e.g., distributed hash tables (DHTs)) and unstructured overlay algorithms ๐ง The idea is that RELOAD gives you a generic structure that can fit most types of overlay topologies (ring, hyperspace, etc.) ๐ To make an actual network, you combine RELOAD with a specific overlay algorithm, which defines how to build the overlay topology and route messages efficiently inside it. This spec also defines how RELOAD is used with the Chord-based [Chord] DHT algorithm, which is mandatory to implement. A default "mandatory-to-implement" overlay algorithm promotes interoperability, and extensibility lets you pick overlay algorithms that are optimized for a particular application ๐
- Support for Clients: RELOAD clients differ from RELOAD peers mainly in that they don't store information on behalf of other nodes in the overlay ๐ซถ Instead, they use the overlay only to locate users and resources, store information, and contact other nodes ๐ฆ
These properties were designed specifically to meet the requirements for a P2P protocol that supports SIP ๐ This document defines the base protocol for the distributed storage and location service, plus the critical usage for NAT traversal. The SIP Usage itself is described separately in [SIP-RELOAD]. RELOAD isn't limited to SIP, though, and it could be a tool for supporting other P2P applications with similar needs โจ
1.1. Basic Setting
okay so this section is a quick overview of the operational setting for RELOAD ๐ธ A RELOAD Overlay Instance is a set of nodes arranged in a partly connected graph. Each node in the overlay is assigned a numeric Node-ID for the lifetime of the node. Together with the specific overlay algorithm in use, that Node-ID determines the node's position in the graph and the set of nodes it connects to. The Node-ID is also tightly coupled to the certificate (see Section 13.3). Here's a trivial example, which isn't drawn from any particular overlay algorithm but was picked because it's easy to look at ๐
+--------+ +--------+ +--------+
| Node 10|--------------| Node 20|--------------| Node 30|
+--------+ +--------+ +--------+
| | |
| | |
+--------+ +--------+ +--------+
| Node 40|--------------| Node 50|--------------| Node 60|
+--------+ +--------+ +--------+
| | |
| | |
+--------+ +--------+ +--------+
| Node 70|--------------| Node 80|--------------| Node 90|
+--------+ +--------+ +--------+
|
|
+--------+
| Node 85|
|(Client)|
+--------+
Because the graph isn't fully connected, when a node wants to send a message to another node, it may need to route it through the network ๐ฆ For example, Node 10 can talk directly to nodes 20 and 40, but not to Node 70. To send a message to Node 70, it would first send it to Node 40, with instructions to pass it along to Node 70 ๐งญ Different overlay algorithms have different connectivity graphs, but the big idea behind all of them is to let any node in the graph efficiently reach every other node within a small number of hops ๐
The RELOAD network isn't only a messaging network ๐ฆ It's also a storage network, albeit one designed for small-scale transient storage rather than bulk storage of large objects. Records are stored under numeric addresses called Resource-IDs, which occupy the same space as node identifiers. Peers are responsible for storing the data associated with some set of addresses, as determined by their Node-ID. For instance, we might say that every peer is responsible for storing any data value that has an address less than or equal to its own Node-ID, but greater than the next lowest Node-ID. So Node 20 would be responsible for storing values 11-20 ๐
RELOAD also supports clients ๐ These are nodes that have Node-IDs but don't participate in routing or storage. In the figure above, Node 85 is a client. It can route to the rest of the RELOAD network via Node 80, but no other node will route through it, and Node 90 is still responsible for addresses in the range [81..90] ๐ We refer to non-client nodes as peers.
Other applications (for instance, SIP) can be defined on top of RELOAD and can use these two basic RELOAD services to provide their own services ๐
1.2. Architecture ๐๏ธ
Okay so RELOAD is fundamentally an overlay network ๐ซถ which means it's a whole network sitting on top of the network. Here's the layered vibe:
Application
+-------+ +-------+
| SIP | | XMPP | ...
| Usage | | Usage |
+-------+ +-------+
------------------------------------ Messaging Service Boundary
+------------------+ +---------+
| Message |<--->| Storage |
| Transport | +---------+
+------------------+ ^
^ ^ |
| v v
| +-------------------+
| | Topology |
| | Plug-in |
| +-------------------+
| ^
v v
+------------------+
| Forwarding & |
| Link Management |
+------------------+
------------------------------------ Overlay Link Service Boundary
+-------+ +-------+
|TLS | |DTLS | ...
|Overlay| |Overlay|
|Link | |Link |
+-------+ +-------+
The major components of RELOAD are:
Usage Layer ๐ : each application defines a RELOAD Usage, which is a set of data Kinds and behaviors that describe how to use the services RELOAD provides. All of these usages talk to RELOAD through a common Message Transport Service.
Message Transport ๐จ: handles end-to-end reliability, manages request state for the usages, and forwards Store and Fetch operations to the Storage component. It delivers message responses to the component that started the request.
Storage ๐๏ธ: this one's responsible for processing messages about storing and retrieving data. It talks directly to the Topology Plug-in to manage data replication and migration, and it talks to the Message Transport component to send and receive messages.
Topology Plug-in ๐งฉ: this is where the specific overlay algorithm gets implemented. It uses the Message Transport component to send and receive overlay management messages, the Storage component to manage data replication, and the Forwarding Layer to control hop-by-hop message forwarding. It kinda parallels conventional routing algorithms, but it's way more tightly coupled to the Forwarding Layer, because there's no single "Routing Table" equivalent that every overlay algorithm uses. The Topology Plug-in has two functions: building the local forwarding instructions and selecting the operational topology (i.e., creating links by sending overlay management messages).
Forwarding and Link Management Layer ๐: stores and implements the Routing Table by providing packet forwarding services between nodes. It also handles establishing new links between nodes, including setting up connections for overlay links across NATs using ICE.
Overlay Link Layer ๐: responsible for actually transporting traffic directly between nodes. Transport Layer Security (TLS) [RFC5246] and Datagram Transport Layer Security (DTLS) [RFC6347] are the currently defined "overlay link layer" protocols RELOAD uses for hop-by-hop communication. Each one includes the appropriate provisions for per-hop framing and hop-by-hop ACKs needed by unreliable underlying transports. New protocols can be defined, as described in Sections 6.6.1 and 11.1. Since this document only defines TLS and DTLS, we'll use those terms throughout the rest of the document, with the understanding that some future specification may add new overlay link layers.
To further clarify the roles of the various layers, here's the architecture lined up with each layer's role from an overlay perspective and its implementation layer on the Internet ๐:
Internet | Internet Model |
Model | Equivalent | Reload
| in Overlay | Architecture
-------------+-----------------+------------------------------------
| | +-------+ +-------+
| Application | | SIP | | XMPP | ...
| | | Usage | | Usage |
| | +-------+ +-------+
| | ----------------------------------
| |+------------------+ +---------+
| Transport || Message |<--->| Storage |
| || Transport | +---------+
| |+------------------+ ^
| | ^ ^ |
| | | v v
Application | | | +-------------------+
| (Routing) | | | Topology |
| | | | Plug-in |
| | | +-------------------+
| | | ^
| | v v
| Network | +------------------+
| | | Forwarding & |
| | | Link Management |
| | +------------------+
| | ----------------------------------
Transport | Link | +-------+ +------+
| | |TLS | |DTLS | ...
| | +-------+ +------+
-------------+-----------------+------------------------------------
Network |
|
Link |
In addition to the above components, nodes may communicate with a central provisioning infrastructure (not shown) to get configuration information, authentication credentials, and the initial set of nodes to communicate with to join the overlay. ๐
1.2.1. Usage Layer ๐
Okay so the top layer is called the Usage Layer, and it has application usages like the SIP Registration Usage [SIP-RELOAD]. These use the abstract Message Transport Service that RELOAD provides. The goal here is to implement application-specific usages of the generic overlay services RELOAD offers. The Usage defines how a specific application maps its data into something that can be stored in the overlay, where to store it, how to secure it, and finally how applications can retrieve and use it. ๐
The architecture diagram shows both a SIP Usage and an XMPP Usage. A single application may need multiple usages. For example, a voicemail feature in a softphone app that stores links to the messages in the overlay would need a different usage than the rendezvous service of XMPP or SIP. A usage may define multiple Kinds of data that get stored in the overlay, and it may also rely on Kinds originally defined by other usages. โจ
Because each Kind's security and storage policies are dictated by the usage that defines it, the usages may be coupled with the Storage component to enforce security policy and to implement storage strategies that fit the needs of the usage. The exact implementation of that interface is outside the scope of this specification. ๐
1.2.2. Message Transport ๐
The Message Transport component provides a generic message routing service for the overlay. This layer is responsible for end-to-end message transactions. Each peer is identified by its location in the overlay, as determined by its Node-ID. A component that's a client of the Message Transport can do two basic things:
- Send a message to a given peer specified by Node-ID or to the peer responsible for a particular Resource-ID.
- Receive messages that other peers sent to a Node-ID or Resource-ID for which the receiving peer is responsible.
All usages rely on the Message Transport component to send and receive messages from peers. For instance, when a usage wants to store data, it does so by sending Store requests. Note that the Storage component and the Topology Plug-in are themselves clients of the Message Transport, because they need to send and receive messages from other peers. ๐ซง
The Message Transport Service handles end-to-end reliability, and it does that with timer-based retransmissions. Unlike the Internet transport layer, though, this layer does not provide congestion control. RELOAD is a request-response protocol, with no more than two pairs of request-response messages used in typical transactions between pairs of nodes, so there are no chances to observe and react to end-to-end congestion. As with all Internet applications, implementers are strongly discouraged from writing applications that react to loss by immediately retrying the transaction. ๐ โโ๏ธ
The Message Transport Service is similar to what's described as providing "key-based routing" (KBR) [wikiKBR]. But RELOAD supports different overlay algorithms (including non-DHT overlay algorithms) that calculate keys (storage indices, not encryption keys) in different ways, so the actual interface needs to accept Resource Names rather than actual keys. ๐๏ธ
The Forwarding and Link Management layers keep the overlay running when the available nodes and the underlying network supporting the overlay (the Internet) change. They also handle congestion control between overlay neighbors, and they exchange routing updates and data replicas in addition to forwarding end-to-end messages. ๐
Real-world experience has shown that a fixed timeout for the end-to-end retransmission timer is sufficient for practical overlay networks. This timer is adjustable via the overlay configuration. Since the overlay configuration can be rapidly updated, this value could be dynamically adjusted at coarse time scales, although algorithms for figuring out how to do that are beyond the scope of this specification. In many cases, though, other ways of improving network performance work better than just increasing the retransmission timer, like having the Topology Plug-in remove lossy links from use in overlay routing or reducing the overall hop count of end-to-end paths. ๐ธ
1.2.3. Storage ๐พ
okay so storage is literally one of RELOAD's biggest jobs ๐ซถ It lets nodes stash data in the overlay and fetch it back later, whether another node stored it or the node stored it itself โจ The Storage component handles data storage and retrieval messages. For example, it might get a Store request for some resource from the Message Transport. Then it queries the appropriate usage before saving the data value(s) in its local data store, and sends a response to the Message Transport so it can be delivered to the requesting node ๐ Usually these messages come from other nodes, but depending on the overlay topology, a node might be storing data for itself too, especially if the overlay is small ๐ง
A peer's Node-ID decides which set of resources it's responsible for storing ๐ The exact mapping between them is decided by the overlay algorithm in use. Storage only gets a Store request from the Message Transport if this peer is responsible for that Resource-ID, so no sneaking in ๐ The Topology Plug-in tells Storage whenever the Resource-IDs it's responsible for change, and then Storage is responsible for migrating resources to other peers.
1.2.4. Topology Plug-in ๐ฆ
RELOAD is explicitly designed to work with a whole bunch of overlay algorithms, and that's the vibe ๐ To make that happen, the overlay algorithm implementation comes from a Topology Plug-in. That way each overlay can pick an algorithm that fits while still relying on the common RELOAD core protocols and code.
The Topology Plug-in is responsible for maintaining the overlay algorithm Routing Table, which the Forwarding and Link Management Layer consults before routing a message. When connections are made or broken, the Forwarding and Link Management Layer notifies the Topology Plug-in, which adjusts the Routing Table as appropriate. The Topology Plug-in also instructs the Forwarding and Link Management Layer to form new connections as dictated by the requirements of the overlay algorithm Topology. It issues periodic update requests through Message Transport to maintain and update its Routing Table ๐
As peers enter and leave, resources might get stored on different peers, so the Topology Plug-in also keeps track of which peers are responsible for which resources ๐ As peers join and leave, it instructs the Storage component to issue resource migration requests as appropriate, so other peers end up with whatever resources they're now responsible for. The Topology Plug-in is also responsible for providing redundant data storage, which protects against loss of information if a peer fails and protects against compromised or subversive peers ๐ก๏ธ
1.2.5. Forwarding and Link Management Layer ๐ฃ๏ธ
The Forwarding and Link Management Layer is responsible for getting a message to the next peer, as determined by the Topology Plug-in ๐ฌ This layer sets up and maintains the network connections the Topology Plug-in needs. It's also responsible for setting up connections to other peers through NATs and firewalls using ICE, and it can choose to forward traffic using relays for NAT and firewall traversal ๐งฑ
Congestion control is implemented at this layer to protect the Internet paths used to form the link in the overlay ๐ฆ Retransmission is also performed to improve the reliability of end-to-end transactions. The relation of this layer to the Message Transport Layer can be likened to the relation of link-level congestion control and retransmission in modern wireless networks ` to Internet transport protocols ๐ถ
This layer provides a generic interface that lets the Topology Plug-in control the overlay and resource operations and messages. Since each overlay algorithm is defined and functions differently, we generically refer to the table of other peers that the overlay algorithm maintains and uses to route requests as a Routing Table ๐๏ธ The Topology Plug-in actually owns the Routing Table, and forwarding decisions are made by querying the Topology Plug-in for the next hop for a particular Node-ID or Resource-ID. If this node is the destination of the message, the message is delivered to the Message Transport ๐ฆ
This layer also uses a framing header to encapsulate messages as they're forwarded along each hop. The header aids reliability, congestion control, flow control, etc. It only has meaning in the context of that individual link ๐
The Forwarding and Link Management Layer sits on top of the Overlay Link Layer protocols that carry the actual traffic. This specification defines how to use DTLS and TLS protocols to carry RELOAD messages ๐
1.3. Security ๐
RELOAD's security model is based on each node having one or more public key certificates. In general, a central server assigns these certificates, and that same server also assigns Node-IDs, although self-signed certificates can be used in closed networks ๐ชช These credentials can be leveraged to provide communications security for RELOAD messages. RELOAD provides communications security at three levels:
- Connection level: Connections between nodes are secured with TLS, DTLS, or potentially some to-be-defined future protocol.
- Message level: Each RELOAD message is signed.
- Object Level: Stored objects are signed by the creating node.
These three levels work together so nodes can verify the origin and correctness of data they receive from other nodes, even in the face of malicious activity by other nodes in the overlay ๐ต๏ธโโ๏ธ RELOAD also provides access control built on top of these communications security features. Because the peer responsible for storing a piece of data can validate the signature on that data, it can determine whether or not a given operation is permitted โ
RELOAD also provides an optional shared-secret-based admission control feature using shared secrets and TLS pre-shared keys (PSK) or TLS Secure Remote Password (SRP). To form a TLS connection to any node in the overlay, a new node needs to know the shared overlay key, which restricts access to authorized users only ๐ This feature is used together with certificate-based access control, not as a replacement for it. It's typically used when self-signed certificates are being used, but it would generally not be used when the certificates were all signed by an enrollment server ๐
1.4. Structure of This Document ๐บ๏ธ
The remainder of this document is structured as follows ๐
- Section 3 provides definitions of terms used in this document.
- Section 4 provides an overview of the mechanisms used to establish and maintain the overlay.
- Section 5 provides an overview of the mechanism RELOAD provides to support other applications.
- Section 6 defines the protocol messages that RELOAD uses to establish and maintain the overlay.
- Section 7 defines the protocol messages that are used to store and retrieve data using RELOAD.
- Section 8 defines the Certificate Store Usages.
- Section 9 defines the TURN Server Usage needed to locate TURN (Traversal Using Relays around NAT) servers for NAT traversal.
- Section 10 defines a specific Topology Plug-in using a Chord-based algorithm.
- Section 11 defines the mechanisms that new RELOAD nodes use to join the overlay for the first time.
- Section 12 provides an extended example.
2. Requirements Language ๐
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [RFC2119]. ๐
3. Terminology ๐โจ
okay so these are the definitions bestie, and yes they're all in here for reference ๐ค Each term gets defined the first time it shows up in the text too, but this is the cheat sheet. Some of these use words that don't get explained until later in the spec, so don't panic if something feels confusing on the first read ๐ซถ
Admitting Peer (AP): a peer in the overlay that helps the Joining Node get into the Overlay ๐ช
Bootstrap Node: a network node that Joining Nodes use to help find the Admitting Peer ๐งญ
Client: a host that can store data in the overlay and retrieve data from it, but doesn't do any routing or data storage for the overlay. it's the lowkey helper that never has to carry the group ๐
Configuration Document: an XML document that holds all the Overlay Parameters for one overlay instance ๐
Connection Table: holds the connection info for the set of nodes a node is directly connected to, including nodes that aren't ready for routing yet โณ
Destination List: a list of Node-IDs, Resource-IDs, and Opaque IDs that a message gets routed through, in strict order. a single Node-ID, Resource-ID, or Opaque ID counts as a trivial Destination List ๐บ๏ธ When you put in more than one Node-ID, it becomes a loose source route. The list gets smaller at every hop, and it doesn't include the source but it does include the destination โจ
DHT: short for distributed hash table ๐ธ It's an abstract storage service that's built by spreading the contents of a hash table across a bunch of peers. so iconic ๐ญ
ID: the umbrella term for any kind of identifier in an Overlay. this document says an ID can be an Application-ID, a Kind-ID, a Node-ID, a transaction ID, a component ID, a response ID, a Resource-ID, or an Opaque ID ๐
Joining Node (JN): a node that's trying to become a peer in a particular Overlay ๐ฆ
Kind: a Kind is a specific type of data that can be stored in the overlay. applications make up new Kinds to store the data they need ๐ Each Kind gets a unique integer called a Kind-ID.
Kind-ID: a unique 32-bit value that identifies a Kind. Kind-IDs are either private or allocated by IANA (see Section 14.6) ๐ข
Maximum Request Lifetime: the longest a request will wait for a response โฐ It's the overlay reliability value (defined in Section 11.1) multiplied by the number of transmissions (defined in Section 6.2.1), so by default it comes out to 15 seconds ๐
Node: the word "node" means a host that can be either a peer or a client. RELOAD uses the same protocol for both, so a lot of the text applies to both of them. that's why the document says "node" when the text covers both, and uses "client" or "peer" when it only applies to one ๐ซถ
Node-ID: a value with a fixed but configurable length that uniquely identifies a node ๐ชช Node-IDs of all 0s and all 1s are reserved ๐ซ A value of 0 never goes over the wire, but implementations and APIs can use it to mean an invalid node. The Node-ID of all 1s is used on the wire as a wildcard ๐
Overlay Algorithm: the rules for working out which peers in an overlay store a given piece of data, and for working out the topology of connections between peers so you can find that data ๐งฉ
Overlay Instance: a specific overlay algorithm plus the group of peers that work together to provide read and write access to it. any number of overlay instances can run in an IP network at once, and each one operates separately from the others ๐
Overlay Parameters: a set of values that every node in an overlay shares. they get distributed in an XML document called the Configuration Document ๐ฎ
Peer: a host that's taking part in the overlay ๐ค Peers hold some portion of the data stored in the overlay, and they route messages for other hosts as the Overlay Algorithm needs โจ
Peer Admission: the act of admitting a node (the Joining Node) into an Overlay. once admission is done, the Joining Node is a fully functional peer of the overlay ๐ During admission, the Joining Node may need to show credentials that prove it has enough authority to join ๐
Resource: an object or a group of objects stored in a P2P network ๐ฆ
Resource-ID: a value that identifies some resources and gets used as the key for storing and retrieving them. it's often not human friendly or readable ๐ One way to make one is to run a mapping function on some other unique name for the resource, like a user name or a service name. The distributed database algorithm uses the Resource-ID to figure out which peer or peers are responsible for storing the data for the overlay. In structured P2P networks, Resource-IDs are usually fixed length and formed by hashing the Resource Name. In unstructured networks, Resource Names can be used directly as Resource-IDs and can be variable length ๐ง
Resource Name: the name a resource goes by. in unstructured P2P networks, the Resource Name is sometimes used directly as a Resource-ID. in structured P2P networks, it's usually mapped into a Resource-ID by feeding the string into a hash function. Structured and unstructured P2P networks are described in [RFC5694] ๐ A SIP resource, for example, is often identified by its AOR (address-of-record), which is one example of a Resource Name ๐
Responsible Peer: the peer that's responsible for a specific resource, as defined by the Topology Plug-in algorithm ๐ฏ
Routing Table: the set of directly connected peers a node can use to forward overlay messages ๐ฃ๏ธ In normal operation, all of these peers will be in the Connection Table, but not the other way around, because some peers might not be available for routing yet. Peers can send messages directly to peers in their Connection Tables, but they can only forward messages to peers that aren't in their Connection Table through peers that are in the Routing Table ๐
Successor Replacement Hold-Down Time: how long to wait before starting replication once a new successor is found. it defaults to 30 seconds โณ๐ธ
Transaction ID: a randomly chosen identifier picked by whoever originates a request. it's used to match requests up with their responses ๐
Usage: the definition of a set of data structures (data Kinds) that an application wants to store in the overlay ๐ง A usage can also define a set of network protocols (Application IDs) that can be tunneled over TLS or DTLS direct connections between nodes. for example, the SIP Usage defines a SIP registration data Kind, which has info on how to reach a SIP endpoint, plus two Application IDs for the SIP and SIPS protocols ๐
User: a physical person identified by the certificates assigned to them ๐งโ๐คโ๐ง
User Name: a name that identifies a user of the overlay. it's usually used as a Resource Name, or as a label on a resource that says which user owns it ๐ท๏ธ
4. Overlay Management Overview ๐
okay the most basic job of RELOAD is being a generic overlay network ๐ธ๏ธ Nodes need to be able to join the overlay, connect to other nodes, and route messages through the overlay to nodes they aren't directly connected to. literally the whole vibe ๐ This section gives you an overview of the mechanisms that make all of that happen โจ
4.1. Security and Identification โจ
okay so the overlay's settings live in a Configuration Document ๐, and it holds security-critical stuff like the certificate signing trust anchors ๐. That's why it has to be retrieved securely, no cap. The very first Configuration Document is either fetched over HTTPS or provisioned by hand ๐. After that, updates can come in two ways. Either the configuration server refreshes them on a schedule, or (the more common move) they get flood-filled through the overlay ๐, which is super fast once someone pushes an update. In that second case, each update is backed by digital signatures that trace all the way back to the initial Configuration Document ๐
Every node in a RELOAD overlay is identified by a Node-ID ๐ชช. The Node-ID does three big jobs:
- It addresses the node itself.
- It tells you where the node sits in the overlay topology (only if the overlay is structured, because overlays don't have to be structured ๐ง).
- It tells you which set of resources the node is responsible for.
Each node has a certificate [RFC5280] with its Node-ID in a subjectAltName extension ๐, and that Node-ID has to be unique within an overlay instance. The certificate is giving multitasker energy, because it does a bunch of things:
- It entitles the user to store data at specific locations in the Overlay Instance ๐พ. Every data Kind sets its own rules for who can access each Resource-ID/Kind-ID pair. Some Kinds let anyone write to a spot, while others only let the owner of one certificate write ๐
- It entitles the user to run a node with the Node-ID in the certificate ๐ฅ๏ธ. When a node connects to another peer, it uses this certificate so the other side knows it's talking to the right node. (Technically, a TLS or DTLS association with client authentication gets formed ๐ค.) The node can also sign its messages, which gives integrity and authentication for everything it sends ๐๏ธ
- It entitles the user to use the user name found in the certificate ๐ท๏ธ
If you have more than one device, you'd usually get one certificate per device ๐ฑ๐ป. That way each device shows up as its own separate peer ๐ซถ
RELOAD supports more than one way to issue certificates. The first is a central enrollment process ๐ซ. It hands out a unique name and Node-ID and bakes them into the user's certificate. Every peer in an Overlay Instance trusts the enrollment server as a trust anchor, so any peer can verify any other peer's certificate โ
The second model is for groups who want an overlay but don't care about attacks from other users on the network ๐คทโโ๏ธ. Think a bunch of people on one LAN setting up a quick ad hoc network without the hassle of an enrollment server ๐๏ธ. RELOAD supports self-generated, self-signed certificates for this. When you go that route, the node also makes its own Node-ID and user name ๐ช. The Node-ID is a digest of the public key, which prevents Node-ID theft ๐ซ. The property that matters for that digest is partial preimage resistance. Collision resistance isn't needed, because an attacker who makes two nodes with the same Node-ID but different public keys gets zero advantage out of it ๐ โโ๏ธ. BUT this model is still subject to a bunch of known attacks (most notably, Sybil attacks [Sybil]) ๐ฑ, so it can be safely used only in closed networks where the users are mutually trusting ๐ฅน. Another downside is that the user's data gets tied to their key. If the key changes, any data stored under their Node-ID has to be re-stored ๐ญ. This isn't a problem for centrally issued Node-IDs, as long as the Certification Authority (CA) reissues the same Node-ID whenever a new certificate is generated ๐
The big principle here is that the security mechanisms are always on, even when the certificates are self-signed ๐โจ. That's TLS or DTLS at the data link layer and message signatures at the message transport layer. Keeping them on means there's one single set of code paths in the systems, and the only difference is whether certificate verification is used to chain up to a single root of trust ๐ณ
4.1.1. Shared-Key Security ๐
RELOAD also has an admission control system based on shared keys ๐ช. In this model, all the peers share a single key, which is used to authenticate the peer-to-peer connections via TLS-PSK [RFC4279] or TLS-SRP [RFC5054] ๐ค
4.2. Clients ๐
RELOAD uses one single protocol as both the peer protocol and the client protocol for the overlay ๐. Having just one protocol keeps implementation simple, especially for devices that might play either role, and it lets clients inject messages straight into the overlay ๐ซ
Quick vocab check ๐: a "peer" is a node in the overlay that routes messages for nodes other than the ones it's directly connected to. Peers also have storage responsibilities. A "client" is a node with no routing or storage responsibilities. When text applies to both, we just call them "nodes" ๐ซง
RELOAD's client support means nodes that aren't participating as peers can still use the same implementation and get the same security mechanisms as the peers ๐. Clients have certificates that authorize the user to store data at certain locations in the overlay. The Node-ID in that certificate identifies the client as a member of the overlay and authenticates its messages ๐ชช
Here's the tea ๐ต: unlike some other designs, clients in RELOAD are not first-class entities. From a peer's point of view, a client is a node that has connected to the overlay but hasn't yet inserted itself into the overlay topology ๐. It might never do that (if it really is a client), or it might eventually (if it's just a node taking a long time to join) โณ. The routing and storage rules give correct behavior from the peers no matter whether the nodes attached to them are clients or peers ๐ฏ. A client implementation does need to know it's a client, but that complexity stays local to that one node ๐งโโ๏ธ
If you want more on why RELOAD does client support this way, check out Appendix B ๐
4.2.1. Client Routing ๐ฃ๏ธ
Clients can insert themselves into the overlay in two ways ๐ซถ:
- They can establish a connection to the peer responsible for the client's Node-ID in the overlay. After that, requests can be sent to and from the client using its Node-ID, just like a peer would do, because the responsible peer handles the final step of routing to the client ๐ฌ. This may require a TURN [RFC5766] relay when NATs or firewalls stop the client from forming a direct connection with its responsible peer ๐ง. Note that clients taking this option need to process Update messages from the peer (Section 6.4.2.3) ๐. These updates can say the peer is no longer responsible for the client's Node-ID. The client would then need to form a connection to the appropriate peer. If it doesn't, the client will stop receiving messages ๐ฑ
- They can establish a connection with an arbitrary peer in the overlay, maybe based on network proximity or because they can't make a direct connection with the responsible peer ๐. In this case, the client relies on RELOAD's Destination List feature (Section 6.3.2.2) to make sure it can be reached ๐งญ. The client can start requests, and any node in the overlay that knows the Destination List to its current location can reach it. But the client isn't directly reachable using only its Node-ID ๐. If the client needs to receive incoming requests from other members of the overlay, the Destination List needed to reach it has to be learnable through other mechanisms, such as being stored in the overlay by a usage ๐ฆ. A client connected this way with a certificate that has only a single Node-ID can keep using the connection without doing an Attach (Section 6.5.1) โจ. A client that wants to connect this way with a certificate holding multiple Node-IDs can use a Ping (Section 6.5.3) to probe the Node-ID of the node it's connected to before doing the Attach ๐
4.2.2. Minimum Functionality Requirements for Clients ๐
A node may act as a client just because it doesn't have the capacity or need to act as a peer, or because it doesn't even have an implementation of the Topology Plug-in defined in Section 6.4.1, which is needed to act as a peer ๐งธ. To exchange RELOAD messages with a peer, a client needs to meet a minimum level of functionality ๐ช. Such a client will:
- Implement RELOAD's connection-management operations that are used to establish the connection with the peer ๐.
- Implement RELOAD's data retrieval methods (with client functionality) ๐ฅ.
- Be able to calculate the Resource-IDs used by the overlay ๐งฎ.
- Possess the security credentials needed by the overlay it's implementing ๐.
A client speaks the same protocol as the peers, knows how to calculate Resource-IDs, and signs its requests in the same way as peers do ๐๏ธ. A client doesn't necessarily need a full implementation of the overlay algorithm, but calculating the Resource-ID does require an implementation of an appropriate algorithm for the overlay ๐
4.3. Routing โจ
okay bestie, this is where RELOAD's routing brain lives ๐ง ๐ we're covering what the routing layer can do, the features that make it happen, and a quick look at how they all click together. Appendix A has the alternative designs and the tradeoffs if you want to go down that rabbit hole ๐
RELOAD's routing gives you these capabilities, and honestly they're giving main character ๐
- Resource-based Routing: messages get routed using only the name of the resource ๐ฏ they get delivered to a node that's responsible for that resource. Both structured and unstructured overlays are supported, so the route might not be deterministic for every Topology Plug-in.
- Node-based Routing: messages can be sent to one specific node in the overlay ๐ฆ
- Clients: requests can go to and from clients that don't take part in overlay routing ๐ clients get located through either of the mechanisms above.
- NAT Traversal: connections between nodes separated by one or more NATs, plus finding peers behind NATs for overlays that allow or require it ๐ง
- Low State: routing doesn't need a ton of state stored on intermediate peers (i.e., state linear or greater in the number of outstanding messages that have passed through it) ๐
- Routability in Unstable Topologies: overlays of moderate size are always changing because individual nodes and links fail ๐ญ RELOAD lets peers reroute messages when a failure is detected. Replies can come back to the requesting node as long as the peers that originally forwarded the successful request don't fail before the response gets back.
RELOAD's routing runs on three basic mechanisms:
- Destination Lists: technically you could inject a message into the overlay with a single Node-ID as the destination, but RELOAD gives you source routing with "Destination Lists" ๐บ๏ธ a Destination List is an ordered list of the nodes a message flows through (i.e., it is loose source routed). The minimal one has just a single value.
- Via Lists: so responses can follow the same path as requests, every message also carries a "Via List" ๐ each node the message passes through appends to it. The Via List can then be inverted and used as a Destination List for the response.
- RouteQuery: this lets a node ask a peer for the next hop it would use to route a message. It's super useful for diagnostics and for iterative routing (see Section 6.4.2.4) ๐
The basic routing mechanism RELOAD uses is symmetric recursive routing โจ we'll go over how it works first, then talk about why it's so good for the requirements we just covered.
With symmetric recursive routing, a request message follows a path through the overlay to its destination, with each peer forwarding it closer to where it's going ๐ the response's return path goes through the same nodes as the request (though it might also pass through some new intermediate nodes because of topology changes). Quick heads-up: if the reverse path breaks because of a topology change after the request was sent, that gets handled by the end-to-end retransmission of the response, as described in Section 6.2.1 ๐ซถ
Here's a message going from A to Z through B and X:
A B X Z
-------------------------------
---------->
Dest=Z
---------->
Via=A
Dest=Z
---------->
Via=A,B
Dest=Z
<----------
Dest=X,B,A
<----------
Dest=B,A
<----------
Dest=A
Quick note: this figure doesn't show whether A is a client or a peer. A forwards its request to B, and the response comes back to A the same way no matter what role A plays in the overlay ๐
This figure uses full Via Lists at intermediate peers B and X. But if B and/or X are willing to store state, they can choose to truncate the lists and save the truncated info internally, using the transaction ID as a key so they can get it back later ๐๏ธ when the response shows up, the transaction ID is used to recover the truncated info, and the response goes back along the path the request came in on. This option needs more state stored on intermediate peers, but it saves a little bandwidth and cuts down on changing the message en route. Whether a peer uses this is its own call, and the techniques are interoperable even on a single message ๐ The figure below has B using full Via Lists, while X truncates them to X1 and saves the state internally:
A B X Z
-------------------------------
---------->
Dest=Z
---------->
Via=A
Dest=Z
---------->
Via=X1
Dest=Z
<----------
Dest=X,X1
<----------
Dest=B,A
<----------
Dest=A
Same as before, when B receives the message, B creates a Via List containing [A]. But instead of sending [A, B], X creates an opaque ID X1 that maps internally to [A, B] (maybe by being an encryption of [A, B]), then forwards to Z with only X1 as the Via List ๐ When the response reaches X, X maps X1 back to [A, B], inverts it to make the new Destination List [B, A], and routes it to B. Iykyk, it's so clever ๐ง โจ
RELOAD also supports a basic iterative "routing" mode ๐ here, intermediate peers just return a response that names the next hop, and they don't actually forward the message to that next hop themselves. Iterative routing runs on the RouteQuery method (see Section 6.4.2.4), which is what asks for this behavior. And only the initiating node can pick iterative routing.
4.4. Connectivity Management
okay so to route efficiently, a peer has to keep a set of direct connections to other peers in the Overlay Instance ๐ค but because of NATs, those connections often can't just be formed directly ๐ค so instead we use the Attach request to set one up. Attach uses Interactive Connectivity Establishment (ICE) [RFC5245] to make the connection, and it's assumed you already know ICE ๐
Say peer A wants a direct connection to peer B, either to join the overlay or to add more connections to its Routing Table ๐ฅน A gathers its ICE candidates, packages them up in an Attach request, and sends it to B through the usual overlay routing procedures. B does its own candidate gathering and sends back a response with its candidates. Then A and B run ICE connectivity checks on the candidate pairs, and boom, there's a connection between them โจ At this point, A and B MAY send messages directly to each other without going through other overlay peers. Basically, A and B are now in each other's Connection Tables. They MAY then run an Update process, which adds entries to each other's Routing Tables, and then they can route messages through each other to other overlay nodes ๐ฆ
There are two cases where Attach isn't used, bestie ๐
The first case is when a peer is joining the overlay and isn't connected to any peers yet. To make that work, a small number of bootstrap nodes usually need to be publicly accessible so new peers can connect to them directly ๐ธ Section 11 has more detail on this. The second case is when a client connects to a peer at an arbitrary IP address, instead of to its responsible peer, as described in the second bullet point of Section 4.2.1 ๐
In general, a peer needs to keep connections to all the peers near it in the Overlay Instance, plus enough other peers for efficient routing (what "enough" and "near" mean depends on the specific overlay ๐งฉ). If a peer can't form a connection to some other peer, it's not a total disaster, because overlays can route correctly even without fully connected links ๐ That said, a peer still needs to try to maintain the Routing Table specified by the Topology Plug-in algorithm, and it needs to form new connections if it notices it has fewer direct connections than the algorithm specifies. This also means peers, following the Topology Plug-in algorithm, need to periodically check that their connected peers are still alive. If one isn't, they need to try to re-form that connection or form an alternate one ๐ For an example of how a specific overlay algorithm handles these constraints, see Section 10.7.4.3 ๐
4.5. Overlay Algorithm Support
The Topology Plug-in lets RELOAD support a bunch of different overlay algorithms ๐ This specification defines a DHT based on Chord, and it's mandatory to implement ๐ซก But the base RELOAD protocol is designed to work with lots of overlay algorithms. Everything you need to implement this DHT is in this specification, but it's easier to get if you're familiar with Chord-based [Chord] DHTs. A nice tutorial is at [wikiChord] ๐
4.5.1. Support for Pluggable Overlay Algorithms
RELOAD defines three methods for overlay maintenance: Join, Update, and Leave ๐ง But the contents of these messages, when they're sent, and their exact semantics are all specified by the actual overlay algorithm. That algorithm is set by configuration for all nodes in the overlay, so nodes know it before they try to join โจ RELOAD just provides a framework of commonly needed methods, which gives you uniform notation (and makes debugging easier) across a bunch of different overlay algorithms ๐
4.5.2. Joining, Leaving, and Maintenance Overview โจ
Okay bestie, when a brand new peer wants to join an Overlay Instance ๐ฆ, it needs two things: a Node-ID it's actually allowed to use, and a set of credentials that match that Node-ID. If there's an enrollment server involved, the Node-ID is whatever's in the certificate it got from that server ๐. The exact joining steps are up to the overlay algorithm, but the general vibe is:
- Form connections to some other peers.
- Acquire the data values this peer is responsible for storing.
- Inform the other peers which were previously responsible for that data that this peer has taken over responsibility.
So the very first thing the peer has to do is connect to some bootstrap node ๐ธ. Since that's its first ever connection, those bootstrap nodes need public IP addresses so the new peer can reach them directly. Once it's connected to one or more of them, it can make more connections the usual way, by routing Attach messages through the overlay to other nodes ๐. After a peer has been on the overlay for the first time, it can cache the past adjacencies that have public IP addresses and try using those as future bootstrap nodes. Heads up though: this needs some sense of which addresses are likely to be public, which is covered in Section 9 ๐.
Once it's hooked up to a bootstrap node, it needs to find its real spot in the overlay ๐ . That's two big operations:
- Form connections to other peers in the overlay to populate its Routing Table.
- Get a copy of the data it is now responsible for storing, and assume responsibility for that data.
The second one happens by contacting the Admitting Peer (AP), which is whichever node is currently in charge of that section of the overlay ๐. The details mostly depend on the overlay algorithm, but a typical flow looks like this:
- JN sends a Join request to AP announcing its intention to join.
- AP sends a Join response.
- AP does a sequence of Stores to JN to give it the data it will need.
- AP does Updates to JN and to other peers to tell them about its own Routing Table. At this point, both JN and AP consider JN responsible for some section of the Overlay Instance.
- JN makes its own connections to the appropriate peers in the Overlay Instance.
After all that, JN is a full member of the Overlay Instance and can process Store/Fetch requests ๐ฅน slay.
Note that the first node is a special case ๐ง. When ordinary nodes can't form connections to the bootstrap nodes, they aren't part of the overlay at all. But the very first node obviously can't connect to other nodes, since there aren't any yet. So potential first nodes (which can also start out as bootstrap nodes) need some way to be told that they are the entire overlay, rather than joining an existing one. For example, they could compare their own IP address to the bootstrap IP addresses in the configuration file.
Note that clients do not perform either of these operations ๐.
4.6. First-Time Setup ๐
Previous sections covered how RELOAD works after a node has connected. This section gives an overview of how users get connected to the overlay for the first time. RELOAD is designed so that users can start with the name of the overlay they want to join, and maybe an account name and password, and then turn those into a working peer with minimal user intervention. This helps avoid the problems people have had with conventional SIP clients, where users have to manually configure a huge pile of settings ๐ญ.
4.6.1. Initial Configuration
In the first phase of setup, the user starts with the name of the overlay and uses it to download an initial set of overlay configuration parameters. The node does a DNS SRV [RFC2782] lookup on the overlay name to get the address of a configuration server. It can then connect to this server with HTTPS [RFC2818] to download a Configuration Document. That document contains the basic overlay configuration parameters, plus a set of bootstrap nodes that can be used to join the overlay. The details of how names in the HTTPS certificates relate to overlay names are described in Section 11.2 ๐.
If a node already has a valid Configuration Document that it got by an out-of-band method, this step can be skipped. Note that this out-of-band method needs to provide authentication and integrity, because the Configuration Document contains the trust anchors used by the overlay.
4.6.2. Enrollment
If the overlay is using centralized enrollment, then a user needs to acquire a certificate before joining the overlay. The certificate attests both to the user's name within the overlay and to the Node-IDs they're permitted to operate. In this case, the Configuration Document will contain the address of an enrollment server that can be used to obtain such a certificate. It will also contain the trust anchor, so this document must be retrieved securely (see Section 11.2) ๐ โโ๏ธ. The enrollment server may (and probably will) require some sort of account name for the user and a password before issuing the certificate. The enrollment server's ability to make sure attackers can't get a large number of certificates for the overlay is one of the cornerstones of RELOAD's security ๐ก๏ธโจ.
4.6.3. Diagnostics
Significant advice about managing a RELOAD overlay, plus extensions for diagnostics, are described in [P2P-DIAGNOSTICS] ๐ฉบ.
5. Application Support Overview ๐
RELOAD isn't meant to be used alone. It's more of a substrate for other applications ๐ง. These applications can use RELOAD for a few different things:
- To store data in the overlay and to retrieve data stored by other nodes.
- As a discovery mechanism for services such as TURN.
- To form direct connections that can be used to transmit application-level messages without using the overlay.
This section gives an overview of these services.
5.1. Data Storage ๐๏ธ
RELOAD provides operations to Store and Fetch data. Each location in the Overlay Instance is referenced by a Resource-ID. However, each location may contain data elements corresponding to multiple Kinds (e.g., certificate and SIP registration). Similarly, there may be multiple elements of a given Kind, as shown below:
+--------------------------------+
| Resource-ID |
| |
| +------------+ +------------+ |
| | Kind 1 | | Kind 2 | |
| | | | | |
| | +--------+ | | +--------+ | |
| | | Value | | | | Value | | |
| | +--------+ | | +--------+ | |
| | | | | |
| | +--------+ | | +--------+ | |
| | | Value | | | | Value | | |
| | +--------+ | | +--------+ | |
| | | +------------+ |
| | +--------+ | |
| | | Value | | |
| | +--------+ | |
| +------------+ |
+--------------------------------+
Each Kind is identified by a Kind-ID, which is a code point either assigned by IANA or allocated out of a private range. As part of the Kind definition, protocol designers may define constraints (such as limits on size) on the values that may be stored. For many Kinds, the set may be restricted to a single value. Some sets may be allowed to contain multiple identical items, and others may have only unique items. Note that a Kind may be used by multiple usages, and new usages are encouraged to use previously defined Kinds where possible. We define the following data models in this document, although other usages can define their own structures:
- single value: There can be at most one item in the set, and any value overwrites the previous item.
- array: Many values can be stored and addressed by a numeric index.
- dictionary: The values stored are indexed by a key. Often, this key is one of the values from the certificate of the peer sending the Store request.
To protect stored data from tampering by other nodes, each stored value is individually digitally signed by the node that created it. When a value is retrieved, the digital signature can be verified to detect tampering. If the certificate used to verify the stored value's signature expires, the value can no longer be retrieved. It may not be garbage collected right away by the storing node, though. If the creating node wants the stored value to stay available, it will need to store the value again ๐.
5.1.1. Storage Permissions
A big issue in peer-to-peer storage networks is minimizing the burden of becoming a peer and, in particular, minimizing the amount of data any peer needs to store for other nodes ๐ฎโ๐จ. RELOAD handles this by allowing any given node to store data only at a small number of locations in the overlay. Those locations are determined by the node's certificate. When a peer uses a Store request to place data at a location its certificate authorizes, it signs that data with the private key that corresponds to its certificate. Then the peer responsible for storing the data can verify that the peer issuing the request is authorized to make that request. Each data Kind defines the exact rules for determining which certificate is appropriate ๐.
The most natural rule is that a certificate authorizes a user to store data keyed with their user name X. So only a user with a certificate for "alice@example.org" could write to that location in the overlay (see Section 11.3). However, other usages can define any rules they choose, including publicly writable values ๐.
The digital signature over the data does two jobs. First, it lets the peer responsible for storing the data verify that the Store is authorized. Second, it provides integrity for the data. The signature is saved along with the data value (or values), so any reader can verify the integrity of the data. Of course, the responsible peer can "lose" the value, but it can't modify it without being detected ๐ต๏ธโโ๏ธ๐.
The size requirements of the data being stored in the overlay vary. For instance, a SIP AOR and voicemail differ widely in storage size. RELOAD leaves it to the usage and overlay configuration to limit size imbalances between Kinds ๐ซถ.
5.1.2. Replication โจ
okay so replication in P2P overlays is lowkey a whole vibe ๐ซถ it can give you:
- persistence ๐พ: if the responsible peer crashes, and/or if the storing peer leaves the overlay
- security ๐ก๏ธ: guarding against DoS attacks by the responsible peer, or routing attacks aimed at that responsible peer
- load balancing โ๏ธ: spreading out the queries for popular resources so nobody gets overwhelmed
there are a bunch of schemes P2P overlays use to hit some of these goals ๐ธ the common ones are replicating on the neighbors of the responsible peer, randomly locating replicas all around the overlay, and replicating along the path to the responsible peer. so many options, bestie ๐ญ
the core RELOAD spec does NOT pick one specific replication strategy ๐ instead, the first level of replication is decided by the overlay algorithm, which can base its strategy on its own topology. for example, Chord places replicas on successor peers, so if the responsible peer fails, a successor can take over [Chord] ๐ฆ the way that works is so clean.
if you need extra replication, like if data persistence is super important for a particular usage, then that usage can specify more replication on top ๐ for example, it could do random replication by inserting a different well-known constant into the Resource Name used to store each replicated copy of the resource. the best part is these replication strategies can be added independently of the underlying algorithm, and each usage can pick what it needs ๐ง
5.2. Usages ๐
by itself, the distributed storage layer only gives you the infrastructure ๐๏ธ to do anything useful, you need a usage. ngl, every usage needs to specify a few things:
- Register Kind-ID code points for any Kinds that the usage defines (Section 14.6).
- Define the data structure for each of the Kinds (the value member in Section 7.2). If the data structure contains character strings, conversion rules between characters and the binary storage need to be specified.
- Define access control rules for each of the Kinds (Section 7.3).
- Define how the Resource Name is used to form the Resource-ID where each Kind is stored.
- Describe how values will be merged when a network partition is being healed.
a usage can also apply the Kinds it defines to other usages ๐ but if you need different parameters, like a different access control model, that means you need to make a brand new Kind. no shortcuts, periodt ๐
5.3. Service Discovery ๐
RELOAD doesn't currently define a generic service discovery algorithm as part of the base protocol ๐ฅฒ it does have a simplistic TURN-specific discovery mechanism though. a bunch of service discovery algorithms can be built as extensions to the base protocol instead, like the service discovery algorithm ReDIR [opendht-sigcomm05] and [REDIR-RELOAD] โจ
5.4. Application Connectivity ๐
there's no requirement that a RELOAD usage has to use RELOAD's primitives for setting up its own communication if it already has its own way to make connections ๐ like, you could design a RELOAD-based resource discovery protocol that used HTTP to retrieve the actual data. very flexible, very iconic.
for more common situations though, it's the overlay itself, not an external authority like DNS, that's used to establish a connection ๐ซถ RELOAD gives applications connectivity through the AppAttach method. for example, if a P2PSIP node wants to set up a SIP dialog with another P2PSIP node, it uses AppAttach to create a direct connection with that other node. this new connection is separate from the peer protocol connection, and it's a dedicated DTLS or TLS flow used only for the SIP dialog. main character energy ๐
6. Overlay Management Protocol ๐
this section is where the basic protocols live ๐ง they're used to create, maintain, and use the RELOAD overlay network. first we go over how message destinations get interpreted when routing messages. then we get into the symmetric recursive routing model, which is RELOAD's default routing algorithm. last but not least, we define the message structure and the messages used to join and maintain the overlay ๐
6.1. Message Receipt and Forwarding ๐ฌ
when a node receives a message, it first checks the overlay, version, and other header fields to figure out whether it can process that message ๐ if any of those are wrong, as defined in Section 6.3.2, it's an error and the message MUST be discarded. the peer SHOULD generate an appropriate error, but local policy can override that and make the message get silently dropped instead ๐
once the peer has decided the message is correctly formatted (and note that this doesn't include signature-checking on intermediate nodes, because the message might be fragmented ๐งฉ), it looks at the first entry on the Destination List. there are three possible cases:
- The first entry on the Destination List is an ID for which the peer is responsible. A peer is always responsible for the wildcard Node-ID. This case is handled in Section 6.1.1.
- The first entry on the Destination List is an ID for which another peer is responsible. This case is handled in Section 6.1.2.
- The first entry on the Destination List is an opaque ID that's being used for Destination List compression. This case is handled in Section 6.1.3. Note that opaque IDs can be told apart from Node-IDs and Resource-IDs on the wire, as described in Section 6.3.2.2 ๐
each case gets handled as discussed below ๐
6.1.1. Responsible ID ๐ซง
if the first entry on the Destination List is an ID for which the peer is responsible, there are several subcases to consider, and they're mutually exclusive ๐
- If the entry is a Resource-ID, then it MUST be the only entry on the Destination List. If there are other entries, the message MUST be silently dropped. Otherwise, the message is destined for this node, so the node MUST verify the signature as described in Section 7.1 and MUST pass it to the upper layers. "Upper layers" here means the components above the "Overlay Link Service Boundary" line in the figure in Section 1.2 โจ
- If the entry is a Node-ID which equals this node's Node-ID, then the message is destined for this node. If it's the only entry on the Destination List, the message is destined for this node, so the node passes it to the upper layers. Otherwise, the node removes the entry from the Destination List and repeats the routing process with the next entry on the Destination List. If the message is a response and list compression was used, then the node first modifies the Destination List to reinsert the saved state, for example by unpacking any opaque IDs ๐ง
- If the entry is the wildcard Node-ID (all
1s), the message is destined for this node, and the node passes the message to the upper layers. A message with a wildcard Node-ID as its first entry is never forwarded. It's consumed locally, full stop ๐ - If the entry is a Node-ID which is not equal to this node, then the node MUST drop the message silently unless the Node-ID corresponds to a node which is directly connected to this node (in other words, a client). In that latter case, the node MUST attempt to forward the message to the destination node as described in the next section. This may fail for connectivity reasons, because the TTL has expired, or because of some other error ๐ฅบ
note that this process implies that if you want to address a message to "the peer that controls region X," the sender sends to Resource-ID X, not Node-ID X ๐ฏ bestie, don't mix those up ๐
6.1.2. Other ID โจ
Okay so, if the first entry on the Destination List is neither an opaque ID nor an ID the peer is responsible for, the peer MUST forward the message towards that entry ๐ . That means it MUST select one of the peers it's connected to that is most likely to be responsible (according to the Topology Plug-in) for the first entry on the Destination List ๐ฆ. For the CHORD-RELOAD topology, the routing to the most likely responsible node is explained in Section 10.3 ๐ธ. If the first entry on the Destination List is in the peer's Connection Table, the peer MUST forward the message to that peer directly ๐. Otherwise, the peer consults the Routing Table to forward the message ๐ง.
Any intermediate peer that forwards a RELOAD request MUST ensure that if it gets a response to that message, the response can be routed back through the same nodes the request passed through ๐. The peer picks one of these approaches:
- The peer can add an entry to the Via List in the forwarding header that will let it figure out the correct node. This is done by appending to the Via List the Node-ID of the node the request came from ๐.
- The peer can keep per-transaction state that lets it figure out the correct node ๐๏ธ.
Let's do the first strategy with nodes A, B, C, D, and E ๐. If node D gets a message from node C with Via List [A, B], then D forwards it to the next node, E, with Via List [A, B, C]. Now, if E wants to respond, it reverses the Via List to make the Destination List, which ends up as [D, C, B, A]. When D forwards the response to C, the Destination List will be [C, B, A] ๐.
Now the second strategy: if node D gets a message from node C with transaction ID X (as assigned by A) and Via List [A, B], it could store [X, C] in its state database and forward the message with the Via List unchanged ๐ง . When D gets the response, it checks its state database for transaction ID X, sees the request came from C, and forwards the response to C ๐.
Intermediate peers that modify the Via List don't have to just add entries. The only real rule is that the peer MUST be able to rebuild the correct Destination List on the return route ๐. RELOAD actually supports this with opaque IDs, which can replace any number of Via List entries ๐ซถ.
So in the example above, Node D might send E a Via List containing only the opaque ID I. E would then use the Destination List [D, I] to send its return message. When D processes this Destination List, it notices that I is an opaque ID, recovers the Via List [A, B, C], and reverses it to make the correct Destination List [C, B, A] before sending it to C ๐ช. This feature is called "list compression" ๐๏ธ. Possibilities for an opaque ID include a compressed and/or encrypted version of the original Via List, and an index into a state database containing the original Via List, but the details are a local matter ๐คซ.
No matter which mechanism is used to store Via List state, if an intermediate peer leaves the overlay, the message can't be forwarded on the return trip and will get dropped ๐. The ordinary timeout and retransmission mechanisms give stability over this kind of failure ๐.
If an intermediate peer keeps per-transaction state instead of modifying the Via List, it needs some way to time that state out, or its state database would grow without bound ๐. Whatever algorithm is used, the state MUST be kept for at least the value of the overlay-reliability-timer configuration parameter, and MAY be kept longer, unless a FORWARD_CRITICAL forwarding option (Section 6.3.2.3) or an overlay configuration option explicitly says this state isn't needed ๐งพ. Future extensions, such as [P2PSIP-RELAY], may define ways to figure out when this state doesn't need to be kept anymore ๐ฎ.
There's no requirement that a request sent after receiving a response follows the same path as that response ๐ค๏ธ. So there's no requirement to use either of the mechanisms above (Via List or state retention) when processing a response message ๐.
A node that gets a request from another node MUST ensure that any response to that request leaves that node with a Destination List equal to the Node-ID of the node the request came from, concatenated with the Via List from the original request ๐ฏ. The intermediate node usually learns the Node-ID the other node is using through an Attach, but a node using a certificate with a single Node-ID MAY choose not to send an Attach (see Section 4.2.1, bullet 2) ๐. If a node with a certificate that has multiple Node-IDs tries to route a message other than a Ping or Attach through a node without doing an Attach, the receiving node MUST reject the request with an Error_Forbidden error ๐ซ. The node MUST also support returning responses to a Ping or Attach request from a Joining Node Attaching to its responsible peer ๐.
6.1.3. Opaque ID โจ
If the first entry on the Destination List is an opaque ID (for example, a compressed Via List), the peer MUST replace the entry with the original Via List it stood in for, and then re-examine the Destination List to see which of the three cases in Section 6.1 now applies ๐.
6.2. Symmetric Recursive Routing ๐
This section defines RELOAD's Symmetric Recursive Routing algorithm, which is the default algorithm nodes use to route messages through the overlay ๐ฃ๏ธ. All implementations MUST implement this routing algorithm ๐. An overlay MAY be configured to use other routing algorithms, and those alternatives MAY be picked on a per-message basis. So a node in an overlay that supports Symmetric Recursive Routing and some other algorithm, called XXX, might use Symmetric Recursive Routing some of the time and XXX at other times ๐.
6.2.1. Request Origination ๐
To send a message to a given Node-ID or Resource-ID, a node MUST build an appropriate Destination List ๐. The simplest one is a single entry containing the Node-ID or Resource-ID. The resulting message MUST be forwarded to its destination through the normal overlay routing mechanisms ๐ฐ๏ธ. The node MAY also build a more complicated Destination List for source routing ๐บ๏ธ.
Once the message is built, the node sends it to an adjacent peer. If the first entry on the Destination List is directly connected, the message MUST be routed down that connection. Otherwise, the Topology Plug-in MUST be consulted to work out the right next hop ๐งญ.
Parallel requests for a resource are a common way to boost reliability when there's churn or subversive peers ๐ช. Parallel searches for usage-specified replicas are handled by the usage layer. For example, the usage might store data at multiple Resource-IDs, and the requesting node sends requests to each of them ๐ฌ. A single request MAY also be routed through multiple adjacent peers, even when they're known to be suboptimal, to improve reliability [vulnerabilities-acsac04] ๐ค. Such parallel searches MAY be specified by the Topology Plug-in, in which case it would return multiple next hops, and the request would be routed to all of them ๐.
Messages can get lost in transit through the overlay, so RELOAD has an end-to-end reliability mechanism ๐ชข. When an originating node transmits a request, it MUST set a timer to the current overlay-reliability-timer โฒ๏ธ. If no response has come back when the timer fires, the request MUST be retransmitted with the same transaction identifier ๐. The request MAY be retransmitted up to 4 times, for a total of 5 messages. After the timer for the fifth transmission fires, the message MUST be considered to have failed ๐.
The originating node does both end-to-end and hop-by-hop retransmissions, but the end-by-end retransmission procedure is not followed by intermediate nodes. They follow the hop-by-hop reliability procedure described in Section 6.6.3 ๐งฉ.
The algorithm above can result in multiple requests being delivered to a node ๐ฏ. Receiving nodes MUST generate semantically equivalent responses to retransmissions of the same request (this can be determined by the transaction ID) if the request arrives within the maximum request lifetime (15 seconds) โฑ๏ธ. For some requests (for example, Fetch), this can be done just by processing the request again โ . For other requests (for example, Store), it may be necessary to keep state for the duration of the request lifetime ๐๏ธ.
6.2.2. Response Origination ๐
When a peer sends a response to a request using this routing algorithm, it MUST build the Destination List by reversing the order of the entries on the Via List ๐ช. The result is that the response goes through the same peers the request went through, just in reverse order (symmetric routing), and possibly with extra nodes (loose routing) ๐ซ.
6.3. Message Structure ๐
RELOAD is a message-oriented request/response protocol ๐ฌ. The messages are encoded using binary fields, and all integers are in network byte order ๐ข. The big idea behind the design was to use Type, Length, Value (TLV) fields so things stay extensible ๐งธ. For the parts of a structure that every message needs, though, we just define them in a fixed position. Adding a type and length for those would be unnecessary and would only add bandwidth and new potential interoperability issues ๐ โโ๏ธ.
Each message has three parts, concatenated like this:
+-------------------------+
| Forwarding Header |
+-------------------------+
| Message Contents |
+-------------------------+
| Security Block |
+-------------------------+
Here's what each part is up to ๐:
- Forwarding Header: Every message has a generic header used to forward the message between peers and on to its final destination ๐. This is the only information an intermediate peer (one that isn't the target of a message) needs to look at. Section 6.3.2 describes the format of this part ๐.
- Message Contents: The message being delivered between the peers ๐ฆ. From the forwarding layer's point of view, the contents are opaque, but the higher layers do interpret them ๐. Section 6.3.3 describes the format of this part ๐.
- Security Block: A security block that holds certificates and a digital signature over the "Message Contents" section ๐. This signature can be computed without parsing the message contents, which is so cute ๐ฅฐ. All messages MUST be signed by their originator โ๏ธ. Section 6.3.4 describes the format of this part ๐ง.
6.3.1. Presentation Language ๐
okay so the structures in this doc are written in a C-like syntax based on the presentation language TLS [RFC5246] uses to define its stuff ๐ and it's giving clean. why we love it:
- it's familiar enough that most readers get it fast ๐
- nesting lets you split the high-level message structure from the low-level bits โจ
- it has a super straightforward wire encoding, so you can implement quickly, but you can understand the structures without knowing the encoding ๐ซถ
- you can mechanically compile encoders and decoders ๐ค
there are a few quirks to know about too ๐
- all lengths are denoted in bytes, not objects
- variable-length values are denoted like arrays, with angle brackets
- "select" is how you indicate variant structures
for example, uint16 array<0..2^8-2>; means up to 254 bytes, which is up to 127 values of two bytes (16 bits) each ๐
a repetitive structure member and a variable-length block of data share a notation, but the block always starts with "opaque" and the repetitive one doesn't. so this one is a variable block of data:
opaque data<0..2^32-1>;
and this one is a list of 0, 1, or more instances of the Name element:
Name names<0..2^32-1>;
6.3.1.1. Common Definitions ๐ธ
this section is the intro to the presentation language used all over RELOAD ๐ฆ
an enum is an enumerated type ๐ each possibility's value goes in parentheses, and the max value is a nameless value that tells you how wide the containing integral type is. like, Boolean is true or false:
enum { false(0), true(1), (255) } Boolean;
a boolean is either a 1 or a 0. that max value of 255 means it gets stored as a single byte on the wire โจ
next up is NodeId, which represents a single Node-ID ๐
typedef opaque NodeId[NodeIdLength];
a NodeId is a fixed-length structure, a series of bytes with the most significant byte first. the length is set per overlay and it's within 16-20 bytes (128 to 160 bits). (see Section 11.1 for how NodeIdLength gets set ๐ง) also, the typedef here is an extension to the TLS language, but the meaning should be pretty obvious. and the [ size ] syntax means a fixed-length element that does not include its length in the on-the-wire encoding ๐
ResourceId is next, representing a single Resource-ID ๐
typedef opaque ResourceId<0..2^8-1>;
like a NodeId, a ResourceId is an opaque string of bytes, but unlike NodeIds, ResourceIds are variable length, up to 254 bytes (2040 bits) long. on the wire, each ResourceId gets a single length byte in front of it (so lengths up to 255 bytes are possible) ๐ซถ the < range > syntax is a variable-length element that does include its length in the on-the-wire encoding. the number of bytes used for that length comes from the range: it's the minimum number of bytes that can encode the largest range value. so the 3-byte value "FOO" gets encoded as 03 46 4f 4f ๐
now the more complicated one, IpAddressPort, which represents a network address and can carry either an IPv6 or IPv4 address ๐ฆ
enum { invalidAddressType(0), ipv4_address(1), ipv6_address(2),
(255) } AddressType;
struct {
uint32 addr;
uint16 port;
} IPv4AddrPort;
struct {
uint128 addr;
uint16 port;
} IPv6AddrPort;
struct {
AddressType type;
uint8 length;
select (type) {
case ipv4_address:
IPv4AddrPort v4addr_port;
case ipv6_address:
IPv6AddrPort v6addr_port;
/* This structure can be extended */
};
} IpAddressPort;
the first two fields are the same no matter what kind of address you're holding ๐
type: the type of address (IPv4 or IPv6)length: the length of the rest of the structure
because type and length always sit at the front, an implementation that doesn't understand a new address type X can still parse the IpAddressPort field and then toss it if it isn't needed. that's the iconic part ๐
the rest of the IpAddressPort is either an IPv4AddrPort or an IPv6AddrPort. both just hold an address as an integer plus a 16-bit port. for example, here's the wire representation of the IPv4 address "192.0.2.1" with port "6084" ๐
01 ; type = IPv4
06 ; length = 6
c0 00 02 01 ; address = 192.0.2.1
17 c4 ; port = 6084
okay now the important bit โ ๏ธ unless a structure that uses a select explicitly allows unknown types in the select, any unknown type SHOULD be treated as a parsing error, and the whole message SHOULD be discarded with no response ๐
6.3.2. Forwarding Header ๐ง
the forwarding header is a ForwardingHeader structure, shown below. this is the main event ๐
struct {
uint32 relo_token;
uint32 overlay;
uint16 configuration_sequence;
uint8 version;
uint8 ttl;
uint32 fragment;
uint32 length;
uint64 transaction_id;
uint32 max_response_length;
uint16 via_list_length;
uint16 destination_list_length;
uint16 options_length;
Destination via_list[via_list_length];
Destination destination_list
[destination_list_length];
ForwardingOption options[options_length];
} ForwardingHeader;
here's what each field does ๐
relo_token: the first four bytes say this message is a RELOAD message. this field MUST contain the value0xd2454c4f(the string "RELO" with the high bit of the first byte set) ๐ฅoverlay: the 32-bit checksum/hash of the overlay in use. this MUST be formed by taking the lower 32 bits of the SHA-1 [RFC3174] hash of the overlay name. it lets nodes be in multiple overlays and catches accidental misconfiguration. it is not a security-critical function, so don't panic ๐ซถ the overlay name MUST consist of a sequence of characters that would be allowable as a DNS name. specifically, since it gets used in a DNS lookup, it has to follow the grammar for the domain in Section 2.3.1 of [RFC1035] ๐ธconfiguration_sequence: the sequence number of the configuration file. see Section 6.3.2.1 for details ๐version: the version of the RELOAD protocol in use, times 10. RELOAD version numbers are fixed-point decimal numbers between fixed-point integer between 0.1 and 25.4. this doc describes version 1.0, which is0x0a. (versions used before this RFC was published used version number 0.1 ๐) nodes MUST reject messages with other versions ๐ โโ๏ธttl: an 8-bit field for how many iterations, or hops, a message can go through before it's discarded โณ the TTL (time-to-live) value MUST be decremented by one at every hop along the route, right before transmission. if a received message has a TTL of 0 and it isn't destined for the receiving node, then it MUST NOT be propagated any further, and an Error_TTL_Exceeded error should be generated ๐ญ the initial TTL value SHOULD be 100 and MUST NOT go above 100 unless the overlay configuration defines otherwise. nodes that receive a message with a TTL greater than the current value of initial-ttl (or the default of 100) MUST discard it and send an Error_TTL_Exceeded error ๐ฅfragment: this one handles fragmentation ๐งฉ the high bit (0x80000000) MUST be set, for historical reasons. if the next bit (0x40000000) is set to 1, that means this is the last (or only) fragment. the next six bits (0x20000000 through 0x01000000) are reserved and SHOULD be set to zero. the rest of the field holds the fragment offset; see Section 6.7 for details โจlength: the count in bytes of the message's size, including the header, after any eventual fragmentation ๐transaction_id: a unique 64-bit number that identifies this transaction and lets receivers tell apart transactions that would otherwise look identical ๐ฆ to make IDs likely to be unique, they MUST be randomly generated. responses use the same transaction ID as the request they correspond to. transaction IDs are also used for fragment reassembly, see Section 6.7 for details ๐งmax_response_length: the max size in bytes of a response ๐ requesting nodes use this to avoid receiving (unexpected) huge responses. if this value is non-zero, responding peers MUST check that any response wouldn't exceed it, and if it would, generate an Error_Incompatible_with_Overlay value. this value SHOULD be set to zero for responses ๐via_list_length: the length of the Via List in bytes. heads up, in this field and the next two length fields, we break the usual variable-length convention of putting the length right before the value. the reason is to make it easier for hardware decoding engines to quickly figure out the length of the header โกdestination_list_length: the length of the Destination List in bytes ๐options_length: the length of the header options in bytes ๐via_list: the via_list holds the sequence of destinations the message has passed through. it starts out empty and grows as the message goes through each peer. in stateless cases, the previous hop the message came from gets appended to the Via List, as specified in Section 6.1.2 ๐ธdestination_list: the destination_list holds a sequence of destinations the message should pass through. the message originator builds the Destination List. the first element is where the message goes next ๐ generally the list shrinks as the message goes through each listed peer, though if list compression is used, that might not be true ๐ซถoptions: a series of ForwardingOption entries. see Section 6.3.2.3 ๐
6.3.2.1. Processing Configuration Sequence Numbers
okay bestie, first things first ๐ to even be part of the overlay, a node MUST have a copy of the overlay Configuration Document ๐โจ. so the config can change over time, every version of the Configuration Document MUST contain a sequence number ๐ข, and that number MUST be monotonically increasing mod 65535. since it can wrap around (in principle, ngl), greater than and less than get read with modulo arithmetic, just like TCP ๐ง ๐ธ.
when a destination node gets a request, it MUST check that the configuration_sequence field is equal to its own configuration sequence number ๐. if they don't match, the node MUST generate an error, either Error_Config_Too_Old or Error_Config_Too_New ๐ญ. and if the configuration file in the request is too old, the node MUST generate a ConfigUpdate message to update the requesting node ๐. this is how new Configuration Documents spread quickly through the whole system, iconic ๐.
there's one exception ๐. if the configuration_sequence field is equal to 65535 and the message type is ConfigUpdate, then the message MUST be accepted regardless of the receiving node's configuration sequence number. since 65535 is a special value, peers sending a new configuration when the configuration sequence is currently 65534 MUST set the configuration sequence number to 0 when they send a new configuration ๐ซถ.
6.3.2.2. Destination and Via Lists
the Destination List and Via List are both sequences of Destination values ๐ฆ:
enum { invalidDestinationType(0), node(1), resource(2),
opaque_id_type(3), /* 128-255 not allowed */ (255) }
DestinationType;
select (destination_type) {
case node:
NodeId node_id;
case resource:
ResourceId resource_id;
case opaque_id_type:
opaque opaque_id<0..2^8-1>;
/* This structure may be extended with new types */
} DestinationData;
struct {
DestinationType type;
uint8 length;
DestinationData destination_data;
} Destination;
struct {
uint16 opaque_id; /* Top bit MUST be 1 */
} Destination;
so if the destination structure is a 16-bit integer, then the first bit MUST be set to 1 ๐ฅ. it MUST be treated as if it were a full structure with a DestinationType of opaque_id_type and an opaque_id that was 2 bytes long, with the value of the 16-bit integer. if the destination structure starts with DestinationType instead, then the first bit MUST be set to 0, and the destination structure must use a TLV structure with the following contents ๐ง:
type- The type of the DestinationData Payload Data Unit (PDU). It may be one of "node", "resource", or "opaque_id_type".
length- The length of the destination_data.
destination_data- The destination value itself, which is an encoded DestinationData structure that depends on the value of "type".
the destination structure encodes a Type, Length, Value, and the Length field is the length of the DestinationData values ๐. that's what lets new DestinationTypes get added later. it also lets an implementation that doesn't understand a given DestinationType just skip right over it ๐.
a DestinationData can be one of three types ๐:
node- A Node-ID.
opaque- A compressed list of Node-IDs and an eventual Resource-ID. because one of the peers compressed this value, it's only meaningful to that peer and can't be decoded by other peers, so it's represented as an opaque string ๐ค.
resource- The Resource-ID of the resource which is desired. this type MUST appear only in the final location of a Destination List and MUST NOT appear in a Via List. it's meaningless to try to route through a resource ๐ โโ๏ธ.
one possible encoding of the 16-bit integer version as an opaque identifier is to encode an index into a Connection Table ๐. to avoid misrouting responses in case a response is delayed and the Connection Table entry has changed, the identifier SHOULD be split between an index and a generation counter for that index. when a Node first joins the overlay, the generation counters SHOULD be initialized to random values ๐ฒ. an implementation MAY use 12 bits for the Connection Table index and 3 bits for the generation counter. (note that this does not suggest a 4096-entry Connection Table for every peer, only the ability to encode for a larger Connection Table ๐.) when a Connection Table slot is used for a new connection, the generation counter is incremented (with wrapping). Connection Table slots are used on a rotating basis to maximize the time interval between uses of the same slot for different connections โจ.
when routing a message to an entry in the Destination List that encodes a Connection Table entry, the peer MUST confirm that the generation counter matches the current generation counter of that index before forwarding the message. if it doesn't match, the message MUST be silently dropped ๐. no drama, just gone.
6.3.2.3. Forwarding Option
the Forwarding header can be extended with forwarding header options, which are a series of ForwardingOption structures ๐ธ:
enum { invalidForwardingOptionType(0), (255) }
ForwardingOptionType;
struct {
ForwardingOptionType type;
uint8 flags;
uint16 length;
select (type) {
/* This type may be extended */
};
} ForwardingOption;
each ForwardingOption has these values:
type- The type of the option. This structure allows for unknown option types.
flags- Three flags are defined: FORWARD_CRITICAL(0x01), DESTINATION_CRITICAL(0x02), and RESPONSE_COPY(0x04). these flags MUST NOT be set in a response. if the FORWARD_CRITICAL flag is set, any peer that would forward the message but doesn't understand this option MUST reject the request with an
Error_Unsupported_Forwarding_Optionerror response. if the DESTINATION_CRITICAL flag is set, any node that generates a response to the message but doesn't understand the forwarding option MUST reject the request with anError_Unsupported_Forwarding_Optionerror response. if the RESPONSE_COPY flag is set, any node generating a response MUST copy the option from the request to the response, except that the RESPONSE_COPY, FORWARD_CRITICAL, and DESTINATION_CRITICAL flags MUST be cleared ๐ฅ.
- Three flags are defined: FORWARD_CRITICAL(0x01), DESTINATION_CRITICAL(0x02), and RESPONSE_COPY(0x04). these flags MUST NOT be set in a response. if the FORWARD_CRITICAL flag is set, any peer that would forward the message but doesn't understand this option MUST reject the request with an
length- The length of the rest of the structure. a 0 length may be reasonable if the mere presence of the option is meaningful and no value is required ๐ซง.
option- The option value.
6.3.3. Message Contents Format
the second major part of a RELOAD message is the contents part, which is defined by MessageContents ๐ฆ:
enum { invalidMessageExtensionType(0),
(2^16-1) } MessageExtensionType;
struct {
MessageExtensionType type;
Boolean critical;
opaque extension_contents<0..2^32-1>;
} MessageExtension;
struct {
uint16 message_code;
opaque message_body<0..2^32-1>;
MessageExtension extensions<0..2^32-1>;
} MessageContents;
here's what each part of this structure does ๐ง:
message_code- This indicates the message that is being sent. The code space is broken up as follows:
- 0x0: Invalid Message Code. This code will never be assigned.
- 0x1 .. 0x7FFF: Requests and responses. These code points are always paired, with requests being an odd value and the corresponding response being the request code plus 1. Thus, "probe_request" (the Probe request) has the value 1 and "probe_answer" (the Probe response) has the value 2.
- 0x8000 .. 0xFFFE: Reserved.
- 0xFFFF: Error.
- The message codes are defined in Section 14.8.
- This indicates the message that is being sent. The code space is broken up as follows:
message_body- The message body itself, represented as a variable-length string of bytes. The bytes themselves depend on the code value. See the sections describing the various RELOAD methods (Join, Update, Attach, Store, Fetch, etc.) for the definitions of the payload contents.
extensions- Extensions to the message. Currently no extensions are defined, but new extensions can be defined by the process described in Section 14.14.
all extensions have the following form โจ:
type- The extension type.
critical- Whether this extension needs to be understood in order to process the message. if critical = True and the recipient doesn't understand the message, it MUST generate an
Error_Unknown_Extensionerror. if critical = False, the recipient MAY choose to process the message even if it doesn't understand the extension ๐ฅน.
- Whether this extension needs to be understood in order to process the message. if critical = True and the recipient doesn't understand the message, it MUST generate an
extension_contents- The contents of the extension (which are extension dependent).
the subsections 6.4.2, 6.5, and 7 describe structures that get inserted inside the message_body member, depending on the value of the message_code value ๐ง . for example, a message_code value of join_req means that the structure named JoinReq is inserted inside message_body. this document doesn't contain a mapping between message_code values and structure names, since the conversion between the two is obvious ๐ .
similarly, this document uses the name of the structure without the "Req" or "Ans" suffix to mean the execution of a transaction consisting of the matching request and answer ๐ฆ. so when the text says "perform an Attach", it must be understood as performing a transaction composed of an AttachReq and an AttachAns. ๐ซถ
6.3.3.1. Response Codes and Response Errors ๐
okay so when a node is processing a request, it MUST return its status in the message_code field ๐
. if the request worked, the message code MUST be set to the response code that matches the request (i.e., the next code up) ๐. the response payload then follows whatever the request and response descriptions say ๐ฆ.
if the request failed, the message code MUST be set to 0xffff (error) and the payload MUST be an error_response message, shown below ๐ญ.
when the message code is 0xFFFF, the payload MUST be an ErrorResponse:
public struct {
uint16 error_code;
opaque error_info<0..2^16-1>;
} ErrorResponse;
here's what's inside that struct ๐ง:
error_code: a numeric error code for whatever went wrong ๐.error_info: an optional arbitrary byte string ๐ธ. unless it says otherwise, this is a UTF-8 text string that gives more detail about what went wrong โจ. developers are encouraged to put enough diagnostic info inerror_infoto actually be useful ๐ซถ. the exact text and any language or encoding stuff is up to the implementation ๐.
these are the error code values that are defined. the numeric values live in Section 14.9 ๐ข.
Error_Forbidden: the requesting node doesn't have permission to make this request ๐.Error_Not_Found: the resource or node can't be found or doesn't exist ๐ป.Error_Request_Timeout: no response to the request arrived in a reasonable amount of time โฐ. the requesting node MAY resend the request later ๐.Error_Data_Too_Old: a store can't be completed because the storage_time is older than the existing value ๐ฅ.Error_Data_Too_Large: a store can't be completed because the requested object is bigger than the size limits for that Kind ๐ฆ.Error_Generation_Counter_Too_Low: a store can't be completed because the generation counter is lower than the existing value ๐.Error_Incompatible_with_Overlay: the peer getting the request is using a different overlay, overlay algorithm, hash algorithm, or some other parameter that doesn't match the overlay config ๐ซ.Error_Unsupported_Forwarding_Option: a node got a request with a forwarding option flagged as critical, but it doesn't support that option ๐ . see Section 6.3.2.3 ๐.Error_TTL_Exceeded: a peer got a request where the TTL was decremented to zero โ. see Section 6.3.2 ๐.Error_Message_Too_Large: a peer got a request that was too large ๐. see Section 6.6 ๐.Error_Response_Too_Large: a node would have generated a response that's too large for the max_response_length field ๐ซ .Error_Config_Too_Old: a destination node got a request with a configuration sequence that's too old ๐ฐ๏ธ. see Section 6.3.2.1 ๐ซ.Error_Config_Too_New: a destination node got a request with a configuration sequence that's too new ๐. see Section 6.3.2.1 ๐ซ.Error_Unknown_Kind: a destination peer got a request with a Kind-ID it doesn't know ๐คทโโ๏ธ. see Section 7.4.1.2 ๐.Error_In_Progress: an Attach to this peer is already happening ๐โโ๏ธ. see Section 6.5.1.2 โณ.Error_Unknown_Extension: a destination node got a request with an extension it doesn't recognize ๐งฉ.Error_Invalid_Message: something about the message is invalid, but it doesn't fit any of the other error codes ๐ต. when this one gets sent, implementations SHOULD include a meaningful description in error_info to help with debugging ๐ ๏ธ.Error_Exp_A: this one is for experimentation only ๐งช. it isn't meant for any vendor-specific use, and it MUST NOT be used in operational deployments โ ๏ธ.Error_Exp_B: this one is for experimentation only ๐งช. it isn't meant for any vendor-specific use, and it MUST NOT be used in operational deployments โ ๏ธ.
6.3.4. Security Block ๐
the third part of a RELOAD message is the security block ๐ก๏ธ. it's represented by a SecurityBlock structure:
struct {
CertificateType type; // From RFC 6091
opaque certificate<0..2^16-1>;
} GenericCertificate;
struct {
GenericCertificate certificates<0..2^16-1>;
Signature signature;
} SecurityBlock;
here's what's in there ๐ง:
certificates: a bucket of certificates ๐ชฃ.signature: a signature โ๏ธ.
the certificates bucket SHOULD contain all the certificates needed to verify every signature in both the message and the internal message objects, except for the ones in a root-cert element of the current configuration file ๐. this is the only place in the message that holds certificates, so only one copy of each certificate gets sent ๐. in systems with another way of distributing certificates, some certificates MAY be left out ๐ค. but unless an alternative mechanism for immediately generating certificates, such as shared secret security (Section 13.4), is being used, implementers MUST include all referenced certificates ๐ .
NOTE TO IMPLEMENTERS: this requirement means a peer storing data is obligated to keep the certificates for the data it holds ๐ซก.
each certificate is a GenericCertificate structure with these fields ๐:
type: the type of the certificate, as defined in [RFC6091] ๐ท๏ธ. only X.509 certificates are defined in this document ๐.certificate: the encoded version of the certificate ๐ค. for X.509 certificates, that's the Distinguished Encoding Rules (DER) form ๐งพ.
the signature is computed over the payload and parts of the forwarding header ๐๏ธ. for a Store, the payload MUST contain an additional signature computed as described in Section 7.1 ๐๏ธ. all signatures MUST be formatted using the Signature element ๐. this element also gets used in other places where signatures are needed โจ. the input structure to the signature computation MAY change depending on the data element being signed ๐ฆ.
enum { invalidSignerIdentityType(0),
cert_hash(1), cert_hash_node_id(2),
none(3)
(255) } SignerIdentityType;
struct {
select (identity_type) {
case cert_hash;
HashAlgorithm hash_alg; // From TLS
opaque certificate_hash<0..2^8-1>;
case cert_hash_node_id:
HashAlgorithm hash_alg; // From TLS
opaque certificate_node_id_hash<0..2^8-1>;
case none:
/* empty */
/* This structure may be extended with new types if necessary*/
};
} SignerIdentityValue;
struct {
SignerIdentityType identity_type;
uint16 length;
SignerIdentityValue identity[SignerIdentity.length];
} SignerIdentity;
struct {
SignatureAndHashAlgorithm algorithm; // From TLS
SignerIdentity identity;
opaque signature_value<0..2^16-1>;
} Signature;
the Signature construct has these values ๐:
algorithm: the signature algorithm in use ๐งฎ. the definitions live in the IANA TLS SignatureAlgorithm and HashAlgorithm registries ๐. all implementations MUST support RSASSA-PKCS1-v1_5 [RFC3447] signatures with SHA-256 hashes [RFC6234] ๐ซถ.identity: the identity used to form the signature, as defined in the two paragraphs right after this list ๐ชช.signature_value: the value of the signature ๐ซ.
note that storage operations allow for special values of algorithm and identity ๐. check the Store Request definition (Section 7.4.1.1) and the Fetch Response definition (Section 7.4.2.2) ๐.
there are two allowed identity formats ๐ญ: one for a certificate with only one Node-ID, and one for a certificate with multiple Node-IDs. in the first case, the cert_hash type MUST be used ๐งท. the hash_alg field says which algorithm made the hash ๐ง. the certificate_hash holds the hash of the certificate object (i.e., the DER-encoded certificate) ๐งพ.
in the second case, the cert_hash_node_id type MUST be used ๐. the hash_alg works the same as in cert_hash, but the cert_hash_node_id is computed over the NodeId used to sign concatenated with the certificate; i.e., H(NodeId || certificate) ๐ง . the NodeId is written without any framing or length fields, just as raw bytes ๐. this is safe because NodeIds are a fixed length for a given overlay ๐.
for signatures over messages, the input to the signature is computed over:
overlay || transaction_id || MessageContents || SignerIdentity
where overlay and transaction_id come from the forwarding header, and || means concatenation ๐.
the input for signatures over data values is different and is described in Section 7.1 ๐.
All RELOAD messages MUST be signed ๐๏ธ. intermediate nodes don't verify signatures ๐ โโ๏ธ. when a message comes in (and after fragment reassembly, if that's needed), the destination node MUST verify the signature and the authorizing certificate ๐ต๏ธโโ๏ธ. if the signature fails, the implementation SHOULD simply drop the message and MUST NOT process it ๐๏ธ. this check gives a minimal level of assurance that the sending node is a valid part of the overlay, and it gives cryptographic authentication of the sending node ๐. on top of that, the requesting node MUST check responses like this ๐:
- the response to a message sent to a Node-ID MUST have been sent by that Node-ID, unless the response was sent to the wildcard Node-ID ๐ฏ.
- the response to a message sent to a Resource-ID MUST have been sent by a Node-ID that's at least as close to the target Resource-ID as any node in the requesting node's Neighbor Table ๐.
the second condition is a primitive check for responses from wildly wrong nodes ๐, but it isn't a complete check ๐ซค. during periods of churn, the requesting node might find a closer neighbor while the request is still outstanding ๐ช๏ธ. that'll cause the response to get rejected and the request to get retransmitted ๐.
in addition, some methods (especially Store) have extra authentication requirements, which are described in the sections covering those methods ๐งพ.
6.4. Overlay Topology ๐บ๏ธ
as we've talked about, RELOAD defines a default overlay topology (CHORD-RELOAD), but it allows other topologies through Topology Plug-ins ๐งฉ. this section describes the requirements for new Topology Plug-ins and the methods RELOAD provides for overlay topology maintenance ๐ ๏ธโจ.
6.4.1. Topology Plug-in Requirements โจ
okay so if you're cooking up a brand new overlay algorithm, bestie, at least these things MUST be described ๐ no skipping!!
- Joining procedures, including the contents of the Join message.
- Stabilization procedures, including the contents of the Update message, the frequency of topology probes and keepalives, and the mechanism used to detect when peers have disconnected.
- Exit procedures, including the contents of the Leave message.
- The length of the Resource-IDs and for DHTs the hash algorithm to compute the hash of an identifier.
- The procedures that peers use to route messages.
- The replication strategy used to ensure data redundancy.
All overlay algorithms MUST specify maintenance procedures that send Updates to clients and peers with established connections to the peer responsible for a particular ID whenever that responsibility changes ๐ฆ tracking that is literally so hard, so the vibe is that overlay algorithms MAY simply say an Update goes to every member of the Connection Table whenever the range of IDs a peer is responsible for changes ๐ซถ
6.4.2. Methods and Types for Use by Topology Plug-ins ๐
this section is all about the methods Topology Plug-ins use to join, leave, and maintain the overlay ๐ง
6.4.2.1. Join
okay so a brand new peer (which already has credentials) uses the JoinReq message to join the overlay ๐ธ the JoinReq gets sent to the responsible peer, and which route it takes depends on the routing mechanism in the Topology Plug-in. basically it tells the responsible peer "hey, I'm taking over some of the overlay and I need to sync my state" ๐ฅ
struct {
NodeId joining_peer_id;
opaque overlay_specific_data<0..2^16-1>;
} JoinReq;
the minimal JoinReq only has the Node-ID the sender wants to assume โจ overlay algorithms MAY specify other data to show up in this request. receivers of the JoinReq MUST verify that the joining_peer_id field matches the Node-ID used to sign the message, and if it doesn't, the message MUST be rejected with an Error_Forbidden error ๐
joins can only happen between nodes that are directly adjacent, so receiving peers MUST verify that any JoinReq they get comes in over a transport channel bound to the Node-ID being assumed by the Joining Node ๐ implementations MUST use DTLS anti-replay mechanisms, which is how they stop replay attacks. iconic behavior ๐
if the request succeeds, the responding peer sends back a JoinAns message, which looks like this:
struct {
opaque overlay_specific_data<0..2^16-1>;
} JoinAns;
if the request succeeds, the responding peer MUST follow up by running the right sequence of Stores and Updates to transfer the appropriate section of the overlay space to the Joining Node ๐ overlay algorithms MAY also define data to show up in the response payload for extra info.
Joining Nodes MUST verify that the signature on the JoinAns message matches the expected target (aka the adjacency they're joining over). if it doesn't match, they MUST discard the message ๐ฅ
in general, nodes that can't form connections SHOULD report an error to the user ๐ however, implementations MUST provide some mechanism so nodes can figure out whether they're potentially the first node and can take responsibility for the overlay. (the whole point is to stop ordinary nodes from all trying to become responsible for the entire overlay during a partition ๐ญ) this spec doesn't mandate any particular mechanism, but a configuration flag or setting seems appropriate โจ
6.4.2.2. Leave
the LeaveReq message is how a node says it's exiting the overlay ๐ a node SHOULD send this message to each peer it's directly connected to before it leaves.
struct {
NodeId leaving_peer_id;
opaque overlay_specific_data<0..2^16-1>;
} LeaveReq;
LeaveReq only contains the Node-ID of the leaving peer ๐ overlay algorithms MAY specify other data to show up in this request. receivers of the LeaveReq MUST verify that the leaving_peer_id field matches the Node-ID used to sign the message, and if not, the message MUST be rejected with an Error_Forbidden error ๐ โโ๏ธ
leaves can only be executed between directly adjacent nodes, so receiving peers MUST verify that any LeaveReq they receive arrives over a transport channel bound to the Node-ID being assumed by the leaving peer. this also prevents replay attacks, as long as DTLS anti-replay is in use ๐
upon receiving a Leave request, a peer MUST update its own Routing Table and send the appropriate Store/Update sequences to re-stabilize the overlay ๐
LeaveAns is an empty message ๐ซง
6.4.2.3. Update
Update is the main overlay-specific maintenance message, and it's giving essential ๐ the sender uses it to tell the recipient its view of the current overlay state (aka its routing state), and the recipient decides what to do about the change. generally, peers send Update messages to all their adjacencies whenever they notice a topology shift โจ
when a peer gets an Attach request with the send_update flag set to True (see Section 6.4.2.4.1), it MUST send an Update message back to the sender of that Attach request after the matching ICE check and TLS connection are done. the sender of the Attach request might not have joined the overlay yet, which is a whole vibe ๐ฆ
when a peer notices through an Update that it's no longer responsible for a data value it's storing, it MUST attempt to Store a copy to the correct node, unless it knows the newly responsible node already has a copy. this stops data loss during big topology shifts, like when partitioned overlays merge ๐ซถ
the contents of the UpdateReq message are completely overlay specific ๐ธ the UpdateAns response is expected to be either success or an error.
6.4.2.4. RouteQuery
the RouteQuery request lets the sender ask a peer where it would route a message aimed at a given destination ๐ so basically, a RouteQuery for destination X asks for the Node-ID of the node the receiving peer would route to next in order to reach X. a RouteQuery can also ask the receiving peer to kick off an Update request to transfer its Routing Table ๐
one big use of RouteQuery is iterative routing ๐ง the sender picks one of the peers in its Routing Table and sends it a RouteQuery with the destination field set to the Node-ID or Resource-ID it wants to route to. the receiving peer replies with info about the peers the request would be routed to. the sending peer MAY then use the Attach method to attach to those peers and repeat the RouteQuery. eventually, the sender hears back from a peer that's closest to the identifier in the destination field, as decided by the Topology Plug-in. at that point, the sender can message that peer directly ๐
6.4.2.4.1. Request Definition
a RouteQueryReq message says which peer or resource the requesting node is interested in. it also has a "send_update" option that lets the requester ask for a full copy of the other peer's Routing Table โจ
struct {
Boolean send_update;
Destination destination;
opaque overlay_specific_data<0..2^16-1>;
} RouteQueryReq;
the contents of the RouteQueryReq message go like this:
send_update: a single byte. It may be set to True to say the requester wants the responder to start an Update request right away. Otherwise, this value MUST be set to False. ๐destination: the destination the requester is interested in. It can be any valid destination object, including a Node-ID, opaque ID, or Resource-ID.- Note: if implementations are using opaque IDs for privacy purposes, answering RouteQueryReqs for opaque IDs will let the requester translate an opaque ID. Implementations MAY wish to consider limiting the use of RouteQuery for opaque IDs in such cases. ๐
overlay_specific_data: other data as appropriate for the overlay ๐
6.4.2.4.2. Response Definition
a successful RouteQueryReq gets a RouteQueryAns message back ๐ซถ this message is completely overlay specific.
6.4.2.5. Probe
Probe is the basic "exploration" service ๐ it lets a node figure out which resources another node is responsible for. a probe can be addressed to a specific Node-ID, or to whichever peer controls a given location (using a Resource-ID). either way, the target node answers with a simple response holding some status info ๐
6.4.2.5.1. Request Definition
the ProbeReq message holds a list (possibly empty) of the status info pieces the requester wants the responder to send back ๐ธ
enum { invalidProbeInformationType(0), responsible_set(1),
num_resources(2), uptime(3), (255) }
ProbeInformationType;
struct {
ProbeInformationType requested_info<0..2^8-1>;
} ProbeReq;
the currently defined ProbeInformationType values are:
responsible_set: tells the peer to respond with the fraction of the overlay the responding peer is responsible for.num_resources: tells the peer to respond with the number of resources it's currently storing. Multiple values under the same Resource-ID are only counted once ๐งฎuptime: tells the peer to respond with how long it's been up, in seconds โฑ๏ธ
6.4.2.5.2. Response Definition
a successful ProbeAns response contains the information elements the requester asked for โจ
struct {
select (type) {
case responsible_set:
uint32 responsible_ppb;
case num_resources:
uint32 num_resources;
case uptime:
uint32 uptime;
/* This type may be extended */
};
} ProbeInformationData;
struct {
ProbeInformationType type;
uint8 length;
ProbeInformationData value;
} ProbeInformation;
struct {
ProbeInformation probe_info<0..2^16-1>;
} ProbeAns;
a ProbeAns message holds a sequence of ProbeInformation structures. each one has a "length" telling you how long its value field is. this structure allows for unknown option types, which is so smart of them ๐ง
each of the current Probe information types is a 32-bit unsigned integer. for type "responsible_ppb", it's the fraction of the overlay the peer is responsible for, in parts per billion. for type "num_resources", it's the number of resources the peer is storing. for type "uptime", it's the number of seconds the peer has been up ๐ฆ
the responding peer SHOULD include any values the requesting node asked for and that it recognizes ๐ they SHOULD come back in the requested order. any other values MUST NOT be returned ๐ โโ๏ธ
6.5. Forwarding and Link Management Layer โจ
okay bestie, every node keeps connections open to a bunch of other nodes, and the Topology Plug-in ๐ฆ decides which ones. This section is all about the methods RELOAD uses to form and maintain those connections in the overlay. There are three of them ๐ :
Attach: used to form RELOAD connections between nodes using ICE for NAT traversal ๐ธ. When node A wants to connect to node B, it sends an Attach message to node B through the overlay. The Attach contains A's ICE parameters. B responds with its ICE parameters, and the two nodes perform ICE to form connection. Attach also lets two nodes connect via No-ICE instead of full ICE ๐ซถ.AppAttach: used to form application-layer connections between nodes โจ.Ping: a simple request/response used to verify connectivity of the target peer ๐.
6.5.1. Attach ๐
A node sends an Attach request when it wants a direct Overlay Link connection to another node so it can send RELOAD messages. A client that can connect directly doesn't need to send an Attach, per the second bullet of Section 4.2.1 ๐.
As described in Section 6.1, an Attach can be routed to either a Node-ID or a Resource-ID. An Attach routed to a specific Node-ID fails if that node isn't reached ๐. An Attach routed to a Resource-ID connects to whichever peer is currently responsible for that Resource-ID. That's super handy for a direct link to the responsible peer when you've got frequent or large resource updates ๐.
An Attach by itself does not update the Routing Table of either node. That's Updates' job ๐. If node A has Attached to node B but hasn't received any Updates from B, it MAY route messages directly addressed to B through that channel. It MUST NOT route messages through B to other peers via that channel. Main character rule, no exceptions ๐ซ.
Attaching is kept separate from becoming a peer (that's Join and Update). This stops half-open states where a node has started forming connections but isn't really ready to act as a peer ๐ง. So clients (unlike peers) can just Attach without sending Join or Update โจ.
6.5.1.1. Request Definition ๐
An Attach request message carries the requesting node's ICE connection parameters, formatted into a binary structure ๐.
enum { invalidOverlayLinkType(0), DTLS-UDP-SR(1),
DTLS-UDP-SR-NO-ICE(3), TLS-TCP-FH-NO-ICE(4),
(255) } OverlayLinkType;
enum { invalidCandType(0),
host(1), srflx(2), /* RESERVED(3), */ relay(4),
(255) } CandType;
struct {
opaque name<0..2^16-1>;
opaque value<0..2^16-1>;
} IceExtension;
struct {
IpAddressPort addr_port;
OverlayLinkType overlay_link;
opaque foundation<0..255>;
uint32 priority;
CandType type;
select (type) {
case host:
; /* Empty */
case srflx:
case relay:
IpAddressPort rel_addr_port;
};
IceExtension extensions<0..2^16-1>;
} IceCandidate;
struct {
opaque ufrag<0..2^8-1>;
opaque password<0..2^8-1>;
opaque role<0..2^8-1>;
IceCandidate candidates<0..2^16-1>;
Boolean send_update;
} AttachReqAns;
The values contained in AttachReqAns are:
ufrag: The username fragment (from ICE) ๐ง.password: The ICE password ๐.role: An active/passive/actpass attribute from RFC 4145 [RFC4145]. This value MUST be "passive" for the offerer (the peer sending the Attach request) and "active" for the answerer (the peer sending the Attach response) ๐ญ.candidates: One or more ICE candidate values, as described below ๐.send_update: Has the same meaning as the send_update field in RouteQueryReq ๐.
Each ICE candidate is an IceCandidate structure. It's a direct translation of the info from the ICE string structures, except for the component ID. There's only one component, so it's always 1 and gets left out of the structure ๐. The rest of the values work like this:
addr_port: Corresponds to the ICE connection-address and port productions ๐.overlay_link: Corresponds to the ICE transport production. Overlay Link protocols used with No-ICE MUST specify "No-ICE" in their description. Future overlay link values can be added by defining new OverlayLinkType values in the IANA registry as described in Section 14.10. Future extensions to the encapsulation or framing that provide backward compatibility with the previously specified encapsulation or framing values MUST use the same OverlayLinkType value that was previously defined. OverlayLinkType protocols are defined in Section 6.6 ๐งฉ.
A single AttachReqAns MUST NOT include both candidates whose OverlayLinkType protocols use ICE (the default) and candidates that specify "No-ICE". Don't mix and match, besties ๐ โโ๏ธ.
foundation: Corresponds to the ICE foundation production ๐งฑ.priority: Corresponds to the ICE priority production โญ.type: Corresponds to the ICE cand-type production ๐ฆ.rel_addr_port: Corresponds to the ICE rel-addr and rel-port productions. It's present only for the types "relay", "prfix", and "srflx" ๐.extensions: ICE extensions. The name and value fields correspond to binary translations of the equivalent fields in the ICE extensions ๐.
These values should be generated using the procedures described in Section 6.5.1.3 ๐ .
6.5.1.2. Response Definition ๐ธ
If a peer receives an Attach request, it MUST determine how to process the request as follows:
- If the peer has not initiated an Attach request to the originating peer of this Attach request, it MUST process this request and SHOULD generate its own response with an AttachReqAns. It should then begin ICE checks โ .
- If the peer has already sent an Attach request to and received the response from the originating peer of this Attach request and, as a result, an ICE check and TLS connection are in progress, then it SHOULD generate an Error_In_Progress error instead of an AttachReqAns ๐ง.
- If the peer has already sent an Attach request to but not yet received the response from the originating peer of this Attach request, it SHOULD apply the following tie-breaker heuristic to determine how to handle this Attach request and the incomplete Attach request it has sent out โ๏ธ:
- If the peer's own Node-ID is smaller when compared as big-endian unsigned integers, it MUST cancel retransmission of its own incomplete Attach request. It MUST then process this Attach request, generate an AttachReqAns response, and proceed with the corresponding ICE check ๐โโ๏ธ.
- If the peer's own Node-ID is larger when compared as big-endian unsigned integers, it MUST generate an Error_In_Progress error to this Attach request, and then proceed to wait for and complete the Attach and the corresponding ICE check it has originated ๐ซ .
- If the peer is overloaded or detects some other kind of error, it MAY generate an error instead of an AttachReqAns ๐ฎโ๐จ.
When a peer receives an Attach response, it SHOULD parse the response and begin its own ICE checks ๐ฅฐ.
6.5.1.3. Using ICE with RELOAD ๐ง
This section describes the profile of ICE that is used with RELOAD. RELOAD implementations MUST implement full ICE ๐ฏ.
In ICE, as defined by [RFC5245], the Session Description Protocol (SDP) is used to carry the ICE parameters. In RELOAD, a binary encoding in the Attach method does that job instead. This encoding is more restricted than the SDP encoding because the RELOAD environment is simpler ๐ท:
- Only a single media stream is supported ๐ต.
- In this case, the "stream" refers not to RTP or other types of media, but rather to a connection for RELOAD itself or other application-layer protocols, such as SIP ๐.
- RELOAD allows only for a single offer/answer exchange. Unlike the usage of ICE within SIP, there is never a need to send a subsequent offer to update the default candidates to match the ones selected by ICE ๐ โโ๏ธ.
An agent follows the ICE specification as described in [RFC5245], with the changes and additional procedures described in the subsections below ๐.
6.5.1.4. Collecting STUN Servers ๐
ICE relies on the node having one or more Session Traversal Utilities for NAT (STUN) servers to use. In conventional ICE, nodes are assumed to be configured with one or more STUN servers through some out-of-band mechanism. This is still possible in RELOAD, but RELOAD also learns STUN servers as it connects to other peers ๐.
A peer on a well-provisioned wide-area overlay will be configured with one or more bootstrap nodes. These nodes make an initial list of STUN servers. However, as the peer forms connections with additional peers, it builds up more peers that it can use as STUN servers ๐ฑ.
Because complicated NAT topologies are possible, a peer may need more than one STUN server. Specifically, a peer that is behind a single NAT will typically observe only two IP addresses in its STUN checks: its local address and its server reflexive address from a STUN server outside its NAT. However, if more NATs are involved, a peer may learn additional server reflexive addresses (which vary based on where in the topology the STUN server is). To maximize the chance of achieving a direct connection, a peer SHOULD group other peers by the peer-reflexive addresses it discovers through them. It SHOULD then select one peer from each group to use as a STUN server for future connections ๐งญ.
Only peers to which the peer currently has connections may be used. If the connection to that host is lost, it MUST be removed from the list of STUN servers, and a new server from the same group MUST be selected unless there are no others servers in the group, in which case some other peer MAY be used ๐ซถ.
6.5.1.5. Gathering Candidates ๐
Okay so when a node wants to set up a connection for RELOAD signaling or application signaling, it follows the candidate gathering process from Section 4 of ICE [RFC5245] ๐ง. RELOAD only uses a single component, so gathering for these "streams" only needs one component ๐. If a node hasn't found a TURN server yet, its agent just won't include a relayed candidate. Simple โจ
ICE assumes that an agent already knows about its TURN and STUN servers, or has some way of finding out ๐. RELOAD helps with this by letting an agent learn about them by querying the overlay, as described in Sections 6.5.1.4 and 9 ๐ซถ
The default candidate selection from Section 4.1.4 of ICE gets ignored ๐ โโ๏ธ Defaults are not signaled or used in RELOAD, so don't even think about them bestie ๐
There's also an alternative to the full ICE that the Attach request supports, and it's called No-ICE ๐ฆ You do this by providing candidates with "No-ICE" Overlay Link protocols. The overlay's configuration tells you whether these Overlay Link protocols can be used. An overlay MUST be either all ICE or all No-ICE, no mixing ๐ญ
No-ICE won't work in every scenario where ICE would work. But in some cases, especially ones with no NATs or firewalls, it totally works ๐ธ
6.5.1.6. Prioritizing Candidates โญ
Okay so more protocols for ICE are expected to get standardized, including TCP [RFC6544], plus things like the Stream Control Transmission Protocol (SCTP) [RFC4960] and the Datagram Congestion Control Protocol (DCCP) [RFC4340]. UDP encapsulations for SCTP and DCCP would give RELOAD even more Overlay Link protocols to pick from ๐ง
When more protocols are available, this prioritization is RECOMMENDED ๐
- Highest priority goes to protocols that offer well-understood congestion and flow control without head-of-line blocking. Examples are SCTP without message ordering, DCCP, and those protocols encapsulated using UDP ๐
- Second highest priority goes to protocols that offer well-understood congestion and flow control but still have head-of-line blocking, like TCP ๐
- Lowest priority goes to protocols encapsulated over UDP that don't implement well-established congestion control algorithms. The DTLS/UDP with Simple Reliability (SR) overlay link protocol is an example of this one ๐
Head-of-line blocking is a total vibe killer in an Overlay Link protocol ๐ The reason is that the messages on a RELOAD link are independent, not stream-oriented. So if message N on a link gets lost, holding back message N+1 on that same link until N is successfully retransmitted does nothing except add latency to the transaction for N+1, even though they have nothing to do with each other ๐ญ Modern TCP implementations are high quality, performant, and available, which makes them super attractive. But their performance as Overlay Link protocols isn't optimal, sadly ๐ฅ
Note that none of the protocols defined in this document meets these conditions. It's expected that new Overlay Link protocols defined in the future will fill this gap โจ
6.5.1.7. Encoding the Attach Message ๐
Section 4.3 of ICE describes how to encode the SDP for conveying RELOAD candidates. But RELOAD doesn't actually encode an SDP message ๐ โโ๏ธ Instead, the candidate information (IP address, port, transport protocol, priority, foundation, type, and related address) gets carried inside the attributes of the Attach request or its response. The username fragment and password ride along in the Attach message or its response too. Section 6.5.1 has the detailed attribute encoding for Attach ๐ The Attach request and its response don't contain any default candidates or the ice-lite attribute, since RELOAD doesn't use those ICE features.
Here's the big idea: the Attach request has the candidate information and short term credentials, so it counts as an offer for a single media stream. It's just encoded in a format that isn't SDP, but it's otherwise a valid offer for following the ICE specification ๐ง The Attach response works the same way, as a valid answer ๐ซถ
6.5.1.8. Verifying ICE Support ๐
An agent MUST skip the verification procedures in Sections 5.1 and 6.1 of ICE. Since RELOAD requires full ICE from all agents, this check isn't needed ๐
6.5.1.9. Role Determination ๐
The controlling and controlled roles from Section 5.2 of ICE still get used with RELOAD ๐ But the offerer (the entity sending the Attach request) is always controlling, and the answerer (the entity sending the Attach response) is always controlled. The connectivity checks MUST still contain the ICE-CONTROLLED and ICE-CONTROLLING attributes, even though the role reversal they're defined for will never be needed in RELOAD ๐ This keeps one common codebase between ICE for RELOAD and ICE for SDP, which is honestly so smart ๐ง
6.5.1.10. Full ICE ๐ฆ
When the overlay uses ICE, connectivity checks and nominations work just like regular ICE ๐
6.5.1.10.1. Connectivity Checks โ
Forming check lists from Section 5.7 of ICE, scheduling checks in Section 5.8, and checking connectivity in Section 7 all get used with RELOAD without any changes ๐ซถ
6.5.1.10.2. Concluding ICE ๐
The procedures in Section 8 of ICE get followed to conclude ICE, with a couple of exceptions:
- The controlling agent MUST NOT attempt to send an updated offer once the state of its single media stream reaches Completed ๐ โโ๏ธ
- Once the state of ICE reaches Completed, the agent can immediately free all unused candidates ๐งน This is because RELOAD doesn't have the concept of forking, so the three-second delay in Section 8.3 of ICE doesn't apply. No waiting around, bestie โฉ
6.5.1.10.3. Media Keepalives ๐
STUN MUST be utilized for the keepalives described in Section 10 of ICE ๐ฅ
6.5.1.11. No-ICE ๐ธ
No-ICE gets selected when either side has provided "no ICE" Overlay Link candidates. STUN isn't used for connectivity checks with No-ICE. Instead, the DTLS or TLS handshake (or a similar security layer for future overlay link protocols) forms the connectivity check ๐ The certificate exchanged during the TLS or DTLS handshake MUST match the node which sent the AttachReqAns. If it doesn't match, the connection MUST be closed ๐ซ
No cap, this certificate check is a big deal. If the certificate doesn't match the node that sent the AttachReqAns, the connection has to get shut down right away ๐ญ
6.5.1.12. Subsequent Offers and Answers ๐ โโ๏ธ
An agent MUST NOT send a subsequent offer or answer. So the procedures in Section 9 of ICE MUST be ignored ๐
6.5.1.13. Sending Media ๐ง
The procedures of Section 11 of ICE apply to RELOAD as well ๐ But here, the "media" is application-layer protocols (e.g., RELOAD) running over TLS or DTLS. So once ICE processing finishes, the agent begins the TLS or DTLS procedures to set up a secure connection ๐ The node that sent the Attach request MUST be the TLS server. The other node MUST be the TLS client. The server MUST request TLS client authentication. The nodes MUST verify that the certificate presented in the handshake matches the identity of the other peer as found in the Attach message ๐ต๏ธโโ๏ธ Once the TLS or DTLS signaling is complete, the application protocol is free to use the connection ๐ฅณ
The concept of a previous selected pair for a component doesn't apply to RELOAD, since ICE restarts aren't possible with RELOAD ๐ โโ๏ธ
6.5.1.14. Receiving Media ๐ฅ
An agent MUST be prepared to receive packets for the application protocol (TLS or DTLS carrying RELOAD) at any time โฐ The jitter and RTP considerations in Section 11 of ICE don't apply to RELOAD ๐
6.5.2. AppAttach ๐
A node sends an AppAttach request when it wants to set up a direct connection to another node for sending application-layer messages โจ AppAttach is nearly identical to Attach, except for the connection's purpose. It's used to carry non-RELOAD "media" ๐ถ A separate request exists so implementers don't get confused between the two methods. Turns out this was a real problem with the first implementations ๐ฉ The AppAttach request and its response contain an application attribute, which says what protocol will run over the connection ๐ง
6.5.2.1. Request Definition ๐ฆ
An AppAttachReq message contains the requesting node's ICE connection parameters, formatted into a binary structure ๐ง
struct {
opaque ufrag<0..2^8-1>;
opaque password<0..2^8-1>;
uint16 application;
opaque role<0..2^8-1>;
IceCandidate candidates<0..2^16-1>;
} AppAttachReq;
Here's what the values in AppAttachReq and AppAttachAns mean:
ufrag: The username fragment (from ICE).password: The ICE password.application: A 16-bit Application-ID, as defined in the Section 14.5. This number represents the IANA-registered application that's going to send data on this connection ๐ฎrole: An active/passive/actpass attribute from RFC 4145 [RFC4145].candidates: One or more ICE candidate values.
The application using the connection set up with this request is responsible for sending traffic often enough to keep the NAT and Firewall bindings alive ๐ฅ Applications will often send traffic every 25 seconds to make sure this happens โฑ๏ธ
6.5.2.2. Response Definition ๐
If a peer receives an AppAttach request, it SHOULD process the request and generate its own response with a AppAttachAns. It should then begin ICE checks ๐โโ๏ธ When a peer receives an AppAttach response, it SHOULD parse the response and begin its own ICE checks โ
If the Application ID isn't supported, the peer MUST reply with an Error_Not_Found error ๐
โโ๏ธ
struct {
opaque ufrag<0..2^8-1>;
opaque password<0..2^8-1>;
uint16 application;
opaque role<0..2^8-1>;
IceCandidate candidates<0..2^16-1>;
} AppAttachAns;
The meaning of the fields is the same as in the AppAttachReq ๐ซถ
6.5.3. Ping ๐
Ping is used to test connectivity along a path ๐ฃ๏ธ A ping can be addressed to a specific Node-ID, to the peer controlling a given location (by using a Resource-ID), or to the wildcard Node-ID ๐ฏ
6.5.3.1. Request Definition ๐จ
The PingReq structure is used to make a Ping request ๐
struct {
opaque<0..2^16-1> padding;
} PingReq;
The Ping request is empty of meaningful contents ๐ซ But it can contain up to 65535 bytes of padding, which helps with discovering overlay maximum packet sizes ๐
6.5.3.2. Response Definition ๐ฌ
A successful PingAns response contains the information elements the peer requested ๐
struct {
uint64 response_id;
uint64 time;
} PingAns;
A PingAns message contains the following elements:
response_id: A randomly generated 64-bit response ID. This is used to distinguish Ping responses ๐ฒtime: The time when the Ping response was created, represented in the same way as storage_time, defined in Section 7 โฐ
6.5.4. ConfigUpdate ๐ฃ
okay so ConfigUpdate is how a node spreads fresh configuration data across the whole overlay ๐ Whenever a node notices that another node is running old config data, it MUST generate a ConfigUpdate request ๐จ That one request can update two kinds of data: the configuration data (Section 6.3.2.1) and the Kind information (Section 7.4.1.1). it's giving group-chat announcement, but make it networking ๐ฆ
6.5.4.1. Request Definition ๐
the ConfigUpdateReq structure is how we pass along the updated config info โจ
enum { invalidConfigUpdateType(0), config(1), kind(2), (255) }
ConfigUpdateType;
typedef uint32 KindId;
typedef opaque KindDescription<0..2^16-1>;
struct {
ConfigUpdateType type;
uint32 length;
select (type) {
case config:
opaque config_data<0..2^24-1>;
case kind:
KindDescription kinds<0..2^24-1>;
/* This structure may be extended with new types */
};
} ConfigUpdateReq;
here's what's inside the ConfigUpdateReq message ๐ซถ
type: tells you what kind of content the message is carrying. the structure leaves room for content types we don't know about yet ๐length: the length of the rest of the message. it's here for backward compatibility, and it's 32 bits instead of 24 so converting between network and host byte order is easy peasy ๐งconfig_data(type==config): the contents of the Configuration Document ๐kinds(type==kind): one or more XML kind-block productions (see Section 11.1). these MUST be encoded with UTF-8, and they assume a default namespace ofurn:ietf:params:xml:ns:p2p:config-base๐
6.5.4.2. Response Definition ๐
the ConfigUpdateAns structure is what we use to answer a ConfigUpdateReq ๐
struct {
} ConfigUpdateAns;
if the ConfigUpdateReq is type "config", it MUST be processed only if ALL of these are true ๐
- the sequence number in the document is greater than the current configuration sequence number ๐ข
- the Configuration Document is correctly digitally signed (see Section 11 for details on signatures) โ๏ธ
otherwise, appropriate errors MUST be generated ๐
if the ConfigUpdateReq is type "kind", it MUST be processed only if it's correctly digitally signed by an acceptable Kind signer (meaning one listed in the current configuration file). details on the kind-signer field in the configuration file are in Section 11.1 ๐ also, if the Kind update conflicts with an existing known Kind (meaning it's signed by a different signer), then it should be rejected with an Error_Forbidden error. this should not happen in correctly functioning overlays ๐
โโ๏ธ
if the update is acceptable, the node MUST reconfigure itself to match the new information โจ that might mean adding permissions for new Kinds, deleting old Kinds, or even, in extreme circumstances, exiting and re-entering the overlay (for instance, if the DHT algorithm has changed) ๐ฆ
if an implementation misses enough ConfigUpdates that include key changes, it might not be able to verify new valid ConfigUpdates anymore ๐ญ in that case, the only available recovery mechanism is to try retrieving a new Configuration Document, typically through the same mechanisms used for initial bootstrapping. it's up to implementers whether or how to use this sort of recovery mechanism ๐
the response for ConfigUpdate is empty ๐ซง
6.6. Overlay Link Layer ๐ธ
okay so RELOAD can use multiple Overlay Link protocols to send its messages ๐ฆ ICE is what sets up connections (see Section 6.5.1.3), so RELOAD nodes can detect which Overlay Link protocols other nodes offer and then connect to them ๐ค any link protocol needs to be able to set up a secure, authenticated connection, and to provide data origin authentication and message integrity for individual data elements ๐ RELOAD currently supports three Overlay Link protocols ๐
- DTLS [RFC6347] over UDP with Simple Reliability (SR) (
OverlayLinkType=DTLS-UDP-SR) ๐ - TLS [RFC5246] over TCP with Framing Header, No-ICE (
OverlayLinkType=TLS-TCP-FH-NO-ICE) ๐ - DTLS [RFC6347] over UDP with SR, No-ICE (
OverlayLinkType=DTLS-UDP-SR-NO-ICE) ๐ง
ngl, UDP doesn't really have "connections" ๐ but both TLS and DTLS have a handshake that sets up a similar, stateful association, so for this document we call these "connections" โจ
if a peer gets a message bigger than the max-message-size value defined in the overlay configuration, the peer SHOULD send an Error_Message_Too_Large error and then close the TLS or DTLS session the message came in on ๐ซ this error can be sent, and the session closed, before the peer has even received the whole message ๐ณ if the forwarding header is bigger than max-message-size, the receiver SHOULD close the TLS or DTLS session without sending an error ๐
the RELOAD mechanism needs failed links to get removed from the Routing Table quickly, so end-to-end retransmission can handle lost messages ๐โโ๏ธ Overlay Link protocols MUST be designed with a mechanism that quickly signals a likely failure, and implementations SHOULD quickly act to remove a failed link from the Routing Table when they get that signal โก the entry can be restored if the link proves to be working again, or it can be replaced later if needed ๐ Section 10.7.2 has more details specific to the CHORD-RELOAD Topology Plug-in ๐ง
the Framing Header (FH) frames messages and provides timing when it's used on a reliable stream-based transport protocol ๐ Simple Reliability (SR) uses the FH to provide congestion control and partial reliability when using unreliable message-oriented transport protocols ๐ we'll define each of these algorithms first, in Sections 6.6.2 and 6.6.3, and then define the Overlay Link protocols that use them in Sections 6.6.4, 6.6.5, and 6.6.6 ๐
Note: we expect future Overlay Link protocols to define replacements for all components of these protocols, including the Framing Header. the three protocols we'll discuss were chosen for simplicity of implementation and reasonable performance ๐ซถ
6.6.1. Future Overlay Link Protocols ๐ฎ
it's possible to define new link-layer protocols and apply them to a new overlay using the "overlay-link-protocol" configuration directive (see Section 11.1.) ๐ ๏ธ however, any new protocols MUST meet the following requirements ๐
- Endpoint authentication: when a node forms an association with another endpoint, it MUST be possible to cryptographically verify that the endpoint has a given Node-ID ๐
- Traffic origin authentication and integrity: when a node receives traffic from another endpoint, it MUST be possible to cryptographically verify that the traffic came from a given association and that it hasn't been modified in transit from the other endpoint in the association ๐ the overlay link protocol MUST also provide replay prevention/detection ๐ก๏ธ
- Traffic confidentiality: when a node sends traffic to another endpoint, it MUST NOT be possible for a third party that isn't involved in the association to figure out the contents of that traffic ๐ค
any new overlay protocol MUST be defined via Standards Action [RFC5226]. see Section 14.11 ๐
6.6.1.1. HIP ๐ฆ
in a Host Identity Protocol Based Overlay Networking Environment (HIP BONE) [RFC6079], HIP [RFC5201] handles connection management (things like NAT traversal and mobility) and security for the overlay network ๐ the P2PSIP Working Group has shown interest in supporting a HIP-based link protocol ๐ that support would need specifying details like:
- how to issue certificates that give identities meaningful to the HIP base exchange. we expect this would need a mapping between Overlay Routable Cryptographic Hash Identifiers (ORCHIDs) and NodeIds ๐บ๏ธ
- how to carry the HIP I1 and I2 messages ๐จ
- how to carry RELOAD messages over HIP ๐
[HIP-RELOAD] documents work in progress on using RELOAD with the HIP BONE ๐ง
6.6.1.2. ICE-TCP ๐ท
the ICE-TCP RFC [RFC6544] lets TCP be supported as an Overlay Link protocol that can be added using ICE ๐งฉ
6.6.1.3. Message-Oriented Transports ๐ซ
modern message-oriented transports offer high performance and good congestion control, and they avoid head-of-line blocking when data gets lost ๐ that's why they're preferable as underlying transport protocols for RELOAD links ๐ SCTP without message ordering and DCCP are two examples ๐ but right now they aren't well-supported by commonly available NATs, and specifications for ICE session establishment aren't available yet ๐ฉ
6.6.1.4. Tunneled Transports ๐
as of when this was written, there's a lot of interest in the IETF community in tunneling other transports over UDP ๐ซง it's motivated by the fact that UDP is well-supported by modern NAT hardware, and that performance similar to a native implementation can be achieved โญ right now, SCTP, DCCP, and a generic tunneling extension are being proposed for message-oriented protocols ๐ once ICE traversal has been specified for these tunneled protocols, they should be straightforward to support as overlay link protocols ๐ฆ
6.6.2. Framing Header โจ
okay so bestie ๐ซถ every message gets wrapped in a super simple framing layer called FramedMessage ๐. It only works on each hop, not end to end. This is what lets things work on flaky links, and it lets you spot a dead link fast when you're using reliable end-to-end transports ๐. It also has a sequence number that can be used for ACKs. The same header is used for both reliable and unreliable transports, because keeping it the same makes it way easier to implement ๐ .
The definition of FramedMessage looks like this:
enum { data(128), ack(129), (255) } FramedMessageType;
struct {
FramedMessageType type;
select (type) {
case data:
uint32 sequence;
opaque message<0..2^24-1>;
case ack:
uint32 ack_sequence;
uint32 received;
};
} FramedMessage;
The type field tells you whether the PDU is data or an acknowledgement ๐ฆ.
If the message is of type "data", the rest of the PDU looks like this:
sequence: the sequence number. It goes up by one for each framed message sent over this transport session ๐ธ.message: the message being transmitted ๐.
Every connection has its own sequence number space. It starts at zero and goes up by exactly one for each message sent over that connection ๐ข.
When the receiver gets a message, it SHOULD immediately send an ACK message โก. The receiver MUST keep track of the 32 most recent sequence numbers received on this association so it can generate the right ACK ๐ง .
If the PDU is of type "ack", the contents are:
ack_sequence: the sequence number of the message being acknowledged ๐.received: a bitmask showing whether each of the 32 sequence numbers before this packet was among the 32 packets most recently received on this connection ๐. Here's how it works: when a packet with sequence number N comes in, the receiver checks the 32 packets it got before. Call each earlier one M. For each of those, if M is less than N but greater than N-32, the N-M bit of the received bitmask gets set to one. Otherwise it's set to zero ๐งฎ. Here's the tea โ: a one means that packet was DEFINITELY received, but a zero only means it's unknown whether it was received, because it might have arrived before those 32 most recent packets ๐.
The received bits give the ACK a lot of redundancy, so the sender can figure out which packets arrived and estimate packet loss rates ๐. If the sender also tracks when recent sequence numbers were sent, it can estimate the RTT (round-trip time) โฑ๏ธ.
Heads up: because retransmissions get new sequence numbers, you can receive multiple ACKs for the same message ๐จ. This gives way more info than traditional TCP sequence numbers, but you have to be careful if you borrow algorithms that were built around TCP's stream-oriented sequence numbers ๐.
6.6.3. Simple Reliability ๐ก๏ธ
When RELOAD runs over DTLS or another unreliable link protocol, it needs a reliability and congestion control mechanism, and that's provided hop by hop ๐. The basic idea is that every message, whether it carries a request or a response, gets an ACK and is reliably retransmitted ๐ . The receiver's job is super simple: it just sends ACKs ๐ซง. All the complexity lives on the sender side. That means the sending implementation can trade off performance against implementation complexity without changing the wire protocol ๐ฏ.
Since the receiver only handles packet acknowledgements, you can plug a wide variety of congestion control algorithms into the sender side while still using the same basic wire protocol ๐. The sender algorithm used MUST meet the requirements of [RFC5405] ๐.
6.6.3.1. Stop and Wait Sender Algorithm ๐ข
This section describes one possible sender algorithm for Simple Reliability ๐ท. It's fine for overlays running on networks with low latency and loss (LANs), or for low-traffic overlays on the Internet โจ.
A node MUST NOT have more than one unacknowledged message on the DTLS connection at a time ๐ซ. Retransmissions of the same message get new sequence numbers, so there can still be multiple unacknowledged sequence numbers in use ๐ข.
The RTO (Retransmission TimeOut) is based on an estimate of the RTT ๐. The RTO is calculated separately for each DTLS session. Implementations can use a static value or a dynamic estimate, and a dynamic estimate can give better performance ๐. For implementations that use a static value, the default RTO is 500 ms ๐. Nodes MAY use smaller RTO values if it's known that all nodes are within the local network ๐ . The default RTO MAY be set to a larger value, which is RECOMMENDED if it's known in advance (like on high-latency access links) that the RTT is larger ๐.
Implementations that use a dynamic estimate to compute the RTO MUST use the algorithm described in RFC 6298 [RFC6298] ๐. The one exception: the RTO SHOULD NOT be rounded up to the nearest second, and should instead be rounded up to the nearest millisecond โณ. The RTT of a successful STUN transaction from the ICE stage is used as the initial measurement for formula 2.2 of RFC 6298 ๐ฑ. The sender keeps track of when each message was sent, for all recently sent messages ๐๏ธ. Any time an ACK comes in, the sender can compute the RTT for that message by comparing when the ACK arrived with when the message was sent ๐ฐ๏ธ. That becomes a subsequent RTT measurement for formula 2.3 of RFC 6298, which updates the RTO estimate ๐. (Because retransmissions get new sequence numbers, all received ACKs are used ๐.)
An initiating node SHOULD retransmit a message if it hasn't received an ACK after an interval of RTO. Transit nodes do not retransmit at this layer ๐ . The node MUST double the time it waits after each retransmission ๐. For each retransmission, the sequence number MUST be incremented ๐ข.
Retransmissions continue until one of these happens: a response is received, a total of 5 requests have been sent, there's a hard ICMP error [RFC1122], or a TLS alert indicating the end of the connection has been sent or received ๐. The sender knows a response was received when it gets an ACK with a sequence number that shows it's a response to one of the transmissions of this message ๐ฌ. For example, assuming an RTO of 500 ms, requests would be sent at 0 ms, 500 ms, 1500 ms, 3500 ms, and 7500 ms โฐ. If all retransmissions for a message fail, the sending node SHOULD close the connection routing the message ๐.
To figure out when a link might be failing without waiting for the final timeout, watch for when no ACKs arrive for an entire RTO interval. Then wait for three retransmissions beyond that point ๐. If no ACKs have arrived by the time the third retransmission happens, it is RECOMMENDED that the link be removed from the Routing Table ๐๏ธ. The link MAY be restored to the Routing Table if ACKs resume before the connection is closed, as described above ๐ฆ.
A sender MUST wait 10 ms between receiving an ACK and transmitting the next message โธ๏ธ.
6.6.4. DTLS/UDP with SR ๐
This overlay link protocol is DTLS over UDP, implementing the SR protocol ๐. STUN connectivity checks and keepalives are used here ๐ซ. Any compliant sender algorithm may be used ๐ง.
6.6.5. TLS/TCP with FH, No-ICE ๐
This overlay link protocol is TLS over TCP with the framing header ๐งต. Since ICE isn't used, STUN connectivity checks aren't used when the TCP connection is set up, and they aren't used for keepalives either ๐ โโ๏ธ.
The TCP layer's application-level timeout is way too slow for overlay routing ๐ข. So the Overlay Link implementation MUST use the framing header to measure the RTT of the connection and calculate an RTO as specified in Section 2 of [RFC6298] ๐. The resulting RTO isn't used for retransmissions. Instead, it's a timeout that indicates when the link SHOULD be removed from the Routing Table โฒ๏ธ. It is RECOMMENDED that such a connection be retained for 30 seconds, so you can tell whether the failure was transient before deciding the link has failed permanently ๐ซถ.
When sending candidates for TLS/TCP with FH, No-ICE, a passive candidate MUST be provided ๐.
6.6.6. DTLS/UDP with SR, No-ICE ๐ธ
This overlay link protocol is DTLS over UDP, implementing the Simple Reliability protocol ๐ฆ. Since ICE isn't used, no STUN connectivity checks or keepalives are used either ๐.
6.7. Fragmentation and Reassembly โจ
okay so, to let RELOAD messages travel over datagram protocols like DTLS ๐ฆ, they may be fragmented. Any node along the path can fragment the message, but only the final destination reassembles the fragments ๐ . When a node takes a packet and fragments it, each fragment gets a full copy of the forwarding header, and the data after that header gets chopped into appropriately sized chunks ๐งฉ. The size of the payload chunks needs to leave room for the Via and Destination Lists to grow, bestie. Each fragment MUST contain a full copy of the Via List, Destination List, and ForwardingOptions and MUST contain at least 256 bytes of the message body ๐. If those elements can't fit within the MTU of the underlying datagram protocol, RELOAD fragmentation is not performed, and IP-layer fragmentation is allowed to occur ๐. The length field MUST contain the size of the message after fragmentation. When a message MUST be fragmented, it SHOULD be split into equal-sized fragments that are no larger than the Path MTU (PMTU) of the next overlay link minus 32 bytes. This is so the Via List has room to grow before more fragmentation is needed ๐ธ.
Note that this fragmentation isn't optimal for the end-to-end path ๐ฅฒ. A message may get refragmented multiple times as it crosses the overlay, but it only gets assembled at the final destination. This option was picked because it's way easier to implement than end-to-end (e2e) PMTU discovery across an ever-changing overlay, and it effectively deals with the reliability issues of relying on IP-layer fragmentation ๐. However, Ping can be used to allow e2e PMTU discovery to be implemented if desired โจ.
Once the intended peer gets a fragmented message, it holds the fragments in a holding buffer until the entire message has arrived ๐ฆ. Then the message is reassembled into a single message and processed ๐. To mitigate denial-of-service (DoS) attacks, receivers SHOULD time out incomplete fragments after the maximum request lifetime (15 seconds) โฐ. That number came from looking at the end-to-end retransmission time and saving fragments long enough for full end-to-end retransmissions to happen ๐. Ideally, the receiver would have enough buffer space to handle as many fragments as can arrive in the maximum request lifetime. But if the receiver runs out of buffer space to reassemble a message, it MUST drop the message ๐ญ.
The fragment field of the forwarding header is used to encode fragmentation information ๐ฆ. The offset is the number of bytes between the end of the forwarding header and the start of the data, so the first fragment has an offset of 0 ๐. The last fragment indicator MUST be appropriately set. If the message isn't fragmented, it's simply treated as if it's the only fragment: the last fragment bit is set and the offset is 0, which gives a fragment value of 0xC0000000 ๐
.
Note: The reason for this definition of the fragment field is that originally, the high bit was defined in part of the specification as "is fragmented," so there was some specification ambiguity about how to encode messages with only one fragment ๐. This ambiguity was resolved in favor of always encoding as the "last" fragment with offset 0, which simplifies the receiver code path, but makes the high bit redundant ๐ง . Because messages MUST be set with the high bit set to 1, implementations SHOULD discard any message with it set to 0. Implementations (presumably legacy ones) which choose to accept such messages MUST either ignore the remaining bits or ensure that they are 0. They MUST NOT try to interpret as fragmented messages with the high bit set low ๐ซ.
7. Data Storage Protocol โจ
RELOAD gives you a set of generic mechanisms for storing and retrieving data in the Overlay Instance ๐๏ธ. New applications can use them just by defining new code points and a small set of rules, so no new protocol mechanisms are required ๐.
The basic unit of stored data is a single StoredData structure ๐:
struct {
uint32 length;
uint64 storage_time;
uint32 lifetime;
StoredDataValue value;
Signature signature;
} StoredData;
Here's what each field means:
length: The size of the StoredData structure, in bytes, excluding the size of length itself.storage_time: The time when the data was stored, represented as the number of milliseconds elapsed since midnight Jan 1, 1970 UTC, not counting leap seconds. The seconds match standard UNIX or POSIX time. More information can be found at [UnixTime]. Any attempt to store a data value with a storage time before that of a value already stored at this location MUST generate an Error_Data_Too_Old error. This prevents rollback attacks ๐. The node SHOULD make a best-effort attempt to use a correct clock to determine this number โฑ๏ธ. However, the protocol does not require synchronized clocks: the receiving peer uses the storage time in the previous store, not its own clock ๐คทโโ๏ธ. Clock values are used so that when clocks are generally synchronized, data may be stored in a single transaction, rather than querying for the value of a counter before the actual store โจ.- If a node attempting to store new data in response to a user request (rather than as an overlay maintenance operation, such as occurs when healing the overlay from a partition) is rejected with an Error_Data_Too_Old error, the node MAY elect to perform its store using a storage_time that increments the value used with the previous store (this may be obtained by doing a Fetch). This situation may occur when the clocks of nodes storing to this location are not properly synchronized ๐ฐ๏ธ.
lifetime: The validity period for the data, in seconds, starting from the time the peer receives the StoreReq โ.value: The data value itself, as described in Section 7.2 ๐.signature: A signature, as defined in Section 7.1 ๐.
Each Resource-ID specifies a single location in the Overlay Instance ๐. However, each location may contain multiple StoredData values, distinguished by Kind-ID ๐. The definition of a Kind describes both the data values which may be stored and the data model of the data. Some data models allow multiple values to be stored under the same Kind-ID. Section 7.2 describes the available data models. So, for instance, a given Resource-ID might contain a single-value element stored under Kind-ID X and an array containing multiple values stored under Kind-ID Y ๐ง.
7.1. Data Signature Computation
Each StoredData element is individually signed ๐๏ธ. However, the signature also must be self-contained and must cover the Kind-ID and Resource-ID, even though they aren't present in the StoredData structure ๐ฅน. The input to the signature algorithm is:
resource_id || kind || storage_time || StoredDataValue ||
SignerIdentity
where || indicates concatenation and where these values are:
resource_id: The Resource-ID where this data is stored.kind: The Kind-ID for this data.storage_time: The contents of the storage_time data value.StoredDataValue: The contents of the stored data value, as described in the previous sections.SignerIdentity: The signer identity, as defined in Section 6.3.4.
Once the signature has been computed, it is represented using a signature element, as described in Section 6.3.4 โ .
Note that there is no necessary relationship between the validity window of a certificate and the expiry of the data it is authenticating ๐ซฃ. When signatures are verified, the current time MUST be compared to the certificate validity period. Stored data MAY be set to expire after the signing certificate's validity period. Such signatures are not considered valid after the signing certificate expires ๐ซ. Implementations may "garbage collect" such data at their convenience, either by purging it automatically (perhaps by setting the upper bound on data storage to the lifetime of the signing certificate) or by simply leaving it in place until it expires naturally and relying on users of that data to notice the expired signing certificate ๐๏ธ๐ .
7.2. Data Models
The protocol currently defines the following data models ๐:
- single value
- array
- dictionary
These are represented with the StoredDataValue structure. The actual data model is known from the Kind being stored ๐.
struct {
Boolean exists;
opaque value<0..2^32-1>;
} DataValue;
struct {
select (DataModel) {
case single_value:
DataValue single_value_entry;
case array:
ArrayEntry array_entry;
case dictionary:
DictionaryEntry dictionary_entry;
/* This structure may be extended */
};
} StoredDataValue;
The following sections discuss the properties of each data model ๐ท.
7.2.1. Single Value
A single-value element is a simple sequence of bytes. There may be only one single-value element for each Resource-ID, Kind-ID pair ๐.
A single value element is represented as a DataValue, which contains the following two elements:
exists: This value indicates whether the value exists at all. If it is set to False, it means that no value is present. If it is True, this means that a value is present. This gives the protocol a mechanism for indicating nonexistence as opposed to emptiness ๐ซง.value: The stored data.
7.2.2. Array
An array is a set of opaque values addressed by an integer index. Arrays are zero based ๐ข. Note that arrays can be sparse ๐ณ๏ธ. For instance, a Store of "X" at index 2 in an empty array produces an array with the values [ NA, NA, "X"]. Future attempts to fetch elements at index 0 or 1 will return values with "exists" set to False ๐.
An array element is represented as an ArrayEntry:
struct {
uint32 index;
DataValue value;
} ArrayEntry;
The contents of this structure are:
index: The index of the data element in the array.value: The stored data.
7.2.3. Dictionary
A dictionary is a set of opaque values indexed by an opaque key, with one value for each key ๐๏ธ. A single dictionary entry is represented as a DictionaryEntry:
typedef opaque DictionaryKey<0..2^16-1>;
struct {
DictionaryKey key;
DataValue value;
} DictionaryEntry;
The contents of this structure are:
key: The dictionary key for this value.value: The stored data.
7.3. Access Control Policies ๐
okay bestie, every Kind that's storable in an overlay MUST come with an access control policy ๐ก๏ธ this policy decides whether a request from a given node to operate on a given value should succeed or fail. it's giving bouncer at the club ๐ only a small number of generic policies are needed, so this section describes a small set of them, and Section 14.4 sets up a registry for new policies, if required โจ each policy has a short string identifier that gets used to reference it in the Configuration Document ๐
in the policies below, "signer" means the signer of the StoredValue object and, for non-replica stores, the signer of the StoreReq message ๐ so in a non-replica store, both the signer of the StoredValue and the signer of the StoreReq MUST conform to the policy. for a replica store, the signer of the StoredValue MUST conform to the policy, and the StoreReq itself MUST be checked as described in Section 7.4.1.1 ๐ซถ
7.3.1. USER-MATCH
the USER-MATCH policy is the classic "it's your name or nothing" energy ๐ชช a given value MUST be written (or overwritten) if and only if the signer's certificate has a user name which hashes (using the hash function for the overlay) to the Resource-ID for the resource. recall that the certificate may, depending on the overlay configuration, be self-signed ๐ค
7.3.2. NODE-MATCH
the NODE-MATCH policy is all about your node ID ๐ฅ๏ธ a given value MUST be written (or overwritten) if and only if the signer's certificate has a specified Node-ID which hashes (using the hash function for the overlay) to the Resource-ID for the resource, and that Node-ID is the one indicated in the SignerIdentity value cert_hash. ๐ฆ
7.3.3. USER-NODE-MATCH
the USER-NODE-MATCH policy may be used only with dictionary types ๐ a given value MUST be written (or overwritten) if and only if the signer's certificate has a user name which hashes (using the hash function for the overlay) to the Resource-ID for the resource. on top of that, the dictionary key MUST be equal to the Node-ID in the certificate, and that Node-ID MUST be the one indicated in the SignerIdentity value cert_hash. double check, double slay ๐
7.3.4. NODE-MULTIPLE
the NODE-MULTIPLE policy is giving multiple doors but one key ๐๏ธ a given value MUST be written (or overwritten) if and only if the signer's certificate contains a Node-ID such that H(Node-ID || i) is equal to the Resource-ID for some small integer value of i, and that Node-ID is the one indicated in the SignerIdentity value cert_hash. when this policy is in use, the maximum value of i MUST be specified in the Kind definition. ๐
ngl this one is a little sneaky ๐ becauseiis not carried on the wire, the verifier MUST iterate through potentialivalues, up to the maximum value, to determine whether a store is acceptable. no shortcuts, it has to check every single one ๐
7.4. Data Storage Methods ๐๏ธ
RELOAD provides several methods for storing and retrieving data, and they're honestly the core of the whole vibe โจ
- Store values in the overlay. ๐พ
- Fetch values from the overlay. ๐ฅ
- Stat: Get metadata about values in the overlay. ๐
- Find the values stored at an individual peer. ๐ง
these methods are described in the following sections ๐ธ
7.4.1. Store
the Store method is used to store data in the overlay ๐ซง the format of the Store request depends on the data model, which is determined by the Kind. it's all connected, bestie ๐
7.4.1.1. Request Definition ๐ฌโจ
okay so a StoreReq is basically a bundle ๐ of StoreKindData values, and each one is a little stash of stored values for one Kind. bestie, the same Kind-ID MUST NOT be used twice in a single store request ๐ โโ๏ธ. Each value then gets processed in turn. These operations MUST be atomic ๐ . If any operation fails, the state MUST be rolled back to what it was before the request arrived. no cap, that's the whole "undo everything" energy ๐ญ
Here's how the StoreReq structure is laid out:
struct {
KindId kind;
uint64 generation_counter;
StoredData values<0..2^32-1>;
} StoreKindData;
struct {
ResourceId resource;
uint8 replica_number;
StoreKindData kind_data<0..2^32-1>;
} StoreReq;
A single Store request stores data of a bunch of Kinds to one resource location. Here's what each field does ๐ฆ
- resource: The resource at which to store.
- replica_number: The number of this replica. When a storing peer saves replicas to other peers, each peer gets a replica number, starting from 1, that is sent in the Store message. This field is set to 0 when a node is storing its own data. That lets peers tell replica writes apart from original writes ๐ซถ. Different topologies may choose to allocate or interpret the replica number differently (see Section 10.4).
- kind_data: A series of elements, one for each Kind of data to be stored.
The peer MUST check that it is responsible for the resource if the replica number is zero. if it isn't, the peer must reject the request ๐. The peer MUST check that it expects to be a replica for the resource, and that the request sender is consistent with being the responsible node (i.e., that the receiving peer does not know of a better node), if the replica number is nonzero. if the request sender isn't consistent, it should reject the request. the vibe check is very serious here ๐
Each StoreKindData element represents the data to be stored for a single Kind-ID. Inside each element:
- kind: The Kind-ID. Implementations MUST reject requests corresponding to unknown Kinds ๐ซ.
- generation_counter: The expected current state of the generation counter (roughly how many times this object has been written; more details below).
- values: The value or values to be stored. This may contain one or more stored_data values, depending on the data model associated with each Kind.
The peer MUST perform the following checks โจ
- The Kind-ID is known and supported.
- The signatures over each individual data element, if any, are valid. If this check fails, the request MUST be rejected with an Error_Forbidden error.
- Each element is signed by a credential which is authorized to write this Kind at this Resource-ID. If this check fails, the request MUST be rejected with an Error_Forbidden error.
- For original (non-replica) stores, the StoreReq is signed by a credential which is authorized to write this Kind at this Resource-ID. If this check fails, the request MUST be rejected with an Error_Forbidden error.
- For replica stores, the StoreReq is signed by a Node-ID which is a plausible node to either have originally stored the value or have been in the replica set. What that means is overlay specific, but for the Chord-based DHT defined in this specification, replica StoreReqs MUST come from nodes which are either in the known replica set for a given resource or which are closer than some node in the replica set. If this check fails, the request MUST be rejected with an Error_Forbidden error. this is the "who's allowed in the group chat" check ๐
- For original (non-replica) stores, the peer MUST check that if the generation counter is nonzero, it equals the current value of the generation counter for this Kind. This lets the generation counter work a bit like the HTTP ETag feature ๐ธ.
- For replica Stores, the peer MUST set the generation counter to match the generation counter in the message, and MUST NOT check the generation counter against the current value. Replica Stores MUST NOT use a generation counter of 0.
- The storage time values are greater than that of any values which would be replaced by this Store.
- The size and number of the stored values are consistent with the limits specified in the overlay configuration.
- If the data is signed with identity_type set to
"none"and/or SignatureAndHashAlgorithm values set to{0, 0}("anonymous"and"none"), the StoreReq MUST be rejected with an Error_forbidden error. Only synthesized data returned by the storage can use these values (see Section 7.4.2.2) ๐
โ ๏ธ bestie, the anonymous and "none" combo is a hard no for regular stores. only synthesized data coming back out of storage gets to use those values.
If all these checks pass, the peer MUST attempt to store the data values. For non-replica stores, if the store succeeds and the data is changed, the peer MUST increase the generation counter by at least 1 ๐. If there are multiple stored values in a single StoreKindData, the peer is allowed to bump the generation counter by just 1 for the whole Kind-ID, or by 1 or more for each value. Either way, all stored data values MUST have a generation counter of 1 or greater. 0 is used in the Store request to say "ignore the generation counter for this request." However, the responsible peer should increase the stored generation counter and should return the correct generation counter in the response ๐ซถ
When a peer stores data that was previously stored by another node (for example, for replicas or topology shifts), it MUST adjust the lifetime value downward to reflect how long the value has been sitting at that peer โณ. The adjustment SHOULD be done with an algorithm equivalent to this: when the peer first receives the StoreReq, it notes the local time T. When it then sends a StoreReq to another node, it should decrement the lifetime value by the difference between the current local time and T.
Unless the usage says otherwise, if a peer tries to store data previously stored by another node (for example, for replicas or topology shifts) and that store fails with either an Error_Generation_Counter_Too_Low or an Error_Data_Too_Old error, the peer MUST fetch the newer data from the peer generating the error and use it to replace its own copy. this is how things resync after partitions heal ๐
When a network partition is being healed, and unless otherwise specified, the default merging rule is to act as if all the values that need merging were stored, and as if the order they were stored in matches the stored time values attached to them. Because the stored time values belong to the peer that did the writing, clock skew is generally not an issue ๐ฐ๏ธ. If two nodes are on different partitions, write to the same location, and have clock skew, this can create merge conflicts. However, because RELOAD deliberately keeps storage segregated so that data from different users and peers lives in different locations, and a single peer will typically only be in a single network partition, this case generally won't come up ๐
The properties of stores for each data model are as follows ๐
- single-value: A store of a new single-value element creates the element if it doesn't exist, and overwrites any existing value with the new value.
- array: A store of an array entry replaces (or inserts) the given value at the location specified by the index. Because arrays are sparse, a store past the end of the array extends it with nonexistent values (exists = False) as required. A store at index 0xffffffff places the new value at the end of the array, regardless of the length of the array. The resulting StoredData has the correct index value when it's fetched later.
- dictionary: A store of a dictionary entry replaces (or inserts) the given value at the location specified by the dictionary key.
The following figure shows how these structures relate for an example store that stores these values at resource "1234" ๐ง
- The value "abc" is in the single-value location for Kind X.
- The value "foo" at index 0 is in the array for Kind Y.
- The value "bar" at index 1 is in the array for Kind Y.
Store
resource=1234
replica_number = 0
/ \
/ \
StoreKindData StoreKindData
kind=X (Single-Value) kind=Y (Array)
generation_counter = 99 generation_counter = 107
| /\
| / \
StoredData / \
storage_time = xxxxxxx / \
lifetime = 86400 / \
signature = XXXX / \
| | |
| StoredData StoredData
| storage_time = storage_time =
| yyyyyyyy zzzzzzz
| lifetime = 86400 lifetime = 33200
| signature = YYYY signature = ZZZZ
| | |
StoredDataValue | |
value="abc" | |
| |
StoredDataValue StoredDataValue
index=0 index=1
value="foo" value="bar"
7.4.1.2. Response Definition
okay so when a Store request goes through successfully, the peer MUST send back a StoreAns message ๐ It's basically a bunch of StoreKindResponse elements, one per Kind-ID, telling you the current generation counter for each Kind plus a list of the peers where the data is getting replicated by the node that handled your request. โจ
struct {
KindId kind;
uint64 generation_counter;
NodeId replicas<0..2^16-1>;
} StoreKindResponse;
struct {
StoreKindResponse kind_responses<0..2^16-1>;
} StoreAns;
Here's what each piece of a StoreKindResponse means ๐
kind The Kind-ID being represented.
generation_counter The current value of the generation counter for that Kind-ID.
replicas The list of other peers where the data was/will be replicated. In overlays and apps where the responsible peer is supposed to keep redundant copies, this lets the storing node check on its own that the replicas actually got stored ๐ It does that check using the Stat method (see Section 7.4.3). Note that the storing node is not required to do this check, so it's totally optional bestie ๐
The response is literally just StoreKindResponse values packed end to end, no gaps, no drama ๐ฆ
Now for the errors, because this is where it gets spicy ๐ถ๏ธ If any of the generation counters in the request are lower than the matching stored generation counter, the peer MUST fail the entire request and respond with an Error_Generation_Counter_Too_Low error. The error_info in the ErrorResponse MUST be a StoreAns response with the correct generation counter for each Kind and the replica list, which will be empty ๐ญ For original (non-replica) stores, a node that gets this error SHOULD try to fetch the data and, if the storage_time value is newer, replace its own data with the newer stuff. This rule is what keeps data consistent after partitions and merges, and honestly it's giving main character energy ๐
If the data being stored is too big for the limit allowed by the given usage, the peer MUST fail the request and generate an Error_Data_Too_Large error. ๐ซ
If any type of request tries to touch a data Kind that the peer doesn't know about, the peer MUST fail the request and generate an Error_Unknown_Kind error. The error_info in the Error_Response is:
KindId unknown_kinds<0..2^8-1>;
which lists all the Kinds that were unrecognized ๐ง A node that receives this error MUST generate a ConfigUpdate message containing the appropriate Kind definition (assuming, of course, that a Kind defined in the configuration document was the one being used) ๐ซถ
7.4.1.3. Removing Values
RELOAD doesn't have an explicit Remove operation ๐ Instead, values get removed by storing "nonexistent" values in their place. Every DataValue has a boolean called "exists" that tells you whether a value is actually there at that location. So to effectively remove a value, the owner stores a new DataValue with "exists" set to False:
exists = False
value = {} (0 length)
The owner SHOULD use a lifetime for the nonexistent value that is at least as long as the rest of the lifetime of the value it's replacing ๐ฐ๏ธ Otherwise, the original value could get accidentally or maliciously re-stored after the storing node has already expired it, which would be a total mess. Note that a window of vulnerability for replay attack still exists after the original lifetime has expired (same as with any store). This attack can be mitigated by doing a nonexistent store with a very long lifetime ๐ก๏ธ
Storing nodes MUST treat these nonexistent values the same way they treat any other stored value. That includes overwriting the existing value, replicating them, and aging them out when the lifetime expires as necessary. When a stored nonexistent value's lifetime expires, it's simply removed from the storing node, just like any other stored value does when it expires ๐งน
Note that in the case of arrays and dictionaries, expiration may create an implicit, unsigned "nonexistent" value to represent a gap in the data structure, which can happen when any value ages out ๐ณ๏ธ
However, that value isn't persistent, and it isn't replicated either. It's just synthesized by the storing node on the spot โจ
7.4.2. Fetch
The Fetch request retrieves one or more data elements stored at a given Resource-ID ๐ A single Fetch request can grab multiple different Kinds at once, which is so efficient it's kinda iconic ๐ฅ
7.4.2.1. Request Definition
Fetch requests are defined by the FetchReq structure:
struct {
int32 first;
int32 last;
} ArrayRange;
struct {
KindId kind;
uint64 generation;
uint16 length;
select (DataModel) {
case single_value: ; /* Empty */
case array:
ArrayRange indices<0..2^16-1>;
case dictionary:
DictionaryKey keys<0..2^16-1>;
/* This structure may be extended */
} model_specifier;
} StoredDataSpecifier;
struct {
ResourceId resource;
StoredDataSpecifier specifiers<0..2^16-1>;
} FetchReq;
Here's what goes into a Fetch request ๐ธ
resource The Resource-ID to fetch from.
specifiers A sequence of StoredDataSpecifier values, each one specifying some of the data values you want to retrieve.
Each StoredDataSpecifier specifies a single Kind of data to retrieve and, if it makes sense, the subset of values you want. The contents of the StoredDataSpecifier structure are as follows:
kind The Kind-ID of the data being fetched. Implementations SHOULD reject requests for unknown Kinds unless they've been specifically configured otherwise ๐ง
DataModel The data model of the data. This isn't sent over the wire, it comes from the definition of the Kind ๐ง
generation The last generation counter that the requesting node saw. This can be used to avoid unnecessary fetches, or it can just be set to zero ๐
length The length of the rest of the structure, which is what allows it to be extended later ๐งฉ
model_specifier A reference to the data value being requested within the data model specified for the Kind. For example, if the data model is "array", it might specify some subset of the values ๐ฏ
Here's how the model_specifier works, depending on the data model ๐
- If the data model is single value, the specifier is empty.
- If the data model is array, the specifier contains a list of
ArrayRangeelements, each holding two integers. The first integer is the beginning of the range, and the second is the end.0means the first element, and0xffffffffmeans the final element. The first integer MUST be less than or equal to the second. While multiple ranges MAY be specified, they MUST NOT overlap. ๐ - If the data model is dictionary, the specifier contains a list of the dictionary keys being requested. If no keys are specified, it's a wildcard fetch and all key-value pairs get returned ๐
The generation counter is how the requester signals what state it expects the storing peer to be in. If the generation counter in the request matches the stored counter, the storing peer returns a response with no StoredData values ๐ค
7.4.2.2. Response Definition
The response to a successful Fetch request is a FetchAns message containing the data the requester asked for ๐
struct {
KindId kind;
uint64 generation;
StoredData values<0..2^32-1>;
} FetchKindResponse;
struct {
FetchKindResponse kind_responses<0..2^32-1>;
} FetchAns;
The FetchAns structure holds a series of FetchKindResponse structures. There MUST be one FetchKindResponse element for each Kind-ID in the request ๐
Here's what goes inside a FetchKindResponse ๐ฆ
kind The Kind that this structure is for.
generation The generation counter for this Kind.
values The relevant values. If the generation counter in the request matches the generation counter in the stored data, then no StoredData values are returned. Otherwise, all relevant data values MUST be returned. A nonexistent value (one the node has no knowledge of) is represented by a synthetic value with "exists" set to False and an empty signature. Specifically, the identity_type is set to "none", the SignatureAndHashAlgorithm values are set to {0, 0} ("anonymous" and "none", respectively), and the signature value is of zero length. This removes the need for the responding node to make signatures for values that don't exist ๐ Those signatures would be pointless anyway, since the entire response is signed by that node. Note that entries removed by the procedure in Section 7.4.1.3 that haven't expired yet also have exists = False, but they do have valid signatures from the node that did the store โ
Upon receipt of a FetchAns message, nodes MUST verify the signatures on all the received values. Any values with invalid signatures (including expired certificates) MUST be discarded ๐จ This means implementations that want to store data for long periods of time must have certificates with appropriate expiration dates or must re-store periodically. Implementations MAY return the subset of values with valid signatures, but in that case they SHOULD somehow signal to the application that a partial response was received ๐ฃ
There's one subtle point about signature computation on arrays, and it's a big one. If the storing node uses the append feature (where the index=0xffffffff), then the index in the StoredData that gets returned won't match the one the storing node used, which would break the signature. To avoid this, the index value in the array is set to zero before the signature is computed. This implies that malicious storing nodes can reorder array entries without being detected ๐ฑ
7.4.3. Stat
The Stat request is used to get metadata (length, generation counter, digest, etc.) for a stored element without retrieving the element itself ๐ต๏ธโโ๏ธ The name comes from the UNIX stat(2) system call, which does something similar for files in a file system. It also lets the requesting node get a list of matching elements without requesting the entire element ๐๏ธ
7.4.3.1. Request Definition
The Stat request is identical to the Fetch request. It just specifies the elements you want metadata about โจ
struct {
ResourceId resource;
StoredDataSpecifier specifiers<0..2^16-1>;
} StatReq;
7.4.3.2. Response Definition โจ
okay so the Stat response is giving Fetch vibes ๐ It has the same sort of entries a Fetch response would have, BUT instead of the element data you get metadata ๐
struct {
Boolean exists;
uint32 value_length;
HashAlgorithm hash_algorithm;
opaque hash_value<0..255>;
} MetaData;
struct {
uint32 index;
MetaData value;
} ArrayEntryMeta;
struct {
DictionaryKey key;
MetaData value;
} DictionaryEntryMeta;
struct {
select (DataModel) {
case single_value:
MetaData single_value_entry;
case array:
ArrayEntryMeta array_entry;
case dictionary:
DictionaryEntryMeta dictionary_entry;
/* This structure may be extended */
};
} MetaDataValue;
struct {
uint32 value_length;
uint64 storage_time;
uint32 lifetime;
MetaDataValue metadata;
} StoredMetaData;
struct {
KindId kind;
uint64 generation;
StoredMetaData values<0..2^32-1>;
} StatKindResponse;
struct {
StatKindResponse kind_responses<0..2^32-1>;
} StatAns;
The structures in StatAns parallel the ones in FetchAns ๐ฆ A response is a bunch of StatKindResponse values, one for each Kind that was in the request. The contents of StatKindResponse are the same as FetchKindResponse, except the values list holds StoredMetaData entries instead of StoredData entries.
The contents of StoredMetaData match the corresponding fields in StoredData, except there is no signature field, and the value is a MetaDataValue rather than a StoredDataValue.
A MetaDataValue is a variant structure, just like StoredDataValue, except each arm swaps DataValue out for MetaData ๐ง
The only brand-new structure is MetaData, and it has these fields:
exists: Same as inDataValue.value_length: The length of the stored value.hash_algorithm: The hash algorithm used to perform the digest of the value.hash_value: A digest usinghash_algorithmon thevaluefield of theDataValue, including its 4 leading length bytes.
7.4.4. Find ๐
The Find request is how you explore the Overlay Instance ๐ธ A Find request for a Resource-ID R and a Kind-ID T gets back the Resource-ID, if any, of the resource of Kind T that the target peer knows about which is closest to R. You can walk the whole Overlay Instance by iteratively fetching R_n+1=nearest(1 + R_n) โจ
7.4.4.1. Request Definition
The FindReq message has a Resource-ID and a series of Kind-IDs, which tell the peer what resource you're after ๐
struct {
ResourceId resource;
KindId kinds<0..2^8-1>;
} FindReq;
The request has a list of the Kind-IDs the Find is for, like so:
resource: The desired Resource-ID.kinds: The desired Kind-IDs. Each value MUST appear only once. Otherwise, the request MUST be rejected with an error. ๐
7.4.4.2. Response Definition
A response to a successful Find request is a FindAns message with the closest Resource-ID on the peer for each Kind in the request ๐
struct {
KindId kind;
ResourceId closest;
} FindKindData;
struct {
FindKindData results<0..2^16-1>;
} FindAns;
If the processing peer isn't responsible for the specified Resource-ID, it SHOULD return an Error_Not_Found error code.
For each Kind-ID in the request, the response MUST contain a FindKindData telling you the closest Resource-ID for that Kind-ID. The only exception is if the Kind isn't allowed to be used with Find, in which case a FindKindData for that Kind-ID MUST NOT be included in the response. If a Kind-ID isn't known, then the corresponding Resource-ID MUST be 0. Also, different Kind-IDs can have different closest Resource-IDs, so don't assume they all match ๐
The response is just a series of FindKindData elements, one per Kind, stacked end to end. Each element has:
kind: The Kind-ID.closest: The closest Resource-ID to the specified Resource-ID. It is 0 if no Resource-ID is known.
Heads up! The response does NOT include the contents of the data stored at these Resource-IDs. If the requester wants that data, it must retrieve it using Fetch. ๐
7.4.5. Defining New Kinds ๐
There are two ways to define a new Kind. The first is to write a document and register the Kind-ID with IANA. This is the preferred method for Kinds that may be widely used and reused ๐ซถ The second is to define the Kind and its parameters in the Configuration Document, using the section of Kind-ID space set aside for private use. This method MAY be used to define ad hoc Kinds in new overlays.
However a Kind is defined, the definition MUST include:
- The meaning of the data to be stored (in some textual form).
- The Kind-ID.
- The data model (single value, array, dictionary, etc.).
- The access control model.
When Kinds are registered with IANA, each Kind also gets a short string name, which is used to refer to it in Configuration Documents ๐
Every Kind needs to say what data model its data uses, but that doesn't mean it has to invent new data models. Where practical, Kinds should use the existing data models. The idea is that the basic data model set is enough for most applications and usages, so you don't have to reinvent the wheel ๐
8. Certificate Store Usage ๐
The Certificate Store Usage lets a node store its certificate in the overlay โจ
A user/node MUST store its certificate at Resource-IDs derived from two Resource Names:
- The user name in the certificate.
- The Node-ID in the certificate.
Here's the lowkey clever bit ๐ฆ In the second case, the certificate for a peer is not stored at its Node-ID, but at a hash of its Node-ID. The point here (as is common throughout RELOAD) is to avoid making a peer responsible for its own data ๐
New certificates are stored at the end of the list. This structure lets users keep an old and a new certificate that both have the same Node-ID, which allows certificates to migrate when they're renewed ๐ธ
This usage defines the following Kinds:
- Name:
CERTIFICATE_BY_NODE- Data Model: The data model for
CERTIFICATE_BY_NODEdata is array. - Access Control: NODE-MATCH
- Data Model: The data model for
- Name:
CERTIFICATE_BY_USER- Data Model: The data model for
CERTIFICATE_BY_USERdata is array. - Access Control: USER-MATCH
- Data Model: The data model for
9. TURN Server Usage ๐ก
The TURN Server Usage lets a RELOAD peer advertise that it's ready to be a TURN server, as defined in [RFC5766] ๐ When a node starts up, it joins the overlay network and forms several connections along the way. If the ICE stage in any of these connections returns a reflexive address that isn't the same as the peer's perceived address, then the peer is behind a NAT and SHOULD NOT be a candidate for a TURN server. Also, if the peer's IP address is in the private address space range defined by [RFC1918], then it is also SHOULD NOT be a candidate for a TURN server. Otherwise, the peer SHOULD assume that it is a potential TURN server and follow the procedures below ๐
If the node is a candidate for a TURN server, it inserts some pointers into the overlay so other peers can find it ๐ง The overlay configuration file has a turn-density parameter that says how many times each TURN server SHOULD record itself in the overlay. Typically, this should be set to the reciprocal of the estimate of what percentage of peers will act as TURN servers. If turn-density isn't set to zero, then for each value, called d, between 1 and turn-density, the peer forms a Resource Name by concatenating its Node-ID and the value d. This Resource Name is hashed to form a Resource-ID. The address of the peer is stored at that Resource-ID using type TURN-SERVICE and the TurnServer object:
struct {
uint8 iteration;
IpAddressPort server_address;
} TurnServer;
The contents of this structure are as follows:
iteration: The d value.server_address: The address at which the TURN server can be contacted.
Note: The algorithm only works properly if turn-density is a reasonable estimate of the reciprocal of the proportion of nodes in the overlay that can act as TURN servers. If the turn-density value in the configuration file is too low, finding TURN servers gets more expensive, because multiple candidate Resource-IDs have to be probed to find one ๐ญ
Peers that provide this service need to support the TURN extensions to STUN for media relay, as defined in [RFC5766] ๐
This usage defines the following Kind to indicate that a peer is willing to act as a TURN server:
- Name:
TURN-SERVICE- Data Model: The TURN-SERVICE Kind stores a single value for each Resource-ID.
- Access Control: NODE-MULTIPLE, with a maximum iteration of counter 20.
Peers MAY find other servers by picking a random Resource-ID and then doing a Find request for the appropriate Kind-ID with that Resource-ID. The Find request gets routed to a random peer based on the Resource-ID. If that peer knows of any servers, they're returned. The returned response may be empty if the peer doesn't know of any servers, in which case the process repeats with some other random Resource-ID. As long as the ratio of servers to peers isn't too low, this approach finds a server pretty quickly โญ
Note to implementers: The certificates used by TurnServer entries need to be retained, as described in Section 6.3.4. ๐ซถ
10. Chord Algorithm โจ
okay bestie, this section is giving DHT main character energy ๐ฆ The algorithm is named CHORD-RELOAD to show that it's an adaptation of the basic Chord-based DHT algorithm ๐
It's not the exact same as the Chord algorithm from [Chord] though ๐ It got a glow-up from newer research and real implementation experience, and it was tailored for RELOAD. Here's the highlight reel:
- Original Chord only stored a single predecessor and a successor list. CHORD-RELOAD tries to keep more than one predecessor and successor. The predecessor sets help other neighbors figure out their successor list ๐ซถ
- Original Chord was built around iterative routing. RELOAD uses recursive routing ๐ Performance is part of the reason, but honestly the cost of NAT traversal is what pushes it to recursive routing.
- Finger Table entries are indexed in the opposite order. Original Chord has
finger[0]as the immediate successor of the peer. CHORD-RELOAD hasfinger[0]as the peer 180 degrees around the ring from the peer ๐ This makes variable-sized Finger Tables easier to discuss and implement. Either way, no more thanO(log N)entries should typically be stored in a Finger Table ๐ง - The stabilize() and fix_fingers() algorithms from original Chord are merged into one periodic process ๐ Stabilization works a bit differently because of the larger neighborhood. fix_fingers is less aggressive so it reduces load, and it doesn't hunt for optimal matches of the Finger Table entries.
- RELOAD allows a 128-bit hash instead of a 160-bit hash. It's not designed for networks with close to or more than
2^128nodes or objects, and it's hard to see how anyone would even build a network that big ๐ญ - RELOAD uses randomized finger entries, as described in Section 10.7.4.2.
- CHORD-RELOAD lets you use either reactive or periodic recovery. The original Chord paper used periodic recovery. Reactive recovery performs better in small overlays, but it's believed to be unstable in large overlays (greater than 1000) with high levels of churn [handling-churn-usenix04] ๐ The overlay configuration file has a "chord-reactive" element that says whether reactive recovery should be used.
10.1. Overview
The algorithm here, CHORD-RELOAD, is a modified version of Chord ๐ In Chord (and in this algorithm), nodes sit in a ring, with node n adjacent to nodes n-1 and n+1. All the arithmetic is done modulo 2^{k}, where k is the length of the Node-ID in bits, so node 2^{k} - 1 sits directly before node 0 ๐
Each peer keeps track of a Finger Table and a Neighbor Table. The Neighbor Table holds at least the three peers before and after this peer in the DHT ring. There may not be three entries in every case, like in small rings or while the ring topology is changing ๐ธ The first Finger Table entry is the peer halfway around the ring from this peer. The second is the peer 1/4th of the way around, the third is the peer 1/8th of the way around, and so on โจ
Honestly, the Chord DHT is basically a doubly linked list, made by knowing the successor and predecessor peers in the Neighbor Table, sorted by Node-ID. As long as the successor peers are correct, the DHT returns the correct result ๐ The pointers to the prior peers exist so new peers can be inserted into the list. Keeping multiple predecessor and successor pointers keeps the data structure intact even when consecutive peers fail at the same time ๐ซถ
The Finger Table forms a skip list [wikiSkiplist], so entries in the linked list can be found in O(log(N)) time instead of the usual O(N) time a linked list would take. Here, N is the number of nodes in the DHT ๐
The Neighbor Table and Finger Table entries hold logical Node-IDs as values. The actual mapping from IP-level addressing information to reach that Node-ID lives in the Connection Table ๐บ๏ธ
A peer, x, is responsible for a particular Resource-ID, k, if k is less than or equal to x and k is greater than p, where p is the Node-ID of the previous peer in the Neighbor Table. Be careful with the math here, because all math is modulo 2^128 ๐งฎ
10.2. Hash Function
For this Chord-based Topology Plug-in, the size of the Resource-ID is 128 bits ๐ The hash of a Resource-ID MUST be computed using SHA-1 [RFC3174], and then the SHA-1 result MUST be truncated to the most significant 128 bits ๐
10.3. Routing
The Routing Table is basically the union of the Neighbor Table and the Finger Table ๐งฉ
If a peer is not responsible for a Resource-ID k, but is directly connected to a node with Node-ID k, then it MUST route the message to that node ๐ฏ Otherwise, it MUST route the request to the peer in the Routing Table that has the largest Node-ID in the interval between the peer and k. If no such node is found, the peer finds the smallest Node-ID that is greater than k and MUST route the message to that node ๐
10.4. Redundancy
When a peer gets a Store request for Resource-ID k and it's responsible for Resource-ID k, it MUST store the data and return a success response โ It MUST then send a Store request to its successor in the Neighbor Table and to that peer's successor, incrementing the replica number for each successor ๐ฆ These Store requests are addressed to those specific peers, even though the Resource-ID they're being asked to store is outside the range they're responsible for. The peers receiving them SHOULD check that the request came from an appropriate predecessor in their Neighbor Table and that they're in a range this predecessor is responsible for. Then they MUST store the data ๐ They don't perform further Stores themselves, because they can tell they aren't responsible for the Resource-ID.
Note that this Topology Plug-in doesn't use the replica number for anything other than telling a replica apart from a non-replica ๐ท
Managing replicas as the overlay changes is described in Section 10.7.3.
The sequential replicas used in this overlay algorithm protect against peer failure, but not against malicious peers ๐ Additional replication from the Usage is required to protect resources from such attacks, as discussed in Section 13.5.4. Don't skip this part, it's a whole vibe ๐ก๏ธ
10.5. Joining
The join process for a Joining Node (JN) with Node-ID n goes like this ๐
- JN MUST connect to its chosen bootstrap node, as specified in Section 11.4.
- JN SHOULD send an Attach request to the Admitting Peer (AP) for Resource-ID n+1. The "send_update" flag can be used to acquire the Routing Table of AP ๐ฌ
- JN SHOULD send Attach requests to start connections to each of the peers in the Neighbor Table, as well as to the desired peers in the Finger Table. This doesn't populate their Routing Tables, only their Connection Tables. So JN won't get messages it's supposed to route to other nodes ๐
- JN MUST enter into its Routing Table all the peers it has successfully contacted ๐
- JN MUST send a Join to AP. The AP MUST send the response to the Join ๐
- AP MUST do a series of Store requests to JN to store the data that JN will be responsible for ๐ฆ
- AP MUST send JN an Update explicitly labeling JN as its predecessor. At this point, JN is part of the ring and is responsible for a section of the overlay ๐ AP MAY now forget any data assigned to JN and not AP. AP SHOULD NOT forget any data where AP is in the replica set for that data ๐ซถ
- The AP MUST send an Update to all of its neighbors (including JN) with the new values of its neighbor set (including JN) ๐ฃ
- JN MUST send Updates to all of the peers in its Neighbor Table ๐
If JN sends an Attach to AP with send_update, it immediately learns most of its expected neighbors from AP's Routing Table update, and it MAY directly connect to them. This is the RECOMMENDED procedure โญ
If for some reason JN doesn't get AP's Routing Table, it MAY still populate its Neighbor Table incrementally ๐ข It SHOULD send a Ping directed at Resource-ID n+1, which is directly after its own Resource-ID. This lets JN discover its own successor. Call that node p0. JN then SHOULD send a Ping to p0+1 to discover its successor (p1). This process MAY be repeated to discover as many successors as desired ๐ The values for the two peers before p will be found at a later stage, when n receives an Update. An alternate procedure is to send Attaches to those nodes instead of Pings. That forms the connections immediately, but it may be slower if the nodes need to collect ICE candidates ๐ง
To set up its i'th Finger Table entry, JN MUST send an Attach to peer n+2^(128-i). This gets routed to a peer in approximately the right spot around the ring ๐งญ (Note that the first entry in the Finger Table has i=1 and not i=0 in this formulation. Easy to mix up, so watch out ๐)
The Joining Node MUST NOT send any Update message placing itself in the overlay until it has successfully completed an Attach with each peer that should be in its Neighbor Table. No skipping this step, bestie ๐ซ
10.6. Routing Attaches
When a peer needs to Attach to a new peer in its Neighbor Table, it MUST source-route the Attach request through the peer it learned the new peer's Node-ID from ๐ค๏ธ Source-routing these requests lets the overlay recover from instability ๐ช
All other Attach requests, like those for new Finger Table entries, are routed conventionally through the overlay ๐ฆ
10.7. Updates ๐
okay so an Update for this DHT is defined like this, and the enum is giving main character energy ๐
enum { invalidChordUpdateType(0),
peer_ready(1), neighbors(2), full(3), (255) }
ChordUpdateType;
struct {
uint32 uptime;
ChordUpdateType type;
select (type){
case peer_ready: /* Empty */
;
case neighbors:
NodeId predecessors<0..2^16-1>;
NodeId successors<0..2^16-1>;
case full:
NodeId predecessors<0..2^16-1>;
NodeId successors<0..2^16-1>;
NodeId fingers<0..2^16-1>;
};
} ChordUpdate;
The uptime field holds how long this peer has been up, in seconds โฐ. The type field holds the type of the update, and which type you get depends on why the update was sent ๐
peer_ready : This peer is ready to receive messages ๐ฌ. This one tells everyone that a node which has Attached is a peer and can be routed through. It also doubles as a connectivity check to non-neighbor peers โจ
neighbors : This version goes out to members of the Chord Neighbor Table ๐ซถ
full : This version goes out to peers that ask for an Update with a RouteQueryReq ๐ฅ
If the message is of type neighbors, the contents are:
predecessors : The predecessor set of the Updating peer.
successors : The successor set of the Updating peer.
If the message is of type full, the contents are:
predecessors : The predecessor set of the Updating peer.
successors : The successor set of the Updating peer.
fingers : The Finger Table of the Updating peer, in numerically ascending order ๐ง
Now the rules, bestie ๐. A peer MUST maintain an association (via Attach) to every member of its neighbor set, no excuses ๐. A peer MUST attempt to maintain at least three predecessors and three successors, even though this won't be possible if the ring is very small ๐. It is RECOMMENDED that O(log(N)) predecessors and successors be maintained in the neighbor set ๐ธ. There are lots of ways to estimate N, and some of them are discussed in [DHT-RELOAD] ๐ฆ.
10.7.1. Handling Neighbor Failures
Every single time a connection to a peer in the Neighbor Table is lost (whether connectivity pings or a failed request tells you so), the peer MUST remove that entry from its Neighbor Table and replace it with the best match it has from the other peers in its Routing Table ๐ญ. If using reactive recovery, the peer MUST send an immediate Update to all nodes in its Neighbor Table. That Update contains all the Node-IDs of the current entries of the table, after the failed one has been removed ๐ . Also, when replacing a successor, the peer SHOULD delay creating new replicas for the successor replacement hold-down time (30 seconds) after removing the failed entry from its Neighbor Table. The point is to give a triggered update time to tell it about a better match for its Neighbor Table โญ.
If the neighbor failure affects the peer's range of responsible IDs, then the Update MUST be sent to all nodes in its Connection Table ๐.
A peer MAY attempt to reestablish connectivity with a lost neighbor, either by waiting a bit longer to see if connectivity comes back or by actively routing a new Attach to the lost peer ๐ฆ. The details for these procedures are beyond the scope of this document, so that's a whole other story. When it does try to reestablish connectivity with a lost neighbor, the peer MUST be removed from the Neighbor Table. That peer goes back into the Neighbor Table once connectivity is reestablished ๐.
If connectivity is lost to all successor peers in the Neighbor Table, this peer SHOULD behave as if it is joining the network. It MUST use Pings to find a peer and send it a Join ๐. If connectivity is lost to all the peers in the Finger Table, this peer SHOULD assume it has been disconnected from the rest of the network, and it SHOULD periodically try to join the DHT ๐ฅบ.
10.7.2. Handling Finger Table Entry Failure
If a Finger Table entry is found to have failed (through connectivity pings or a failed request), all references to the failed peer MUST be removed from the Finger Table. Then they get replaced with the closest preceding peer from the Finger Table or Neighbor Table ๐.
If using reactive recovery, the peer MUST initiate a search for a new Finger Table entry, as described below ๐.
10.7.3. Receiving Updates
When a peer x receives an Update request, it looks at the Node-IDs in the UpdateReq and in its Neighbor Table, then decides whether this UpdateReq would change its Neighbor Table ๐. It does this by taking the set of peers currently in the Neighbor Table and comparing them to the peers in the Update request. There are two major cases:
- The UpdateReq contains peers that match x's Neighbor Table, so no change is needed to the neighbor set ๐.
- The UpdateReq contains peers that x doesn't know about and that should be in x's Neighbor Table, meaning they are closer than entries already in the Neighbor Table ๐.
In the first case, no change is needed, easy ๐ซถ.
In the second case, x MUST attempt to Attach to the new peers. If that works, it MUST adjust its neighbor set accordingly โจ. x can keep the now inferior peers as neighbors, but it MUST remember the closer ones ๐ง .
After any Pings and Attaches are done, if the Neighbor Table changes and the peer is using reactive recovery, the peer MUST send an Update request to each member of its Connection Table. These Update requests are what end up filling in the predecessor and successor tables of the peers that this peer is a neighbor to ๐. A peer MUST NOT enter itself in its successor or predecessor table. It should leave those entries empty instead ๐.
If peer x is responsible for a Resource-ID R and x discovers that the replica set for R (the next two nodes in its successor set) has changed, it MUST send a Store for any data associated with R to any new node in the replica set ๐ฆ. It SHOULD NOT delete data from peers which have left the replica set ๐ซ.
When peer x detects that it is no longer in the replica set for a resource R (meaning there are three predecessors between x and R), it SHOULD delete all data associated with R from its local store ๐งน.
When a peer discovers that its range of responsible IDs has changed, it MUST send an Update to all entries in its Connection Table ๐ฃ.
10.7.4. Stabilization
There are four components to stabilization, and each one is a whole vibe ๐:
- Exchange Updates with all peers in its Neighbor Table to exchange state.
- Search for better peers to place in its Finger Table.
- Search to determine if the current Finger Table size is sufficiently large.
- Search to determine if the overlay has partitioned and needs to recover.
10.7.4.1. Updating the Neighbor Table
A peer MUST periodically send an Update request to every peer in its Neighbor Table ๐. The purpose is to keep the predecessor and successor lists up to date and to detect failed peers. The default time is about every ten minutes, but the configuration server SHOULD set this in the Configuration Document using the "chord-update-interval" element (denominated in seconds) โฑ๏ธ. A peer SHOULD randomly offset these Update requests so they don't all happen at once ๐ฒ.
10.7.4.2. Refreshing the Finger Table
A peer MUST periodically search for new peers to replace invalid entries in the Finger Table ๐. For peer x, the i'th Finger Table entry is valid if it is in the range [ x+2^( 128-i ), x+2^( 128-(i-1) )-1 ]. Invalid entries show up in the Finger Table when a previous Finger Table entry has failed, or when no peer has been found in that range ๐ฅ.
Two possible methods for searching for new peers for the Finger Table entries are presented ๐ :
Alternative 1: A peer selects one entry in the Finger Table from among the invalid entries. It pings for a new peer for that Finger Table entry. The selection SHOULD be exponentially weighted to attempt to replace earlier (lower i) entries in the Finger Table. A simple way to implement this selection is to search through the Finger Table entries from i=1, and each time an invalid entry is encountered, send a Ping to replace that entry with probability 0.5 ๐ฐ.
Alternative 2: A peer monitors the Update messages received from its connections to observe when an Update indicates a peer that would be used to replace an invalid Finger Table entry, i, and flags that entry in the Finger Table. Every "chord-ping-interval" seconds, the peer selects from among those flagged candidates using an exponentially weighted probability, as above ๐ฉ.
When searching for a better entry, the peer SHOULD send the Ping to a Node-ID selected randomly from that range ๐ฏ. Random selection is preferred over a search for strictly spaced entries, because it minimizes the effect of churn on overlay routing [minimizing-churn-sigcomm06] ๐. An implementation or subsequent specification MAY choose a method for selecting Finger Table entries other than choosing randomly within the range ๐งฉ. Any such alternate methods SHOULD be employed only on Finger Table stabilization, and not for the selection of initial Finger Table entries, unless the alternative method is faster and imposes less overhead on the overlay ๐.
A peer SHOULD NOT send Ping requests looking for new Finger Table entries more often than the configuration element "chord-ping-interval", which defaults to 3600 seconds (one per hour) ๐.
A peer MAY choose to keep connections to multiple peers that can act for a given Finger Table entry ๐ซ.
10.7.4.3. Adjusting Finger Table Size
If the Finger Table has fewer than 16 entries, the node SHOULD attempt to discover more fingers to grow the table to 16 entries ๐. The value 16 was chosen to ensure high odds of a node maintaining connectivity to the overlay, even with strange network partitions ๐ก๏ธ.
For many overlays, 16 Finger Table entries will be enough. But as an overlay grows very large, more than 16 entries may be required in the Finger Table for efficient routing. An implementation SHOULD be capable of increasing the number of entries in the Finger Table to 128 entries ๐.
Although log(N) entries are all that are required for optimal performance, careful implementation of stabilization results in no additional traffic being generated when maintaining a Finger Table larger than log(N) entries ๐คฏ. Implementers are encouraged to make use of RouteQuery and algorithms for determining where new Finger Table entries may be found. Complete details of possible implementations are outside the scope of this specification ๐.
A simple approach to sizing the Finger Table is to make sure it is large enough to contain at least the final successor in the peer's Neighbor Table โ .
10.7.4.4. Detecting Partitioning ๐
okay so bestie, this is how you spot a partition and heal the overlay ๐ฉน. A peer P MUST periodically repeat the discovery process it used during its initial join to find an appropriate bootstrap node, B. ๐ P SHOULD then send a Ping for its own Node-ID, routed through B. If it gets a response from peer S', and S' is not P's successor, then the overlay is partitioned ๐ฑ. In that case P SHOULD send an Attach to S', routed through B, and then an Update to S'. โจ
ngl, S' might not be in P's Neighbor Table once everything is healed, but the connection still lets S' find its own good neighbor entries through its own stabilization ๐ซถ.
Future specifications may describe other ways to decide when to repeat the discovery process ๐.
10.8. Route Query f.in 3 ๐
For CHORD-RELOAD, the RouteQueryReq contains no additional information ๐. The RouteQueryAns contains a single Node-ID: the next peer that the responding peer would have routed the request message to during recursive routing ๐ง.
struct {
NodeId next_peer;
} ChordRouteQueryAns;
Here's what those fields mean:
next_peer: the peer to which the responding peer would route the message, so it can deliver it to the destination listed in the request.
If the requester has set the send_update flag, the responder SHOULD initiate an Update immediately after sending the RouteQueryAns ๐ฆ.
10.9. Leaving ๐
To support extensions like [DHT-RELOAD] ๐ธ, peers SHOULD send a Leave request to all members of their Neighbor Table before they exit the Overlay Instance. The overlay_specific_data field MUST contain the ChordLeaveData structure, which is defined below ๐.
enum { invalidChordLeaveType(0),
from_succ(1), from_pred(2), (255) }
ChordLeaveType;
struct {
ChordLeaveType type;
select (type) {
case from_succ:
NodeId successors<0..2^16-1>;
case from_pred:
NodeId predecessors<0..2^16-1>;
};
} ChordLeaveData;
The type field tells the recipient whether the Leave request came from its predecessor or its successor ๐:
from_succ: the Leave request was sent by a successor.from_pred: the Leave request was sent by a predecessor.
If the type is "from_succ", the contents will be:
successors: the sender's successor list.
If the type is "from_pred", the contents will be:
predecessors: the sender's predecessor list.
๐จ Any peer that receives a Leave for a peer n in its neighbor set MUST follow the procedures as if it had detected a peer failure, as described in Section 10.7.1. No skipping this part, bestie!
11. Enrollment and Bootstrap ๐
This section defines the format of the configuration data, and it also covers the process for joining a new overlay ๐งโโ๏ธ.
11.1. Overlay Configuration ๐
This specification defines a new content type, "application/p2p-overlay+xml" ๐ , for a MIME entity that contains overlay information. Here's an example document ๐:
<?xml version="1.0" encoding="UTF-8"?>
<overlay xmlns="urn:ietf:params:xml:ns:p2p:config-base"
xmlns:ext="urn:ietf:params:xml:ns:p2p:config-ext1"
xmlns:chord="urn:ietf:params:xml:ns:p2p:config-chord">
<configuration instance-name="overlay.example.org" sequence="22"
expiration="2002-10-10T07:00:00Z" ext:ext-example="stuff" >
<topology-plugin> CHORD-RELOAD </topology-plugin>
<node-id-length>16</node-id-length>
<root-cert>
MIIDJDCCAo2gAwIBAgIBADANBgkqhkiG9w0BAQUFADBwMQswCQYDVQQGEwJVUzET
MBEGA1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxMIU2FuIEpvc2UxDjAMBgNVBAoT
BXNpcGl0MSkwJwYDVQQLEyBTaXBpdCBUZXN0IENlcnRpZmljYXRlIEF1dGhvcml0
eTAeFw0wMzA3MTgxMjIxNTJaFw0xMzA3MTUxMjIxNTJaMHAxCzAJBgNVBAYTAlVT
MRMwEQYDVQQIEwpDYWxpZm9ybmlhMREwDwYDVQQHEwhTYW4gSm9zZTEOMAwGA1UE
ChMFc2lwaXQxKTAnBgNVBAsTIFNpcGl0IFRlc3QgQ2VydGlmaWNhdGUgQXV0aG9y
aXR5MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDDIh6DkcUDLDyK9BEUxkud
+nJ4xrCVGKfgjHm6XaSuHiEtnfELHM+9WymzkBNzZpJu30yzsxwfKoIKugdNUrD4
N3viCicwcN35LgP/KnbN34cavXHr4ZlqxH+OdKB3hQTpQa38A7YXdaoz6goW2ft5
Mi74z03GNKP/G9BoKOGd5QIDAQABo4HNMIHKMB0GA1UdDgQWBBRrRhcU6pR2JYBU
bhNU2qHjVBShtjCBmgYDVR0jBIGSMIGPgBRrRhcU6pR2JYBUbhNU2qHjVBShtqF0
pHIwcDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExETAPBgNVBAcT
CFNhbiBKb3NlMQ4wDAYDVQQKEwVzaXBpdDEpMCcGA1UECxMgU2lwaXQgVGVzdCBD
ZXJ0aWZpY2F0ZSBBdXRob3JpdHmCAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0B
AQUFAAOBgQCWbRvv1ZGTRXxbH8/EqkdSCzSoUPrs+rQqR0xdQac9wNY/nlZbkR3O
qAezG6Sfmklvf+DOg5RxQq/+Y6I03LRepc7KeVDpaplMFGnpfKsibETMipwzayNQ
QgUf4cKBiF+65Ue7hZuDJa2EMv8qW4twEhGDYclpFU9YozyS1OhvUg==
</root-cert>
<root-cert> YmFkIGNlcnQK </root-cert>
<enrollment-server>https://example.org</enrollment-server>
<enrollment-server>https://example.net</enrollment-server>
<self-signed-permitted
digest="sha1">false</self-signed-permitted>
<bootstrap-node address="192.0.0.1" port="6084" />
<bootstrap-node address="192.0.2.2" port="6084" />
<bootstrap-node address="2001:DB8::1" port="6084" />
<turn-density> 20 </turn-density>
<clients-permitted> false </clients-permitted>
<no-ice> false </no-ice>
<chord:chord-update-interval>
400</chord:chord-update-interval>
<chord:chord-ping-interval>30</chord:chord-ping-interval>
<chord:chord-reactive> true </chord:chord-reactive>
<shared-secret> password </shared-secret>
<max-message-size>4000</max-message-size>
<initial-ttl> 30 </initial-ttl>
<overlay-reliability-timer> 3000 </overlay-reliability-timer>
<overlay-link-protocol>TLS</overlay-link-protocol>
<configuration-signer>47112162e84c69ba</configuration-signer>
<kind-signer> 47112162e84c69ba </kind-signer>
<kind-signer> 6eba45d31a900c06 </kind-signer>
<bad-node> 6ebc45d31a900c06 </bad-node>
<bad-node> 6ebc45d31a900ca6 </bad-node>
<ext:example-extension> foo </ext:example-extension>
<mandatory-extension>
urn:ietf:params:xml:ns:p2p:config-ext1
</mandatory-extension>
<required-kinds>
<kind-block>
<kind name="SIP-REGISTRATION">
<data-model>SINGLE</data-model>
<access-control>USER-MATCH</access-control>
<max-count>1</max-count>
<max-size>100</max-size>
</kind>
<kind-signature>
VGhpcyBpcyBub3QgcmlnaHQhCg==
</kind-signature>
</kind-block>
<kind-block>
<kind id="2000">
<data-model>ARRAY</data-model>
<access-control>NODE-MULTIPLE</access-control>
<max-node-multiple>3</max-node-multiple>
<max-count>22</max-count>
<max-size>4</max-size>
<ext:example-kind-extension> 1
</ext:example-kind-extension>
</kind>
<kind-signature>
VGhpcyBpcyBub3QgcmlnaHQhCg==
</kind-signature>
</kind-block>
</required-kinds>
</configuration>
<signature> VGhpcyBpcyBub3QgcmlnaHQhCg== </signature>
<configuration instance-name="other.example.net">
</configuration>
<signature> VGhpcyBpcyBub3QgcmlnaHQhCg== </signature>
</overlay>
The file MUST be a well-formed XML document, and it SHOULD contain an encoding declaration in the XML declaration ๐. The file MUST use the UTF-8 character encoding ๐ธ. The namespaces for the elements defined in this specification are urn:ietf:params:xml:ns:p2p:config-base and urn:ietf:params:xml:ns:p2p:config-chord ๐.
Heads up: elements or attributes defined as xsd:boolean in the RELAX NG schema (Section 11.1.1) have two lexical forms. "1" or "true" means true, and "0" or "false" means false ๐ฆ. Whitespace and case handling follow the rules of [OASIS.relax_ng] and XML Schema Datatypes [W3C.REC-xmlschema-2-20041028] ๐.
The file MAY contain multiple "configuration" elements, and each one holds the configuration information for a different overlay ๐ง. Each configuration element MAY be followed by signature elements that provide a signature over the preceding configuration element ๐. Each configuration element has the following attributes:
instance-name: the name of the overlay, which this specification calls the "overlay name" ๐ท๏ธ.expiration: the time in the future at which this overlay configuration is no longer valid โณ. The node SHOULD retrieve a new copy of the configuration at a randomly selected time that is before the expiration time. Heads up: if the certificates expire before a new configuration is retrieved, the node won't be able to validate the configuration file ๐ฌ. All times MUST conform to the Internet date/time format defined in [RFC3339] and be specified using UTC โฐ.sequence: a monotonically increasing sequence number between 0 and 2^16-2 ๐ข.
Inside each overlay element, the following elements can occur ๐ :
topology-plug-in: defines the overlay algorithm being used. If it's missing, the default is "CHORD-RELOAD" ๐งฉ.node-id-length: the length of a NodeId (NodeIdLength), in bytes. This value MUST be between 16 (128 bits) and 20 (160 bits). If this element is not present, the default of 16 is used ๐.root-cert: a base-64-encoded X.509v3 certificate that acts as a root trust anchor, used to sign all certificates in this overlay ๐. There can be more than oneroot-certelement ๐.enrollment-server: the URL where the enrollment server can be reached, given in a "url" element. This URL MUST be of type "https:" ๐. More than oneenrollment-serverelement MAY be present. Note that there is no necessary relationship between the overlay name or configuration server name and the enrollment server name ๐.self-signed-permitted: indicates whether self-signed certificates are permitted ๐ชช. If it's set to "true", self-signed certificates are allowed, and in that case theenrollment-serverandroot-certelements MAY be absent. Otherwise, it SHOULD be absent, but it MAY be set to "false" โจ. This element also has an attribute, "digest", which indicates the digest used to compute the Node-ID. Valid values are "sha1" and "sha256", representing SHA-1 [RFC3174] and SHA-256 [RFC6234], respectively ๐งฎ. Implementations MUST support both of these algorithms ๐ช.bootstrap-node: the address of one of the bootstrap nodes ๐. It has an attribute called "address", which is the IP address (either IPv4 or IPv6, since they can be told apart). It also has an optional attribute called "port", which is the port and defaults to 6084. The IPv6 address uses the typical hexadecimal form with standard period and colon separators, as specified in [RFC5952] ๐. More than onebootstrap-nodeelement MAY be present ๐ซถ.
okay so picture this: we're still in the Overlay Configuration bit, and there are a bunch of config knobs that just make the whole overlay work ๐โจ
turn-density๐ is a positive integer that's basically the approximate reciprocal of how dense the TURN-capable nodes are. Like, if 5% of nodes can act as TURN servers, you'd set this to20. If it's not there, the default is1. And if there are no TURN servers in the overlay at all, it gets set to zero ๐clients-permitted๐ฆ is about whether clients are allowed, or whether everyone has to be a peer. If clients are permitted, this MUST be set to"true"or be absent. If nodes aren't allowed to stay clients after their initial join, it MUST be set to"false". ngl the overlay has no way to enforce this right now ๐no-ice๐ธ says whether nodes are REQUIRED to use the"No-ICE"Overlay Link protocols in this overlay. If it's absent, it's treated like it was set to"false".chord-update-interval๐ง is the update frequency for the CHORD-RELOAD Topology Plug-in (see Section 10).chord-ping-interval๐ is the Ping frequency for that same CHORD-RELOAD Topology Plug-in (see Section 10).chord-reactiveโญ is whether reactive recovery SHOULD be used for this overlay. It's"true"or"false", and if it's missing, the default is"true"(see Section 10).shared-secret๐ shows up only in shared secret mode, and it holds the shared secret. The security guarantee here is kinda vibes-based: any agent that can get to the Configuration Document (probably locked down by some HTTP access control or network topology) can recover the shared secret and therefore join the overlay. ๐max-message-size๐ is the maximum size, in bytes, of any message in the overlay. If it's not present, the default is5000.initial-ttl๐ is the initial default TTL for messages (see Section 6.3.2). If it's not present, the default is100.overlay-reliability-timerโฑ๏ธ is the default value for the end-to-end retransmission timer for messages, in milliseconds. If it's not present, the default is3000. The value MUST be at least200milliseconds, which means the minimum time before dropping a link is1000milliseconds ๐ซถoverlay-link-protocol๐ฆ indicates a permissible overlay link protocol (see Section 6.6.1 for the requirements for those). You can have as many of these as you want. If none appear, the implied default is"TLS", which means TLS and DTLS. But if one or more show up, then no default applies at all, so be intentional ๐kind-signer๐ contains a single Node-ID in hexadecimal and says that the certificate with that Node-ID is allowed to sign Kinds. Identifying the signer by Node-ID instead of by certificate means you can use short-lived certificates without constantly needing to hand out an updated configuration file. big brain move ๐งconfiguration-signer๐ contains a single Node-ID in hexadecimal and says that the certificate with that Node-ID is allowed to sign configurations for this instance-name. Same deal: identifying the signer by Node-ID instead of certificate lets you use short-lived certificates without re-sending the configuration file all the time โจbad-node๐ซ contains a single Node-ID in hexadecimal and says that the certificate with that Node-ID MUST NOT be considered valid. This is how certificate revocation works here ๐ โโ๏ธ You can include an arbitrary number of these. Because certificates may expire, bad-node entries only need to be present for the lifetime of the certificate. Technically, bad Node-IDs could be reused after their certificates expire, but since Node-IDs are supposed to be pseudorandomly generated, that's a vanishingly small probability ๐ธmandatory-extension๐งโโ๏ธ contains the name of an XML namespace that a node joining the overlay MUST support. Having one doesn't mean the extension has to be used in the current configuration file, but it can hint that it might be used later. The namespace is case-sensitive, as specified in Section 2.3 of [w3c-xml-namespaces]. More than onemandatory-extensionelement MAY be present.
Inside each configuration element, the required-kinds element MAY also occur ๐ It says which Kinds members MUST support, and it has multiple kind-block elements, each defining a single Kind that MUST be supported by nodes in the overlay. Each kind-block has one kind element and one kind-signature. The kind element defines the Kind, and the kind-signature is the signature computed over the kind element.
Each kind element has either an id attribute or a name attribute. The name is a string representing the Kind (the name registered to IANA), while the id is an integer Kind-ID allocated out of private space ๐
On top of that, the kind element MUST contain these elements:
max-count๐ข is the maximum number of values that members of the overlay must support.data-model๐ฆ is the data model to be used.max-size๐ is the maximum size of individual values.access-control๐ is the access control model to be used.
The kind element MAY also contain this element:
max-node-multipleโจ If the access control is NODE-MULTIPLE, this element MUST be included. It indicates the maximum value for theicounter, and it MUST be an integer greater than0.
All of the non-optional values MUST be provided. If the Kind is registered with IANA, the data-model and access-control elements MUST match those in the Kind registration, and clients MUST ignore them in favor of the IANA versions ๐ Multiple kind-block elements MAY be present.
The kind-block element also MUST contain a kind-signature element. This signature is computed across the kind element, from the beginning of the first < of the kind element to the end of the last > of the kind element, in the same way as the signature element described later in this section. kind-block elements MUST be signed by a node listed in the kind-signers block of the current configuration. Receivers MUST verify the signature before accepting a kind-block ๐ฅ
The configuration element MUST be treated as a binary blob that cannot be changed, including any whitespace changes, or the signature will break ๐ The signature MUST be computed by taking each configuration element, starting from and including the first < at the start of <configuration>, up to and including the > in </configuration>, and treating that as a binary blob that MUST be signed using the standard SecurityBlock defined in Section 6.3.4. The SecurityBlock MUST be base-64 encoded using the base64 alphabet from [RFC4648], and MUST be put in the signature element following the configuration object in the configuration file. Any configuration file MUST be signed by one of the configuration-signer elements from the previous extant configuration. Recipients MUST verify the signature before accepting the configuration file ๐ซถ
When a node receives a new configuration file, it MUST change its configuration to meet the new requirements. This may require the node to exit the DHT and rejoin. If a node isn't capable of supporting the new requirements, it MUST exit the overlay ๐ญ If some information about a particular Kind changes from what the node previously knew (for example, the max size), the new information in the configuration files overrides whatever was learned before. If any Kind data was signed by a node that is no longer allowed to sign Kinds, that Kind MUST be discarded, along with any stored information about that Kind ๐๏ธ
Note that forcing an avalanche restart of the overlay with a configuration change that requires rejoining may result in serious performance problems, including total collapse of the network if configuration parameters aren't properly considered. Such an event may be necessary in case of a compromised CA or a similar problem, but for large overlays it should be avoided in almost all circumstances. Be careful with this one, bestie, it's giving disaster ๐จ
11.1.1. RELAX NG Grammar โจ
Okay so here's the big grammar for the configuration data ๐ It's basically the blueprint that tells you what a valid config file looks like, bestie ๐
namespace chord = "urn:ietf:params:xml:ns:p2p:config-chord"
namespace local = ""
default namespace p2pcf = "urn:ietf:params:xml:ns:p2p:config-base"
namespace rng = "http://relaxng.org/ns/structure/1.0"
anything =
(element * { anything }
| attribute * { text }
| text)*
foreign-elements = element * - (p2pcf:* | local:* | chord:*)
{ anything }*
foreign-attributes = attribute * - (p2pcf:*|local:*|chord:*)
{ text }*
foreign-nodes = (foreign-attributes | foreign-elements)*
start = element p2pcf:overlay {
overlay-element
}
overlay-element &= element configuration {
attribute instance-name { xsd:string },
attribute expiration { xsd:dateTime }?,
attribute sequence { xsd:long }?,
foreign-attributes*,
parameter
}+
overlay-element &= element signature {
attribute algorithm { signature-algorithm-type }?,
xsd:base64Binary
}*
signature-algorithm-type |= "rsa-sha1"
signature-algorithm-type |= xsd:string # signature alg extensions
parameter &= element topology-plugin { topology-plugin-type }?
topology-plugin-type |= xsd:string # topo plugin extensions
parameter &= element max-message-size { xsd:unsignedInt }?
parameter &= element initial-ttl { xsd:int }?
parameter &= element root-cert { xsd:base64Binary }*
parameter &= element required-kinds { kind-block* }?
parameter &= element enrollment-server { xsd:anyURI }*
parameter &= element kind-signer { xsd:string }*
parameter &= element configuration-signer { xsd:string }*
parameter &= element bad-node { xsd:string }*
parameter &= element no-ice { xsd:boolean }?
parameter &= element shared-secret { xsd:string }?
parameter &= element overlay-link-protocol { xsd:string }*
parameter &= element clients-permitted { xsd:boolean }?
parameter &= element turn-density { xsd:unsignedByte }?
parameter &= element node-id-length { xsd:int }?
parameter &= element mandatory-extension { xsd:string }*
parameter &= foreign-elements*
parameter &=
element self-signed-permitted {
attribute digest { self-signed-digest-type },
xsd:boolean
}?
self-signed-digest-type |= "sha1"
self-signed-digest-type |= xsd:string # signature digest extensions
parameter &= element bootstrap-node {
attribute address { xsd:string },
attribute port { xsd:int }?
}*
kind-block = element kind-block {
element kind {
( attribute name { kind-names }
| attribute id { xsd:unsignedInt } ),
kind-parameter
} &
element kind-signature {
attribute algorithm { signature-algorithm-type }?,
xsd:base64Binary
}?
}
kind-parameter &= element max-count { xsd:int }
kind-parameter &= element max-size { xsd:int }
kind-parameter &= element max-node-multiple { xsd:int }?
kind-parameter &= element data-model { data-model-type }
data-model-type |= "SINGLE"
data-model-type |= "ARRAY"
data-model-type |= "DICTIONARY"
data-model-type |= xsd:string # data model extensions
kind-parameter &= element access-control { access-control-type }
access-control-type |= "USER-MATCH"
access-control-type |= "NODE-MATCH"
access-control-type |= "USER-NODE-MATCH"
access-control-type |= "NODE-MULTIPLE"
access-control-type |= xsd:string # access control extensions
kind-parameter &= foreign-elements*
kind-names |= "TURN-SERVICE"
kind-names |= "CERTIFICATE_BY_NODE"
kind-names |= "CERTIFICATE_BY_USER"
kind-names |= xsd:string # kind extensions
# Chord specific parameters
topology-plugin-type |= "CHORD-RELOAD"
parameter &= element chord:chord-ping-interval { xsd:int }?
parameter &= element chord:chord-update-interval { xsd:int }?
parameter &= element chord:chord-reactive { xsd:boolean }?
11.2. Discovery through Configuration Server ๐
When a node first enrolls in a new overlay ๐ฆ, it kicks off a discovery process to hunt down a configuration server.
The node MAY start by figuring out the overlay name ๐ That value MUST be provided by the user or some other out-of-band provisioning mechanism ๐ธ That out-of-band mechanism MAY also hand over an optional URL for the configuration server โจ
If a URL for the configuration server is not provided, the node MUST do a DNS SRV query using a Service name of reload-config and a protocol of TCP to find a configuration server, and then form the URL by appending a path of /.well-known/reload-config to the overlay name. This uses the "well-known URI" framework defined in [RFC5785]. For example, if the overlay name was example.com, the URL would be https://example.com/.well-known/reload-config ๐ง
Once an address and URL for the configuration server are determined, the peer MUST form an HTTPS connection to that IP address. If an optional URL for the configuration server was provided, the certificate MUST match the domain name from the URL as described in [RFC2818]; otherwise, the certificate MUST match the overlay name as described in [RFC2818]. If the HTTPS certificates pass the name matching, the node MUST fetch a new copy of the configuration file. To do this, the peer performs a GET to the URL. The result of the HTTP GET is an XML configuration file described above. If the XML is not valid or the instance-name attribute of the overlay-element in the XML does not match the overlay name, this configurations file SHOULD be discarded. Otherwise, the new configuration MUST replace any previously learned configuration file for this overlay. It's a whole chain of checks, bestie, and every link matters ๐
For overlays that do not use a configuration server, nodes MUST obtain the configuration information needed to join the overlay through some out-of-band approach, such as an XML configuration file sent over email ๐ง
11.3. Credentials ๐
If the Configuration Document contains an enrollment-server element, credentials are REQUIRED to join the Overlay Instance. A peer which does not yet have credentials MUST contact the enrollment server to acquire them. Main character energy ๐
RELOAD defines its own trivial certificate request protocol. We would have liked to use an existing protocol, but we were concerned about the implementation burden of even the simplest of those, such as [RFC5272] and [RFC5273]. The objective was a protocol that could be easily implemented in a Web server which the operator did not control (e.g., in a hosted service) and which was compatible with the existing certificate-handling tooling used with the Web certificate infrastructure. This means accepting bare PKCS#10 requests and returning a single bare X.509 certificate. Although the MIME types for these objects are defined, none of the existing protocols support exactly this model ๐
The certificate request protocol MUST be performed over HTTPS. The server certificate MUST match the overlay name as described in [RFC2818]. The request MUST be an HTTP POST with the parameters encoded as described in [RFC2388] and with the following properties:
- If authentication is required, there MUST be form parameters of
passwordandusernamecontaining the user's account name and password in the clear (hence the need for HTTPS). The username and password strings MUST be UTF-8 strings compared as binary objects. Applications using RELOAD SHOULD define any needed string preparation as per [RFC4013] or its successor documents. - If more than one Node-ID is required, there MUST be a form parameter of
nodeidscontaining the number of Node-IDs required. - There MUST be a form parameter of
csrwith a content type ofapplication/pkcs10, as defined in [RFC2311], that contains the certificate signing request (CSR). - The Accept header MUST contain the type
application/pkix-cert, indicating the type that is expected in the response.
The enrollment server MUST authenticate the request using the provided account name and password. The reason for using the RFC 2388 "multipart/form-data" encoding is so that the password parameter will not be encoded in the URL, to reduce the chance of accidental leakage of the password ๐ซถ If the authentication succeeds and the requested user name in the CSR is acceptable, the server MUST generate and return a certificate for the CSR in the "csr" parameter of the request. The SubjectAltName field in the certificate MUST contain the following values:
- One or more Node-IDs which MUST be cryptographically random [RFC4086]. Each MUST be chosen by the enrollment server in such a way that it is unpredictable to the requesting user. For example, the user MUST NOT be informed of potential (random) Node-IDs prior to authenticating. Each is placed in the subjectAltName using the uniformResourceIdentifier type, each MUST contain RELOAD URI, as described in Section 14.15, and each MUST contain a Destination List with a single entry of type "node_id". The enrollment server SHOULD maintain a mapping of users to Node-IDs and if the same user returns (e.g., to have their certificate re-issued), the enrollment server should return the same Node-IDs, thus avoiding the need for implementations to re-store all their data when their certificates expire. ๐ฆ
- A single name (the "user name") that this user is allowed to use in the overlay, using type rfc822Name. Enrollment servers SHOULD take care to allow only legal characters in the name (e.g., no embedded NULs), rather than simply accepting any name provided by the user. In some usages, the right side of the user name will match the overlay name, but there is no requirement for this match in this specification. Applications using this specification MAY define such a requirement or MAY otherwise limit the allowed range of allowed user names.
The SubjectAltName field in the certificate MUST NOT contain any identities other than those listed above. The subject distinguished name in the certificate MUST be empty.
The certificate MUST be returned as type "application/pkix-cert", as defined in [RFC2585], with an HTTP status code of 200 OK. โ
Certificate processing errors SHOULD result in an HTTP return code of 403 Forbidden, along with a body of type "text/plain" and a body that consists of one of the tokens defined in the following list:
failed_authentication: The account name and password combination used in the HTTPS request was not valid.username_not_available: The requested user name in the CSR was not acceptable.Node-IDs_not_available: The number of Node-IDs requested was not acceptable.bad_CSR: There was some other problem with the CSR.
If the client receives an unknown token in the body, it SHOULD treat it as a failure for an unknown reason ๐คท
The client MUST check that the returned certificate chains back to one of the certificates received in the "root-cert" list of the overlay configuration data (including PKIX BasicConstraints checks). The node then reads the certificate to find the Node-ID it can use. Certificate chain verified, the vibes are immaculate ๐
11.3.1. Self-Generated Credentials ๐
okay so if the "self-signed-permitted" element is in the configuration and it's set to "true", then a node MUST generate its own self-signed certificate to join the overlay ๐ the certificate MAY contain any user name the user picks, bestie โจ
for self-signed certificates with only one Node-ID, the Node-ID MUST be computed by running the digest from the self-signed-permitted element over the DER representation of the user's public key (specifically the subjectPublicKeyInfo) and then taking the high-order bits ๐งฎ if the cert has multiple Node-IDs, the index of the Node-ID (counting from 1 up to however many Node-IDs are needed) must be prepended as a 4-byte big-endian integer to the DER representation of the public key, and then you take the high-order bits ๐ธ when a node accepts a self-signed certificate, nodes MUST check that the Node-ID and public keys match. this is how Node-ID theft gets prevented ๐ก๏ธ๐ฅบ
once the node has built its self-signed certificate, it MAY join the overlay ๐ฆ it MUST store its certificate in the overlay (Section 8), but it SHOULD check whether the user name is already taken and, if it is, pick a different one ๐ ngl this only protects against accidental name collisions. name theft is still totally possible ๐ if you want real protection against name theft, then the enrollment service MUST be used ๐
the vibe check: self-signed credentials only guard against accidental name clashes. if someone is actively trying to steal a name, you need the enrollment service. no cap ๐จ
11.4. Contacting a Bootstrap Node ๐ช
okay, to join the overlay, the Joining Node MUST contact a node that's already in it ๐ซถ usually that means reaching out to the bootstrap nodes, since they're either reachable by the local peer or have public IP addresses ๐ if the Joining Node has a cached list of peers it was previously connected with in this overlay, it MAY try those as bootstrap nodes first as a little optimization โญ and if that doesn't work, it falls back to the bootstrap nodes listed in the configuration file ๐
when the Joining Node contacts a bootstrap node, it MUST first set up the DTLS or TLS connection to that bootstrap node, and then send an Attach request over that connection, with the destination Resource-ID set to the Joining Node's Node-ID plus 1 ๐
when the requester node finally hears back from some responding node, it MUST use the Node-ID in that response to start sending requests to join the Overlay Instance, as described in Section 6.4 ๐ง
once a node has successfully joined the overlay, it'll have direct connections to several peers ๐ some of those MAY get added to the cached bootstrap nodes list and reused on future boots ๐ peers that aren't directly connected MUST NOT be cached ๐ โโ๏ธ the suggested number of peers to cache is 10 โจ how you pick which peers to cache is beyond the scope of this spec, so that's a vibe for another day ๐
12. Message Flow Example ๐ง
okay, first the cast ๐ญ the abbreviations in the message flow diagrams are: JN = Joining Node, AP = Admitting Peer, NP = next peer after the AP, NNP = next next peer (the peer after NP), PP = previous peer before the AP, PPP = previous previous peer (the peer before the PP), and BP = bootstrap node ๐
in this example, we assume JN has already formed a connection to one of the bootstrap nodes ๐ธ JN then sends an Attach through that peer to a Resource-ID of itself plus 1 (JN+1) ๐ฆ it gets routed to the AP, because JN isn't part of the overlay yet ๐ฅน when the AP responds, JN and the AP use ICE to set up a connection and then set up DTLS ๐ฅ once AP is connected to JN, AP sends JN an Update so JN can fill up its Routing Table ๐ the example shows the Update happening after the DTLS connection is formed, but it could also happen before that, in which case the Update would often get routed through other nodes ๐บ๏ธ
JN PPP PP AP NP NNP BP
| | | | | | |
| | | | | | |
| | | | | | |
|AttachReq Dest=JN+1| | | | |
|---------------------------------------------------------->|
| | | | | | |
| | | | | | |
| | | |AttachReq Dest=JN+1| |
| | | |<----------------------------|
| | | | | | |
| | | | | | |
| | | |AttachAns | |
| | | |---------------------------->|
| | | | | | |
| | | | | | |
|AttachAns | | | | |
|<----------------------------------------------------------|
| | | | | | |
|ICE | | | | | |
|<===========================>| | | |
| | | | | | |
|TLS | | | | | |
|<...........................>| | | |
| | | | | | |
| | | | | | |
| | | | | | |
|UpdateReq| | | | | |
|<----------------------------| | | |
| | | | | | |
| | | | | | |
|UpdateAns| | | | | |
|---------------------------->| | | |
| | | | | | |
| | | | | | |
| | | | | | |
Figure 1
next up, JN forms connections to the right neighbors, like NP ๐งฉ it does this by sending an Attach that gets routed through other nodes ๐ฃ๏ธ when NP responds, JN and NP use ICE and DTLS to get connected ๐ค
JN PPP PP AP NP NNP BP
| | | | | | |
| | | | | | |
| | | | | | |
|AttachReq NP | | | | |
|---------------------------->| | | |
| | | | | | |
| | | | | | |
| | | |AttachReq NP | |
| | | |-------->| | |
| | | | | | |
| | | | | | |
| | | |AttachAns| | |
| | | |<--------| | |
| | | | | | |
| | | | | | |
|AttachAns| | | | | |
|<----------------------------| | | |
| | | | | | |
| | | | | | |
|ICE | | | | | |
|<=====================================>| | |
| | | | | | |
| | | | | | |
|TLS | | | | | |
|<.....................................>| | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
Figure 2
JN also needs to fill up its Finger Table (for the Chord-based DHT) ๐งญ so it sends Attach requests to a bunch of spots around the overlay ๐ the diagram below shows JN sending an Attach halfway around the Chord ring, to JN + 2^127 ๐
JN NP XX TP
| | | |
| | | |
| | | |
|AttachReq JN+2<<126| |
|-------->| | |
| | | |
| | | |
| |AttachReq JN+2<<126|
| |-------->| |
| | | |
| | | |
| | |AttachReq JN+2<<126
| | |-------->|
| | | |
| | | |
| | |AttachAns|
| | |<--------|
| | | |
| | | |
| |AttachAns| |
| |<--------| |
| | | |
| | | |
|AttachAns| | |
|<--------| | |
| | | |
|ICE | | |
|<===========================>|
| | | |
|TLS | | |
|<...........................>|
| | | |
| | | |
Figure 3
once JN has a decent set of connections, it's ready to take its spot in the DHT ๐ it does that by sending a Join to AP ๐ AP sends JN a series of Store requests so JN gets the data it'll be responsible for ๐ฆ then AP sends JN an Update that explicitly labels JN as its predecessor ๐ at this point JN is officially part of the ring and is responsible for a section of the overlay ๐ฅณ AP can now forget any data that's assigned to JN and not to AP ๐งนโจ
the glow-up is complete, the ring has a new member, and the data is sorted!! ๐๐
12. Message Flow Example (continued)
JN PPP PP AP NP NNP BP
| | | | | | |
| | | | | | |
| | | | | | |
|JoinReq | | | | | |
|---------------------------->| | | |
| | | | | | |
| | | | | | |
|JoinAns | | | | | |
|<----------------------------| | | |
| | | | | | |
| | | | | | |
|StoreReq Data A | | | | |
|<----------------------------| | | |
| | | | | | |
| | | | | | |
|StoreAns | | | | | |
|---------------------------->| | | |
| | | | | | |
| | | | | | |
|StoreReq Data B | | | | |
|<----------------------------| | | |
| | | | | | |
| | | | | | |
|StoreAns | | | | | |
|---------------------------->| | | |
| | | | | | |
| | | | | | |
|UpdateReq| | | | | |
|<----------------------------| | | |
| | | | | | |
| | | | | | |
|UpdateAns| | | | | |
|---------------------------->| | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
Figure 4
okay so in Chord, JN's Neighbor Table has to hold its own predecessors ๐ฆ it couldn't connect to them before because it didn't know their addresses yet ๐ญ but now that it's gotten an Update from AP (see the diagram above), it has AP's predecessors, which are also its own, so it sends Attaches to them โจ below, it only connects to AP's closest predecessor, PP ๐
JN PPP PP AP NP NNP BP
| | | | | | |
| | | | | | |
| | | | | | |
|AttachReq Dest=PP | | | | |
|---------------------------->| | | |
| | | | | | |
| | | | | | |
| | |AttachReq Dest=PP | | |
| | |<--------| | | |
| | | | | | |
| | | | | | |
| | |AttachAns| | | |
| | |-------->| | | |
| | | | | | |
| | | | | | |
|AttachAns| | | | | |
|<----------------------------| | | |
| | | | | | |
| | | | | | |
|TLS | | | | | |
|...................| | | | |
| | | | | | |
| | | | | | |
|UpdateReq| | | | | |
|------------------>| | | | |
| | | | | | |
| | | | | | |
|UpdateAns| | | | | |
|<------------------| | | | |
| | | | | | |
| | | | | | |
|UpdateReq| | | | | |
|---------------------------->| | | |
| | | | | | |
| | | | | | |
|UpdateAns| | | | | |
|<----------------------------| | | |
| | | | | | |
| | | | | | |
|UpdateReq| | | | | |
|-------------------------------------->| | |
| | | | | | |
| | | | | | |
|UpdateAns| | | | | |
|<--------------------------------------| | |
| | | | | | |
| | | | | | |
Figure 5
finally!! now that JN has a copy of all the data and is ready to route messages and take requests, it sends Updates to everyone in its Routing Table to say "I'm ready to go" ๐ below, it sends one to TP ๐ธ
JN NP XX TP
| | | |
| | | |
| | | |
|UpdateReq| | |
|---------------------------->|
| | | |
| | | |
|UpdateAns| | |
|<----------------------------|
| | | |
| | | |
| | | |
| | | |
Figure 6
13. Security Considerations ๐ก๏ธ
13.1. Overview
okay this section is the serious one ๐ฅบ RELOAD is a generic storage service, but it's designed to be super useful for P2PSIP ๐ we're talking about security problems that are likely to matter for pretty much any usage of RELOAD. if you want more background, check out [RFC5765] ๐
in any Overlay Instance, a user depends on a bunch of peers they have no well-defined relationship with, other than the fact that they're all fellow members of the same Overlay Instance ๐ฌ in practice, those other nodes could be friendly, lazy, curious, or straight-up malicious ๐ no security system can give complete protection when most of the nodes are malicious, so the goal is to give strong security guarantees for some properties even when there are a lot of malicious nodes, AND to let the overlay keep working properly when there are a modest number of malicious nodes โจ
P2PSIP deployments need to be able to authenticate both peers and resources (users) without a trusted entity being actively present in the system ๐ we describe two mechanisms. the first is based on public key certificates and is suitable for general deployments ๐ the second is an admission control mechanism based on an overlay-wide shared symmetric key ๐
13.2. Attacks on P2P Overlays
the two basic jobs overlay nodes do are storage and routing ๐ง some peer is responsible for storing a node's data and for letting a third node fetch that stored data, while other peers are responsible for routing messages to and from the storing nodes ๐ each of these issues gets its own section below ๐ซถ
P2P overlays are a target for subversive nodes that might try to disrupt routing, corrupt or remove user registrations, or eavesdrop on signaling ๐ค the certificate-based security algorithms in this specification are meant to protect overlay routing and user registration information in RELOAD messages ๐
so, to protect the signaling from attackers pretending to be valid nodes (or nodes other than themselves), the first requirement is making sure that all messages come from authorized members of the overlay ๐ for this reason, RELOAD MUST transport all messages over a secure channel (TLS and DTLS are defined in this document) which provides message integrity and authentication of the directly communicating peer ๐ on top of that, messages and data MUST be digitally signed with the sender's private key, which gives end-to-end security for communications ๐ no cap, this is the foundation of the whole thing ๐ญ๐ซถ
13.3. Certificate-Based Security ๐
okay so this spec stores users' registrations (and maybe other data) in an overlay network ๐ฆ which means we need to secure that data AND secure the routing in the overlay as much as we possibly can. both of those are built on one big rule: every entity in the system, whether it's a user or a peer, has to authenticate cryptographically using an asymmetric key pair tied to a certificate ๐ no cap, it's the whole foundation bestie.
When a user enrolls in the Overlay Instance, they request or get assigned a unique name, like "alice@dht.example.net". These names MUST be unique ๐ and they're meant to be picked and used by actual humans, kinda like a SIP address-of-record (AOR) or an email address. The user MUST also be assigned one or more Node-IDs by the central enrollment authority. Both the name and the Node-IDs go into the certificate, right alongside the user's public key โจ
Each certificate lets an entity play two kinds of roles:
- As a user, storing data at specific Resource-IDs in the Overlay Instance that correspond to the user name.
- As an overlay peer with the Node-IDs listed in the certificate.
Note that only users of this Overlay Instance need to validate a certificate, so this doesn't require a global Public Key Infrastructure (PKI) ๐ Instead, certificates MUST be signed by a central enrollment authority, which acts as the certificate authority for the Overlay Instance. This authority signs each node's certificate. Since every node has the CA's certificate (they get it when they enroll), they can verify the certificates of the other entities in the overlay without having to talk to anyone else ๐ And because the certificates contain the user's or node's public key, communications from that user or node can be verified too, which is so iconic.
If self-signed certificates are used, the security provided is significantly decreased, since attackers can mount Sybil attacks ๐ On top of that, attackers can't trust the user names in certificates (although they can trust the Node-IDs, because they are cryptographically verifiable). This scheme might be fine for some small deployments, like a small office or an ad hoc overlay set up among participants in a meeting where all the hosts on the network are trusted ๐ง Some extra security can be added by using the shared secret admission control scheme as well.
Because all stored data is signed by the owner of the data, the storing node can verify that the storer is authorized to store at that Resource-ID, and it can also let any consumer of the data verify the provenance and integrity of the data when they retrieve it ๐ซถ
Note that RELOAD doesn't provide its own revocation or status mechanism (although certificates may, of course, include Online Certificate Status Protocol [OCSP] responder information). So certificate lifetimes SHOULD be chosen to balance the compromise window against the cost of certificate renewal โณ Because RELOAD is already designed to keep working even when some fraction of nodes are malicious, this form of compromise isn't fatal ๐
All implementations MUST implement certificate-based security. ๐
13.4. Shared-Secret Security ๐
RELOAD also supports a shared secret admission control scheme that relies on a single key shared among all members of the overlay. It's a good fit for small groups that want a private network without a bunch of complexity ๐ธ In shared secret mode, all the peers MUST share a single symmetric key, which is used to key TLS-PSK or TLS-SRP mode. A peer that doesn't know the key can't form TLS connections with any other peer, so it can't join the overlay ๐
One natural approach is to use a user-entered password as the key. The problem is that in TLS-PSK mode, keys like that are super susceptible to dictionary attacks ๐ญ If passwords are used as the source of shared keys, then TLS-SRP is the superior choice, because it is not subject to dictionary attacks โจ
13.5. Storage Security ๐ง
When certificate-based security is used in RELOAD, any given Resource-ID/Kind-ID pair is bound to some small set of certificates. To write data, the writer must prove they have the private key for one of those certificates. Also, all data is stored signed with the same private key that was used to authorize the storage. This set of rules makes questions of authorization and data integrity, which have historically been thorny for overlays, relatively simple ๐
13.5.1. Authorization ๐
When a node wants to store some value, it MUST first digitally sign the value with its own private key. Then it sends a Store request that contains both the value and the signature toward the storing peer (which is defined by the Resource Name construction algorithm for that particular Kind of value) ๐จ
When the storing peer receives the request, it MUST determine whether the storing node is authorized to store at this Resource-ID/Kind-ID pair. Figuring that out means comparing the user's identity to the requirements of the access control model (see Section 7.3). If it meets those requirements, the user is authorized to write, pending quota checks, as described in the next section โ
For example, consider a certificate with the following properties:
User name: alice@dht.example.com
Node-ID: 013456789abcdef
Serial: 1234
If Alice wants to Store a value of the "SIP Location" Kind, the Resource Name will be the SIP AOR "sip:alice@dht.example.com". The Resource-ID is determined by hashing the Resource Name. Because SIP Location uses the USER-NODE-MATCH policy, it first verifies that the user name in the certificate hashes to the requested Resource-ID. Then it verifies that the Node-ID in the certificate matches the dictionary key being used for the store. If both of those checks succeed, the Store is authorized ๐ Just a heads up: because the access control model is different for different Kinds, the exact set of checks will vary ๐
13.5.2. Distributed Quota ๐ฐ
Being a peer in an Overlay Instance comes with the responsibility to store data for a given region of the Overlay Instance. But if nodes could store unlimited amounts of data, that would create unacceptable burdens on peers and would also make trivial denial-of-service (DoS) attacks possible ๐ค So RELOAD deals with this by requiring configurations to define maximum sizes for each Kind of stored data. Attempts to store values exceeding this size MUST be rejected.
If peers are inconsistent about this, then strange artifacts will happen when the zone of responsibility shifts and a different peer becomes responsible for overlarge data ๐
Because each Resource-ID/Kind-ID pair is bound to a small set of certificates, these size restrictions also create a distributed quota mechanism, with the quotas administered by the central configuration server ๐
Letting different Kinds of data have different size restrictions gives new usages the flexibility to define limits that fit their needs, without requiring every usage to have expansive limits ๐
13.5.3. Correctness ๐
Because each stored value is signed, it's trivial for any retrieving node to verify the integrity of the stored value ๐ซถ Preventing version rollback attacks takes a bit more care. Rollback attacks on storage are prevented by using store times and lifetime values in each store. A lifetime represents the latest time at which the data is valid, so it limits (although it does not completely prevent) the storing node's ability to pull off a rollback attack on retrievers.
To prevent a rollback attack at the time of the Store request, it is REQUIRED that storage times be monotonically increasing. Storing peers MUST reject Store requests with storage times smaller than or equal to those they are currently storing ๐ซ In addition, a fetching node that receives a data value with a storage time older than the result of its previous fetch knows that a rollback has occurred ๐ต๏ธโโ๏ธ
13.5.4. Residual Attacks ๐ฆ
The mechanisms described here give a high degree of security, but some attacks are still possible. The simplest one is that storing peers can refuse to store a value (i.e., they reject any request). A storing peer can also deny knowing about values it has previously accepted ๐ฌ These attacks can be eased a bit by trying to store to and retrieve from replicas, but a retrieving node doesn't know whether it should try this, since there's a cost to doing so.
The certificate-based authentication scheme prevents a single peer from forging data owned by other peers. Also, although a subversive peer can refuse to return data resources it's responsible for, it can't return forged data, because it can't provide authentication for those registrations. So parallel searches for redundant registrations can mitigate most of the effects of a compromised peer. How reliable the overlay ultimately is comes down to a statistical question based on the replication factor and the percentage of compromised peers ๐
Also, when a Kind is multivalued (e.g., an array data model), the storing peer can return only some subset of the values, which biases its responses. You can counter this by using single values rather than sets, but that makes coordination between multiple storing agents much harder. It's a trade-off that has to be made when designing any usage โ๏ธ
13.6. Routing Security ๐ธ
Because the storage security system guarantees (within limits) the integrity of the stored data, routing security focuses on stopping the attacker from performing a DoS attack that misroutes requests in the overlay ๐ก๏ธ There are a few obvious things to note here. First, it's easy to make sure an attacker is at least a valid node in the Overlay Instance. Second, this is only a DoS attack. Third, if a large percentage of the nodes in the Overlay Instance are controlled by the attacker, it's probably impossible to perfectly secure against this ๐
13.6.1. Background ๐
In general, attacks on DHT routing are mounted by the attacker arranging to route traffic through one or two nodes that it controls. In the Eclipse attack [Eclipse], the attacker tampers with messages to and from nodes for which it is on-path with respect to a given victim node. This lets it pretend to be all the nodes that are reachable through it ๐ญ In the Sybil attack [Sybil], the attacker registers a large number of nodes and is therefore able to capture a large amount of the traffic through the DHT ๐ฏ
Both the Eclipse and Sybil attacks require the attacker to be able to control her Node-IDs. The Sybil attack requires creating a large number of peers, and the Eclipse attack requires the attacker to be able to impersonate specific peers. In both cases, RELOAD tries to mitigate these attacks through centralized, certificate-based admission control ๐ซถโจ
13.6.2. Admissions Control
Getting into a RELOAD Overlay Instance is basically a VIP list ๐. Every peer needs a certificate that contains its Node-ID, and that gets enforced with certificate-based mutual authentication on each connection. (Note: the following applies only when self-signed certificates are not used.) Every time a peer connects to another peer, both sides automatically check that the other one has a suitable certificate. These Node-IDs MUST be randomly assigned by the central enrollment server. โจ This gives two perks:
- It lets the enrollment server limit how many Node-IDs get issued to any one user.
- It stops the attacker from picking specific Node-IDs.
The first perk helps protect against Sybil attacks, as long as the enrollment server uses strict rate-limiting policies ๐ . The second one deters Eclipse attacks but doesn't fully prevent them ๐. Here's the tea: an Eclipse attacker has to impersonate peers on the far side of itself, so it needs certificates for suitable Node-IDs. That means repeatedly asking the enrollment server for new certificates, and those will only match by chance ๐ฒ. From the attacker's side, the problem is that if it only has a few certificates, the part of the Overlay Instance it's pretending to be in looks super sparsely populated next to the victim's local region ๐ญ.
13.6.3. Peer Identification and Authentication
Generally speaking, whenever a peer does overlay stuff that could affect its Routing Table, it must establish its identity ๐ชช. This happens in two ways. First, whenever a peer sets up a direct connection to another peer, they authenticate through certificate-based mutual authentication. Everything sent between them goes over that protected channel, so the peers can verify the data origin of the last-hop peer for requests and responses without any extra cryptography ๐โจ.
Sometimes, though, you need to know who a peer is even when you aren't directly connected to them ๐. The most natural case is when a peer Updates its state. At that point, other peers might need to update their view of the overlay structure, but they have to check that the Update message really came from the actual peer and not an attacker ๐ต๏ธโโ๏ธ. So to stop peers from accepting Update messages from attackers, every overlay routing message is signed by the peer that generated it ๐๏ธ.
For messages that affect the overlay topology, replay is usually prevented by having the information come directly from the nodes that claimed to generate the update, or by having it verified by those nodes ๐. For data storage, replay detection works by signing the time from the node that generated the signature on the Store request. That gives time-based replay protection ๐ฐ๏ธ. Time synchronization only needs to happen between peers that can write to the same location, though! โฐ
13.6.4. Protecting the Signaling
The goal here is to stop an attacker from knowing who is signaling what to whom ๐คซ. An attacker is unlikely to be able to watch the activities of one specific person, thanks to the randomization of IDs and the routing based on the present peers we talked about above. Plus, because messages can be routed using only the header information, the actual body of the RELOAD message can be encrypted during transmission ๐.
There are two lines of defense. The first is TLS or DTLS on each communications link between peers, which protects against attackers who aren't members of the overlay ๐ก๏ธ. The second line is digitally signing each message, which stops adversarial peers from modifying messages in flight, even when they're sitting right on the routing path ๐ช.
13.6.5. Routing Loops and DoS Attacks
Source-routing mechanisms are known to open the door to DoS amplification, especially through induced routing loops [RFC5095] ๐. To limit amplification, the initial-ttl value in the configuration file SHOULD be set to something slightly larger than the longest expected path through the network. For Chord, experience has shown that log(2) of the number of nodes in the network + 5 is a safe bound ๐. Because nodes are required to enforce the initial-ttl as the maximum value, an attacker can't reach an amplification factor greater than initial-ttl. That keeps the extra capabilities from source routing limited ๐งข.
To stop loops from being used for targeted implementation attacks ๐ฏ, implementations SHOULD check the Destination List for duplicate entries and discard those records with an "Error_Invalid_Message" error. This doesn't completely prevent loops, but it does mean at least one attacker node has to be part of the loop ๐.
13.6.6. Residual Attacks
The routing security mechanisms in RELOAD are built to contain attacks on routing, not eliminate them ๐ซง. Attackers can still pull off a whole bunch of stuff. In particular, if an attacker manages to take up a position on the overlay routing between A and B, it can make it look like B doesn't exist or is disconnected. It can also advertise false network metrics to try to reroute traffic. Still, these are mostly DoS attacks ๐ค.
The certificate-based security scheme secures the namespace. But if an individual peer gets compromised, or an attacker obtains a certificate from the CA, a number of subversive peers can still show up in the overlay ๐. These peers can't falsify responses to resource queries, but they can respond with error messages, which effects a DoS attack on the resource registration. They can also subvert routing to other compromised peers ๐. To defend against all of this, a resource search still has to consist of parallel searches for replicated registrations ๐ก๏ธ.
14. IANA Considerations
This section lists the new code points registered by this document ๐.
14.1. Well-Known URI Registration
IANA has registered a "well-known URI" as described in [RFC5785]:
+----------------------------+----------------------+
| URI suffix: | reload-config |
| Change controller: | IETF <iesg@ietf.org> |
| Specification document(s): | RFC 6940 |
| Related information: | None |
+----------------------------+----------------------+
14.2. Port Registrations
IANA has already allocated a TCP port for the main peer-to-peer protocol ๐. That port had the name p2psip-enroll and the port number of 6084. Per this document, IANA has updated this registration to change the service name to reload-config. ๐
IANA has made the following port registration:
+-----------------------------+-------------------------------------+
| Registration Technical | IETF Chair <chair@ietf.org> |
| Contact | |
| Registration Owner | IETF <iesg@ietf.org> |
| Transport Protocol | TCP |
| Port Number | 6084 |
| Service Name | reload-config |
| Description | Peer-to-Peer Infrastructure |
| | Configuration |
+-----------------------------+-------------------------------------+
14.3. Overlay Algorithm Types
IANA has created a "RELOAD Overlay Algorithm Types" Registry ๐. Entries in this registry are strings denoting the names of overlay algorithms, as described in Section 11.1 of [RFC6940]. The registration policy for this registry is "IETF Review" [RFC522]. The initial contents of this registry are:
+----------------+-----------+
| Algorithm Name | Reference |
+----------------+-----------+
| CHORD-RELOAD | RFC 6940 |
| EXP-OVERLAY | RFC 6940 |
+----------------+-----------+
The value EXP-OVERLAY has been made available for experimentation ๐งช. This value is not meant for vendor-specific use of any sort, and it MUST NOT be used for operational deployments ๐ซ.
14.4. Access Control Policies
IANA has created a "RELOAD Access Control Policies" Registry ๐. Entries in this registry are strings denoting access control policies, as described in Section 7.3 of [RFC6940]. New entries in this registry SHALL be registered via Standards Action [RFC5226]. The initial contents of this registry are:
+-----------------+-----------+
| Access Policy | Reference |
+-----------------+-----------+
| USER-MATCH | RFC 6940 |
| NODE-MATCH | RFC 6940 |
| USER-NODE-MATCH | RFC 6940 |
| NODE-MULTIPLE | RFC 6940 |
| EXP-MATCH | RFC 6940 |
+-----------------+-----------+
The value EXP-MATCH has been made available for experimentation ๐งช. This value is not meant for vendor-specific use of any sort, and it MUST NOT be used for operational deployments ๐ซ.
14.5. Application-ID
IANA has created a "RELOAD Application-ID" Registry ๐. Entries in this registry are 16-bit integers denoting Application-IDs, as described in Section 6.5.2 of [RFC6940]. Code points in the range 1 to 32767 SHALL be registered via Standards Action [RFC5226]. Code points in the range 32768 to 61440 SHALL be registered via Expert Review [RFC5226]. Code points in the range 61441 to 65534 are reserved for private use. The initial contents of this registry are:
+-------------+----------------+-------------------------------+
| Application | Application-ID | Specification |
+-------------+----------------+-------------------------------+
| INVALID | 0 | RFC 6940 |
| SIP | 5060 | Reserved for use by SIP Usage |
| SIP | 5061 | Reserved for use by SIP Usage |
| Reserved | 65535 | RFC 6940 |
+-------------+----------------+-------------------------------+
14.6. Data Kind-ID ๐
okay so IANA made a "RELOAD Data Kind-ID" registry ๐ง Entries are 32-bit integers that name data Kinds, see Section 5.2 of [RFC6940]. Code points 0x00000001 to 0x7FFFFFFF SHALL be registered via Standards Action [RFC5226]. Code points in the range 0x8000000 to 0xF0000000 SHALL be registered via Expert Review [RFC5226]. Code points 0xF0000001 to 0xFFFFFFFE are reserved for private use through the Kind description mechanism in Section 11 of [RFC6940]. Here's what's already in the registry ๐
+---------------------+------------+-----------+
| Kind | Kind-ID | Reference |
+---------------------+------------+-----------+
| INVALID | 0x0 | RFC 6940 |
| TURN-SERVICE | 0x2 | RFC 6940 |
| CERTIFICATE_BY_NODE | 0x3 | RFC 6940 |
| CERTIFICATE_BY_USER | 0x10 | RFC 6940 |
| Reserved | 0x7fffffff | RFC 6940 |
| Reserved | 0xfffffffe | RFC 6940 |
+---------------------+------------+-----------+
14.7. Data Model ๐ธ
IANA also made a "RELOAD Data Model" registry ๐ฆ The entries here are strings naming data models, see Section 7.2 of [RFC6940]. New entries in this registry SHALL be registered via Standards Action [RFC5226]. The starter list looks like this:
+------------+-----------+
| Data Model | Reference |
+------------+-----------+
| INVALID | RFC 6940 |
| SINGLE | RFC 6940 |
| ARRAY | RFC 6940 |
| DICTIONARY | RFC 6940 |
| EXP-DATA | RFC 6940 |
| RESERVED | RFC 6940 |
+------------+-----------+
EXP-DATA is there for experimentation only ๐งช It is not meant for vendor-specific use of any sort, and it MUST NOT be used for operational deployments.
14.8. Message Codes ๐
IANA created a "RELOAD Message Codes" registry ๐ฎ Entries are 16-bit integers naming method codes, see Section 6.3.3 of [RFC6940]. These codes SHALL be registered via Standards Action [RFC5226]. Here's the initial lineup, unassigned slots and all ๐
+-------------------------------------+----------------+-----------+
| Message Code Name | Code Value | Reference |
+-------------------------------------+----------------+-----------+
| invalidMessageCode | 0x0 | RFC 6940 |
| probe_req | 0x1 | RFC 6940 |
| probe_ans | 0x2 | RFC 6940 |
| attach_req | 0x3 | RFC 6940 |
| attach_ans | 0x4 | RFC 6940 |
| Unassigned | 0x5 | |
| Unassigned | 0x6 | |
| store_req | 0x7 | RFC 6940 |
| store_ans | 0x8 | RFC 6940 |
| fetch_req | 0x9 | RFC 6940 |
| fetch_ans | 0xA | RFC 6940 |
| Unassigned (was remove_req) | 0xB | RFC 6940 |
| Unassigned (was remove_ans) | 0xC | RFC 6940 |
| find_req | 0xD | RFC 6940 |
| find_ans | 0xE | RFC 6940 |
| join_req | 0xF | RFC 6940 |
| join_ans | 0x10 | RFC 6940 |
| leave_req | 0x11 | RFC 6940 |
| leave_ans | 0x12 | RFC 6940 |
| update_req | 0x13 | RFC 6940 |
| update_ans | 0x14 | RFC 6940 |
| route_query_req | 0x15 | RFC 6940 |
| route_query_ans | 0x16 | RFC 6940 |
| ping_req | 0x17 | RFC 6940 |
| ping_ans | 0x18 | RFC 6940 |
| stat_req | 0x19 | RFC 6940 |
| stat_ans | 0x1A | RFC 6940 |
| Unassigned (was attachlite_req) | 0x1B | RFC 6940 |
| Unassigned (was attachlite_ans) | 0x1C | RFC 6940 |
| app_attach_req | 0x1D | RFC 6940 |
| app_attach_ans | 0x1E | RFC 6940 |
| Unassigned (was app_attachlite_req) | 0x1F | RFC 6940 |
| Unassigned (was app_attachlite_ans) | 0x20 | RFC 6940 |
| config_update_req | 0x21 | RFC 6940 |
| config_update_ans | 0x22 | RFC 6940 |
| exp_a_req | 0x23 | RFC 6940 |
| exp_a_ans | 0x24 | RFC 6940 |
| exp_b_req | 0x25 | RFC 6940 |
| exp_b_ans | 0x26 | RFC 6940 |
| Reserved | 0x8000..0xFFFE | RFC 6940 |
| error | 0xFFFF | RFC 6940 |
+-------------------------------------+----------------+-----------+
The values exp_a_req, exp_a_ans, exp_b_req, and exp_b_ans are there for experimentation ๐ฌ They are not meant for vendor-specific use of any sort, and they MUST NOT be used for operational deployments.
14.9. Error Codes ๐จ
IANA made a "RELOAD Error Code" registry ๐ Entries are 16-bit integers naming error codes, see Section 6.3.3.1 of [RFC6940]. New entries SHALL be defined via Standards Action [RFC5226]. Here's the starter set:
+-------------------------------------+----------------+-----------+
| Error Code Name | Code Value | Reference |
+-------------------------------------+----------------+-----------+
| invalidErrorCode | 0x0 | RFC 6940 |
| Unassigned | 0x1 | |
| Error_Forbidden | 0x2 | RFC 6940 |
| Error_Not_Found | 0x3 | RFC 6940 |
| Error_Request_Timeout | 0x4 | RFC 6940 |
| Error_Generation_Counter_Too_Low | 0x5 | RFC 6940 |
| Error_Incompatible_with_Overlay | 0x6 | RFC 6940 |
| Error_Unsupported_Forwarding_Option | 0x7 | RFC 6940 |
| Error_Data_Too_Large | 0x8 | RFC 6940 |
| Error_Data_Too_Old | 0x9 | RFC 6940 |
| Error_TTL_Exceeded | 0xA | RFC 6940 |
| Error_Message_Too_Large | 0xB | RFC 6940 |
| Error_Unknown_Kind | 0xC | RFC 6940 |
| Error_Unknown_Extension | 0xD | RFC 6940 |
| Error_Response_Too_Large | 0xE | RFC 6940 |
| Error_Config_Too_Old | 0xF | RFC 6940 |
| Error_Config_Too_New | 0x10 | RFC 6940 |
| Error_In_Progress | 0x11 | RFC 6940 |
| Error_Exp_A | 0x12 | RFC 6940 |
| Error_Exp_B | 0x13 | RFC 6940 |
| Error_Invalid_Message | 0x14 | RFC 6940 |
| Reserved | 0x8000..0xFFFE | RFC 6940 |
+-------------------------------------+----------------+-----------+
Error_Exp_A and Error_Exp_B are experiment-only ๐งช They are not meant for vendor-specific use of any sort, and they MUST NOT be used for operational deployments.
14.10. Overlay Link Types ๐
IANA made a "RELOAD Overlay Link Registry" ๐ Entries are 8-bit integers, see Section 6.5.1.1 of [RFC6940]. For more on the link types defined here, check Section 6.6 of [RFC6940]. New entries SHALL be defined via Standards Action [RFC5226]. This registry starts out with these values:
+--------------------+------+-----------+
| Protocol | Code | Reference |
+--------------------+------+-----------+
| INVALID-PROTOCOL | 0 | RFC 6940 |
| DTLS-UDP-SR | 1 | RFC 6940 |
| DTLS-UDP-SR-NO-ICE | 3 | RFC 6940 |
| TLS-TCP-FH-NO-ICE | 4 | RFC 6940 |
| EXP-LINK | 5 | RFC 6940 |
| Reserved | 255 | RFC 6940 |
+--------------------+------+-----------+
EXP-LINK has been made available for experimentation ๐งช It is not meant for vendor-specific use of any sort, and it MUST NOT be used for operational deployments.
14.11. Overlay Link Protocols ๐งต
IANA made a "RELOAD Overlay Link Protocol Registry" ๐ Entries are strings naming protocols, as described in Section 11.1 of this document, and they SHALL be defined via Standards Action [RFC5226]. The starter values are:
+---------------+-----------+
| Link Protocol | Reference |
+---------------+-----------+
| TLS | RFC 6940 |
| EXP-PROTOCOL | RFC 6940 |
+---------------+-----------+
EXP-PROTOCOL is for experimentation only ๐งช It is not meant for vendor-specific use of any sort, and it MUST NOT be used for operational deployments.
14.12. Forwarding Options ๐ฆ
IANA made a "RELOAD Forwarding Option Registry" ๐ Entries are 8-bit integers naming options, see Section 6.3.2.3 of [RFC6940]. Values between 1 and 127 SHALL be defined via Standards Action [RFC5226]. Entries between 128 and 254 SHALL be defined via Specification Required [RFC5226]. The starter list:
+-------------------------+------+-----------+
| Forwarding Option | Code | Reference |
+-------------------------+------+-----------+
| invalidForwardingOption | 0 | RFC 6940 |
| exp-forward | 1 | RFC 6940 |
| Reserved | 255 | RFC 6940 |
+-------------------------+------+-----------+
exp-forward has been made available for experimentation ๐งช It is not meant for vendor-specific use of any sort, and it MUST NOT be used for operational deployments.
14.13. Probe Information Types ๐
okay so IANA made a "RELOAD Probe Information Type Registry" ๐ Entries are 8-bit integers that denote types (see Section 6.4.2.5.1 of [RFC6940]), and each one SHALL be defined via Standards Action [RFC5226]. It starts out with these values:
+--------------------+------+-----------+
| Probe Option | Code | Reference |
+--------------------+------+-----------+
| invalidProbeOption | 0 | RFC 6940 |
| responsible_set | 1 | RFC 6940 |
| num_resources | 2 | RFC 6940 |
| uptime | 3 | RFC 6940 |
| exp-probe | 4 | RFC 6940 |
| Reserved | 255 | RFC 6940 |
+--------------------+------+-----------+
exp-probe is there for experimentation ๐งช It is not a vendor-specific slot, and it MUST NOT be used for operational deployments. Hands off in production, bestie ๐ โโ๏ธโจ
14.14. Message Extensions ๐ฆ
IANA also made a "RELOAD Extensions Registry" ๐ Entries are 8-bit integers that denote extensions (see Section 6.3.3 of [RFC6940]), and they SHALL be defined via Specification Required [RFC5226]. Here's the starting lineup:
+-----------------------------+--------+-----------+
| Extensions Name | Code | Reference |
+-----------------------------+--------+-----------+
| invalidMessageExtensionType | 0x0 | RFC 6940 |
| exp-ext | 0x1 | RFC 6940 |
| Reserved | 0xFFFF | RFC 6940 |
+-----------------------------+--------+-----------+
Same deal as before: exp-ext is for experiments only, not vendor-specific stuff, and it MUST NOT be used for operational deployments ๐ซ Respect the boundary, periodt ๐
14.15. Reload URI Scheme ๐
okay this part is so cute ๐ฅน The reload URI scheme can point at either:
- A peer, e.g., as used in a certificate (see Section 11.3 of [RFC6940]).
- A resource inside a peer.
It's built from a subset of the URI schema in Appendix A of RFC 3986 [RFC3986], plus the URI Guidelines in [RFC4395]. The grammar goes like this ๐ง
RELOAD-URI = "reload://" destination "@" overlay "/"
[specifier]
destination = 1*HEXDIG
overlay = reg-name
specifier = 1*HEXDIG
Here's what each piece means ๐
destination A hexadecimal-encoded Destination List object (i.e., multiple concatenated Destination objects with no length prefix prior to the object as a whole).
overlay The name of the overlay.
specifier A hexadecimal-encoded StoredDataSpecifier indicating the data element.
If there's no specifier, the URI addresses the peer, reachable through the given Destination List at the given overlay name ๐ซถ If there IS a specifier, the URI addresses the data value. Simple, iconic โจ
14.15.1. URI Registration ๐
Here's everything you need to register the reload URI ๐ง
URI Scheme Name: reload
Status: permanent
URI Scheme Syntax: see Section 14.15 of RFC 6940
URI Scheme Semantics: The reload URI is intended to be used as a reference to a RELOAD peer or resource.
Encoding Considerations: The reload URI is not intended to be human-readable text, so it is encoded entirely in US-ASCII.
Applications/protocols that Use this URI Scheme: The RELOAD protocol described in RFC 6940.
Interoperability Considerations: See RFC 6940.
Security Considerations: See RFC 6940
Contact: Cullen Jennings <fluffy@cisco.com>
Author/Change Controller: IESG
References: RFC 6940
14.16. Media Type Registration ๐
Time for the media type, and it's giving config file energy ๐๏ธโจ
Type Name: application
Subtype Name: p2p-overlay+xml
Required Parameters: none
Optional Parameters: none
Encoding Considerations: Must be binary encoded.
Security Considerations: This media type is typically not used to transport information that needs to be kept confidential. However, there are cases where it is integrity of the information is important. For these cases, using a digital signature is RECOMMENDED. One way of doing this is specified in RFC 6940. In the case when the media includes a shared-secret element, the contents of the file MUST be kept confidential or else anyone who can see the shared secret can affect the RELOAD overlay network.
Okay, this one is serious ๐ญ If the file has a shared secret in it, the contents MUST stay confidential, or anyone who sees that secret can mess with the RELOAD overlay network. Guard it like your diary ๐
Interoperability Considerations: No known interoperability consideration beyond those identified for application/xml in [RFC3023].
Published Specification: RFC 6940
Applications that Use this Media Type: The type is used to configure the peer-to-peer overlay networks defined in RFC 6940.
Additional Information: The syntax for this media type is specified in Section 11.1 of [RFC6940]. The contents MUST be valid XML that is compliant with the RELAX NG grammar specified in RFC 6940 and that use the UTF-8[RFC3629] character encoding.
- Magic Number(s): none
- File Extension(s): relo
- Macintosh File Type Code(s): none
Person & Email Address to Contact for Further Information: Cullen Jennings <fluffy@cisco.com>
Intended Usage: COMMON
Restrictions on Usage: None
Author: Cullen Jennings <fluffy@cisco.com>
Change Controller: IESG
14.17. XML Namespace Registration ๐ธ
This document registers two URIs for the config and config-chord XML namespaces in the IETF XML registry defined in [RFC3688]. Two little namespaces, each with its own spot ๐
14.17.1. Config URL ๐
URI: urn:ietf:params:xml:ns:p2p:config-base
Registrant Contact: IESG.
XML: N/A, the requested URIs are XML namespaces
14.17.2. Config Chord URL ๐
URI: urn:ietf:params:xml:ns:p2p:config-chord
Registrant Contact: The IESG.
XML: N/A, the requested URIs are XML namespaces
15. Acknowledgments ๐ซถ
This specification is a merge of the "REsource LOcation And Discovery (RELOAD)" document by David A. Bryan, Marcia Zangrilli, and Bruce B. Lowekamp; the "Address Settlement by Peer to Peer" document by Cullen Jennings, Jonathan Rosenberg, and Eric Rescorla; the "Security Extensions for RELOAD" document by Bruce B. Lowekamp and James Deverick; the "A Chord-based DHT for Resource Lookup in P2PSIP" by Marcia Zangrilli and David A. Bryan; and the Peer-to-Peer Protocol (P2PP) document by Salman A. Baset, Henning Schulzrinne, and Marcin Matuszewski. Thanks to the authors of [RFC5389] for text included from that document. Vidya Narayanan provided many comments and improvements.
The ideas and text for the Chord-specific extension data to the Leave mechanisms were provided by Jouni Maenpaa, Gonzalo Camarillo, and Jani Hautakorpi.
Thanks to the many people who contributed, including Ted Hardie, Michael Chen, Dan York, Das Saumitra, Lyndsay Campbell, Brian Rosen, David Bryan, Dave Craig, and Julian Cain. Extensive last call comments were provided by Jouni Maenpaa, Roni Even, Gonzalo Camarillo, Ari Keranen, John Buford, Michael Chen, Frederic-Philippe Met, Mary Barnes, Roland Bless, David Bryan, and Polina Goltsman. Special thanks to Marc Petit-Huguenin, who provided an amazing amount of detailed review ๐
Dean Willis and Marc Petit-Huguenin helped resolve and provided text to fix many comments received during the IESG review. Iconic teamwork ๐ฆ๐
16. References ๐
16.1. Normative References โจ
okay bestie, these are the docs the spec leans on for the important stuff ๐๐ you NEED these to make sense of the rest ๐ซถ
[OASIS.relax_ng]Bray, T. and M. Murata, "RELAX NG Specification", December 2001.[RFC1918]Rekhter, Y., Moskowitz, R., Karrenberg, D., Groot, G., and E. Lear, "Address Allocation for Private Internets", BCP 5, RFC 1918, February 1996.[RFC2119]Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.[RFC2388]Masinter, L., "Returning Values from Forms: multipart/form-data", RFC 2388, August 1998.[RFC2585]Housley, R. and P. Hoffman, "Internet X.509 Public Key Infrastructure Operational Protocols: FTP and HTTP", RFC 2585, May 1999.[RFC2782]Gulbrandsen, A., Vixie, P., and L. Esibov, "A DNS RR for specifying the location of services (DNS SRV)", RFC 2782, February 2000.[RFC2818]Rescorla, E., "HTTP Over TLS", RFC 2818, May 2000.[RFC3023]Murata, M., St. Laurent, S., and D. Kohn, "XML Media Types", RFC 3023, January 2001.[RFC3174]Eastlake, D. and P. Jones, "US Secure Hash Algorithm 1 (SHA1)", RFC 3174, September 2001.[RFC3339]Klyne, G., Ed. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, July 2002.[RFC3447]Jonsson, J. and B. Kaliski, "Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography Specifications Version 2.1", RFC 3447, February 2003.[RFC3629]Yergeau, F., "UTF-8, a transformation format of ISO 10646", STD 63, RFC 3629, November 2003.[RFC3986]Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, January 2005.[RFC4279]Eronen, P. and H. Tschofenig, "Pre-Shared Key Ciphersuites for Transport Layer Security (TLS)", RFC 4279, December 2005.[RFC4395]Hansen, T., Hardie, T., and L. Masinter, "Guidelines and Registration Procedures for New URI Schemes", BCP 35, RFC 4395, February 2006.[RFC4648]Josefsson, S., "The Base16, Base32, and Base64 Data Encodings", RFC 4648, October 2006.[RFC5226]Narten, T. and H. Alvestrand, "Guidelines for Writing an IANA Considerations Section in RFCs", BCP 26, RFC 5226, May 2008.[RFC5245]Rosenberg, J., "Interactive Connectivity Establishment (ICE): A Protocol for Network Address Translator (NAT) Traversal for Offer/Answer Protocols", RFC 5245, April 2010.[RFC5246]Dierks, T. and E. Rescorla, "The Transport Layer Security (TLS) Protocol Version 1.2", RFC 5246, August 2008.[RFC5272]Schaad, J. and M. Myers, "Certificate Management over CMS (CMC)", RFC 5272, June 2008.[RFC5273]Schaad, J. and M. Myers, "Certificate Management over CMS (CMC): Transport Protocols", RFC 5273, June 2008.[RFC5389]Rosenberg, J., Mahy, R., Matthews, P., and D. Wing, "Session Traversal Utilities for NAT (STUN)", RFC 5389, October 2008.[RFC5405]Eggert, L. and G. Fairhurst, "Unicast UDP Usage Guidelines for Application Designers", BCP 145, RFC 5405, November 2008.[RFC5766]Mahy, R., Matthews, P., and J. Rosenberg, "Traversal Using Relays around NAT (TURN): Relay Extensions to Session Traversal Utilities for NAT (STUN)", RFC 5766, April 2010.[RFC5952]Kawamura, S. and M. Kawashima, "A Recommendation for IPv6 Address Text Representation", RFC 5952, August 2010.[RFC6091]Mavrogiannopoulos, N. and D. Gillmor, "Using OpenPGP Keys for Transport Layer Security (TLS) Authentication", RFC 6091, February 2011.[RFC6234]Eastlake, D. and T. Hansen, "US Secure Hash Algorithms (SHA and SHA-based HMAC and HKDF)", RFC 6234, May 2011.[RFC6298]Paxson, V., Allman, M., Chu, J., and M. Sargent, "Computing TCP's Retransmission Timer", RFC 6298, June 2011.[RFC6347]Rescorla, E. and N. Modadugu, "Datagram Transport Layer Security Version 1.2", RFC 6347, January 2012.[W3C.REC-xmlschema-2-20041028]Malhotra, A. and P. Biron, "XML Schema Part 2: Datatypes Second Edition", World Wide Web Consortium Recommendation REC-xmlschema-2-20041028, October 2004,http://www.w3.org/TR/2004/REC-xmlschema-2-20041028.[w3c-xml-namespaces]Bray, T., Hollander, D., Layman, A., Tobin, R., and University of Edinburgh and W3C, "Namespaces in XML 1.0 (Third Edition)", December 2008.
16.2. Informative References ๐ธ
these ones are the extra reading, the "ooh tell me more" pile ๐ง totally optional but so worth a peek ๐
[Chord]Stoica, I., Morris, R., Liben-Nowell, D., Karger, D., Kaashoek, M., Dabek, F., and H. Balakrishnan, "Chord: A Scalable Peer-to-peer Lookup Protocol for Internet Applications", IEEE/ACM Transactions on Networking Volume 11, Issue 1, 17-32, Feb 2003, 2001.[DHT-RELOAD]Maenpaa, J. and G. Camarillo, "A Self-tuning Distributed Hash Table (DHT) for REsource LOcation And Discovery (RELOAD)", Work in Progress, August 2013.[Eclipse]Singh, A., Ngan, T., Druschel, T., and D. Wallach, "Eclipse Attacks on Overlay Networks: Threats and Defenses", INFOCOM 2006, April 2006.[P2P-DIAGNOSTICS]Song, H., Jiang, X., Even, R., and D. Bryan, "P2P Overlay Diagnostics", Work in Progress, August 2013.[P2PSIP-RELAY]Zong, N., Jiang, X., Even, R., and Y. Zhang, "An extension to RELOAD to support Relay Peer Routing", Work in Progress, October 2013.[REDIR-RELOAD]Maenpaa, J. and G. Camarillo, "Service Discovery Usage for REsource LOcation And Discovery (RELOAD)", Work in Progress, August 2013.[RFC1035]Mockapetris, P., "Domain names - implementation and specification", STD 13, RFC 1035, November 1987.[RFC1122]Braden, R., "Requirements for Internet Hosts - Communication Layers", STD 3, RFC 1122, October 1989.[RFC2311]Dusse, S., Hoffman, P., Ramsdell, B., Lundblade, L., and L. Repka, "S/MIME Version 2 Message Specification", RFC 2311, March 1998.[RFC3688]Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, January 2004.[RFC4013]Zeilenga, K., "SASLprep: Stringprep Profile for User Names and Passwords", RFC 4013, February 2005.[RFC4086]Eastlake, D., Schiller, J., and S. Crocker, "Randomness Requirements for Security", BCP 106, RFC 4086, June 2005.[RFC4145]Yon, D. and G. Camarillo, "TCP-Based Media Transport in the Session Description Protocol (SDP)", RFC 4145, September 2005.[RFC4340]Kohler, E., Handley, M., and S. Floyd, "Datagram Congestion Control Protocol (DCCP)", RFC 4340, March 2006.[RFC4787]Audet, F. and C. Jennings, "Network Address Translation (NAT) Behavioral Requirements for Unicast UDP", BCP 127, RFC 4787, January 2007.[RFC4960]Stewart, R., "Stream Control Transmission Protocol", RFC 4960, September 2007.[RFC5054]Taylor, D., Wu, T., Mavrogiannopoulos, N., and T. Perrin, "Using the Secure Remote Password (SRP) Protocol for TLS Authentication", RFC 5054, November 2007.[RFC5095]Abley, J., Savola, P., and G. Neville-Neil, "Deprecation of Type 0 Routing Headers in IPv6", RFC 5095, December 2007.[RFC5201]Moskowitz, R., Nikander, P., Jokela, P., and T. Henderson, "Host Identity Protocol", RFC 5201, April 2008.[RFC5280]Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk, "Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile", RFC 5280, May 2008.[RFC5694]Camarillo, G., Ed., and IAB, "Peer-to-Peer (P2P) Architecture: Definition, Taxonomies, Examples, and Applicability", RFC 5694, November 2009.[RFC5765]Schulzrinne, H., Marocco, E., and E. Ivov, "Security Issues and Solutions in Peer-to-Peer Systems for Realtime Communications", RFC 5765, February 2010.[RFC5785]Nottingham, M. and E. Hammer-Lahav, "Defining Well-Known Uniform Resource Identifiers (URIs)", RFC 5785, April 2010.[RFC6079]Camarillo, G., Nikander, P., Hautakorpi, J., Keranen, A., and A. Johnston, "HIP BONE: Host Identity Protocol (HIP) Based Overlay Networking Environment (BONE)", RFC 6079, January 2011.[RFC6544]Rosenberg, J., Keranen, A., Lowekamp, B., and A. Roach, "TCP Candidates with Interactive Connectivity Establishment (ICE)", RFC 6544, March 2012.[RFC7086]Keranen, A., Camarillo, G., and J. Maenpaa, "Host Identity Protocol-Based Overlay Networking Environment (HIP BONE) Instance Specification for REsource LOcation And Discovery (RELOAD)", RFC 7086, January 2014.[SIP-RELOAD]Jennings, C., Lowekamp, B., Rescorla, E., Baset, S., Schulzrinne, H., and T. Schmidt, "A SIP Usage for RELOAD", Work in Progress, July 2013.[Sybil]Douceur, J., "The Sybil Attack", IPTPS 02, March 2002.[UnixTime]Wikipedia, "Unix Time", 2013,http://en.wikipedia.org/w/index.php?title=Unix_time&oldid=551527446.[bryan-design-hotp2p08]Bryan, D., Lowekamp, B., and M. Zangrilli, "The Design of a Versatile, Secure P2PSIP Communications Architecture for the Public Internet", Hot-P2P'08, 2008.[handling-churn-usenix04]Rhea, S., Geels, D., Roscoe, T., and J. Kubiatowicz, "Handling Churn in a DHT", In Proc. of the USENIX Annual Technical Conference June 2004 USENIX 2004, 2004.[lookups-churn-p2p06]Wu, D., Tian, Y., and K. Ng, "Analytical Study on Improving DHT Lookup Performance under Churn", IEEE P2P'06, 2006.[minimizing-churn-sigcomm06]Godfrey, P., Shenker, S., and I. Stoica, "Minimizing Churn in Distributed Systems", SIGCOMM 2006, 2006.[non-transitive-dhts-worlds05]Freedman, M., Lakshminarayanan, K., Rhea, S., and I. Stoica, "Non-Transitive Connectivity and DHTs", WORLDS'05, 2005.[opendht-sigcomm05]Rhea, S., Godfrey, B., Karp, B., Kubiatowicz, J., Ratnasamy, S., Shenker, S., Stoica, I., and H. Yu, "OpenDHT: A Public DHT and its Uses", SIGCOMM'05, 2005.[vulnerabilities-acsac04]Srivatsa, M. and L. Liu, "Vulnerabilities and Security Threats in Structured Peer-to-Peer Systems: A Quantitative Analysis", ACSAC 2004, 2004.[wikiChord]Wikipedia, "Chord (peer-to-peer)", 2013,http://en.wikipedia.org/w/index.php?title=Chord_%28peer-to-peer%29&oldid=549516287.[wikiKBR]Wikipedia, "Key-based routing", 2013,en.wikipedia.org/w/index.php?title=Key-based_routing&oldid=543850833.[wikiSkiplist]Wikipedia, "Skip list", 2013,http://en.wikipedia.org/w/index.php?title=Skip_list&oldid=551304213.
Appendix A. Routing Alternatives ๐บ๏ธโจ
okay bestie, this is where we talk about the routing choices people argued about for P2PSIP ๐ Lots of discussion went into picking a routing algorithm. This appendix explains why RELOAD ended up with symmetric recursive routing, and what extensions would be needed to support other algorithms ๐ฆ
A.1. Iterative vs. Recursive ๐
Iterative routing has real perks ๐ It's easier to debug, it uses fewer resources on intermediate peers, and the querying peer can spot and route around misbehaving peers [non-transitive-dhts-worlds05]. BUT, and this is a big but ๐ญ, when NATs are involved, iterative routing is intolerably expensive, because a brand new connection has to be set up for every single hop (using ICE) [bryan-design-hotp2p08] ๐
Iterative routing is supported through the RouteQuery mechanism, and it's mainly meant for debugging ๐ It also lets the querying peer check the routing decisions each hop made, consider other options, and maybe figure out exactly where the forwarding path breaks ๐ง
A.2. Symmetric vs. Forward Response ๐ช
RELOAD uses symmetric recursive routing, but there's another option called forward-only routing. Here the response travels back to the requester as if it were a brand new message started by the responder ๐ (In the previous example, Z sends the response to A as if it were sending a request.) The upside is that forward-only routing needs no state in either the message or the intermediate peers โจ
The downside is that it falls apart when the overlay is unstable ๐ฌ Say A is in the middle of joining the overlay and sends a Join request to Z. A isn't reachable via forward-only routing yet! And even after A is established, if network failures cause temporary instability, A might not be reachable at all, and it may be stuck trying to fix its connectivity with Attach messages ๐ฅฒ
Also, forward-only responses are less likely to reach the querying peer than symmetric recursive ones are ๐ โโ๏ธ The reason is that the forward path is more likely to include a failed peer than the request path is, since the request path was just tested to route the request [non-transitive-dhts-worlds05].
An extension to RELOAD that supports forward-only routing but falls back to symmetric responses would be possible ๐ค But figuring out when to use forward-only routing and when to fall back to symmetric routing is super complicated, so we chose not to include it as an option at this point ๐
A.3. Direct Response ๐ฌ
Another option is direct response routing, where the response goes straight back to the querying node ๐ฏ In the previous example, if A puts its IP address in the request, then Z can just deliver the response directly to A. Without NATs or other connectivity issues, this is the most optimal technique ๐
The catch is NATs ๐ There are a bunch of complexities that have to be handled. In this discussion we keep assuming that A issued the request and Z is generating the response.
- The IP address listed by A may be unreachable, either because of a NAT or firewall rules ๐งฑ So a direct response technique has to fall back to symmetric response [non-transitive-dhts-worlds05]. The hop-by-hop ACKs used by RELOAD let Z figure out when A has received the message (and the TLS negotiation gives earlier confirmation that A is reachable), but this fallback needs a timeout, which increases the response latency whenever A isn't reachable from Z โณ
- Whenever A is behind a NAT, it will have multiple candidate IP addresses, and each one has to be advertised to make sure connectivity works ๐ So Z will need to attempt multiple connections to deliver the response ๐ตโ๐ซ
- One (or all) of A's candidate addresses may route from Z to a different device on the Internet ๐ฑ In the worst case, those nodes might actually be running RELOAD on the same port. So it is absolutely necessary to set up a secure connection to authenticate A before delivering the response ๐ This step slows down direct response routing, because multiple round-trips are needed before the message can be delivered.
- If A is behind a NAT and doesn't already have a connection established with Z, there are only two ways the direct response will work ๐ค The first is that A and Z are both behind the same NAT, in which case the NAT isn't involved. The more common case is when Z is outside A's NAT. In that case the response only gets through if A's NAT implements endpoint-independent filtering. Since the choice of filtering mode mixes up application transparency with security [RFC4787], and no clear recommendation exists, it's unclear how common this feature will be in future devices ๐ซ๏ธ
An extension to RELOAD that supports direct response routing but falls back to symmetric responses would be possible ๐ ๏ธ But figuring out when to use direct response routing and when to fall back to symmetric routing is complicated, and direct response performs worse for peers behind restrictive NATs. So we chose not to include it as an option at this point ๐ โโ๏ธ
A.4. Relay Peers ๐งโโ๏ธ
[P2PSIP-RELAY] proposed a form of direct response where A identifies a peer, Q, that will be directly reachable by any other peer ๐ A uses Attach to establish a connection with Q and advertises Q's IP address in the request sent to Z. Z sends the response to Q, which relays it to A. This cuts the latency down to two hops, while Z negotiates a secure connection to Q ๐
This technique depends on the relative population of nodes like A that need relay peers, and peers like Q that can serve as relay peers ๐ It also requires nodes to be able to identify which category they belong to. That identification problem has turned out to be really hard to solve, and it's still an open area of exploration ๐ง
An extension to RELOAD that supports relay peers is possible, but implementing such an alternative is complicated, so we have not added this feature to RELOAD at this point ๐ซถ
A concept similar to relay peers, basically picking a relay peer at random, has previously been suggested to solve pairwise non-transitivity problems [non-transitive-dhts-worlds05] ๐ฒ But deterministic filtering provided by NATs means random relay peers are no more likely to work than the responding peer ๐
A.5. Symmetric Route Stability โ๏ธ
A common worry about symmetric recursive routing is that one or more peers along the request path might fail before the response comes back ๐ฐ How much this matters depends on the response latency of the overlay. An overlay with slow responses is vulnerable to churn, whereas responses delivered very quickly are only vulnerable to failures that happen during that tiny window โฑ๏ธ
The other side of this is whether the request itself can be delivered successfully ๐จ Assuming typical connection maintenance intervals, the time between the last maintenance and the request being sent is orders of magnitude greater than the delay between the request being forwarded and the response being received. So if the path was stable enough to route the request, it is almost certainly going to stay available to route the response ๐ฏ
An overlay that's unstable enough to suffer this kind of failure often is unlikely to support reliable functionality, no matter what routing mechanism it uses ๐ช๏ธ That said, regardless of how stable the return path is, studies show that under high churn, iterative routing is a better solution for making sure requests complete [lookups-churn-p2p06] [non-transitive-dhts-worlds05]
Finally, because RELOAD retries the end-to-end request, that retry takes care of whatever churn issues are left ๐โจ
Appendix B. Why Clients? ๐
there are a bunch of reasons a node might act as a client instead of a peer ๐คทโโ๏ธ This section covers some of those scenarios, and how the client's behavior changes depending on its capabilities ๐
B.1. Why Not Only Peers? ๐โโ๏ธ
Sometimes a node is forced to act as a client even though it's willing to be a peer ๐ญ These reasons include:
- The node does not have appropriate network connectivity, typically because it has a low-bandwidth network connection ๐ถ
- The node may not have sufficient resources, such as computing power, storage space, or battery power ๐
- The overlay algorithm may dictate specific requirements for peer selection. These may include participating in the overlay to determine trustworthiness, controlling the number of peers in the overlay to reduce overly long routing paths, and ensuring minimum application uptime before a node can join as a peer ๐งฎ
The ultimate criteria for a node to become a peer are set by the overlay algorithm and the specific deployment ๐ฏ A node acting as a client that has a full implementation of RELOAD and the appropriate overlay algorithm can locate its responsible peer in the overlay and use Attach to set up a direct connection to that peer ๐ That way, it can choose to be reachable under either of the routing approaches listed above. Especially for overlay algorithms that elect nodes to serve as peers based on trustworthiness or population, the overlay algorithm may require such a client to locate itself at a particular place in the overlay ๐
B.2. Clients as Application-Level Agents ๐ค
SIP defines an extensive protocol for registration and security between a client and its registrar/proxy server(s) ๐ Any SIP device can act as a client of a RELOAD-based P2PSIP overlay if it contacts a peer that implements the server-side functionality required by the SIP protocol ๐ซ In this case, the peer would be acting as if it were the user's peer, and it would need the appropriate credentials for that user ๐
Application-level support for clients is defined by a usage ๐งฉ A usage offering support for application-level clients should specify how the security of the system is maintained when the data is moved between the application and RELOAD layers ๐ก๏ธ
Authors' Addresses ๐ธ
Cullen Jennings
Cisco
400 3rd Avenue SW, Suite 350
Calgary
Canada
EMail: fluffy@cisco.com
Bruce B. Lowekamp (editor)
Skype
Palo Alto, CA
USA
EMail: bbl@lowekamp.net
Eric Rescorla
RTFM, Inc.
2064 Edgewood Drive
Palo Alto, CA 94303
USA
Phone: +1 650 678 2350
EMail: ekr@rtfm.com
Salman A. Baset
Columbia University
1214 Amsterdam Avenue
New York, NY
USA
EMail: salman@cs.columbia.edu
Henning Schulzrinne
Columbia University
1214 Amsterdam Avenue
New York, NY
USA
EMail: hgs@cs.columbia.edu
๐ฆ where this page comes from
- ietf: rfc6940 2014-01
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms