Internet-Draft | Multipart | March 2020 |
Zhang & Yang | Expires 10 September 2020 | [Page] |
Many ALTO use cases involve multiple ALTO information resources like different network maps, cost maps and property maps to achieve their own specific goals. To make the ALTO client query them one by one is not only inefficient but also error-prone. The inconsistent responses can be performed because of the unstable communication environment, and finally conduct the unexpected traffic optimization. Further more, some ALTO information resources may have correlation, which means one's input parameters may depends on another one's response. To address those issues, some advanced query schema is required. This document proposes an ALTO extension to support the multiple ALTO resources query in the single request using the HTTP multipart message and the existing JSON query languages.¶
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 [RFC2119].¶
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.¶
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.¶
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."¶
This Internet-Draft will expire on 10 September 2020.¶
Copyright (c) 2020 IETF Trust and the persons identified as the document authors. All rights reserved.¶
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.¶
Application-Layer Traffic Optimization (ALTO) protocol [RFC7285] and its extensions already define several types of information resources, like Network Map, Cost Map and Property Map, to expose useful network information to applications. However, many applications do not only use a single information resource to perform their traffic optimization. Retrieving multiple ALTO information resources is very common in many ALTO use cases.¶
Using the current ALTO framework defined in [RFC7285], the ALTO client can only query multiple ALTO information resources one by one. It is not only inefficient but also error-prone. Because of the network delay between different requests and the frequent change of ALTO information resources, the responses received by the ALTO client may be inconsistent.¶
Further more, some ALTO information resources have known dependencies, which means the ALTO client may need one's response to decide another one's query input parameters.¶
To be summarized, we need the multipart query service for three reasons:¶
This document defines a new ALTO services for: (1) querying multiple ALTO resources in a single request/response, and (2) supporting general-purpose JSON query languages to resolve the relational query.¶
Besides the terms defined in [RFC2045], [RFC2046], [RFC2387], and [RFC7285], this document also uses the following additional terms:¶
A Resource Query Entry indicates the ResoureQuery object (see Section 6.4) for an individual resource in the accept input parameters of the Multipart Query resource.¶
A Resource Response Entry indicates the entry of an individual part of the multipart response message, including the MIME headers and the body content.¶
A Resource Response Entry Body indicates the body content of a Resource Response Entry.¶
The following use cases can benefit from the multipart query service.¶
The simplest use case is to query a batch of ALTO resources in a single request.¶
Although the ALTO client can perform ALTO requests for multiple times, it is not only inefficient but also inconsistent.¶
For example, the ALTO server provides a network map resource A and a dependent cost map resource B. Both resources may change frequently. Assume the ALTO client queries the network map first, and it gets the revision A1. When the client queries the cost map, the network map may be already changed from A1 to A2, and the client receives cost map B2 which depends on A2 not A1. So the responded cost map B2 is not consistent with the previous network map A1.¶
This case requires the ALTO server to provide a way for the ALTO client to query multiple ALTO resources in a single transaction.¶
Beyond the simple batch query, there are also some another use cases requiring a new service for relational query. For example, Some clients may need to query an endpoint property map first, and find endpoints with some properties fitting some conditions. And then they query the endpoint cost of these endpoints.¶
In this case, the endpoint cost query depends on the result of the property map query. Although the ALTO client can cache the whole property map in its local storage, it is still not efficient and may conduct the consistency issue if the property map changes frequently. So it requires a new service to provide multiple dependent resources efficiently and consistently.¶
A general multipart query service benefits the ALTO client in two aspects:¶
Another use case requiring the multiple resource query is the relational query between the on-demand generated resources. A straightforward example is the path vector query demonstrated in [I-D.ietf-alto-path-vector].¶
[I-D.ietf-alto-path-vector] introduces an extension of ALTO to provide path vector information by cost map and unified property map [I-D.ietf-alto-unified-props-new]. The client using path vector extension will usually query cost map and a dynamically generated property map sequentially. It is even hard to cache the full data of resources, because both the cost map and the property map are on-demand generated by the query input here. Thus, the only way to reduce the time consumption is to compound the two resources.¶
From the use cases described in Section 3, there are three additional requirements for ALTO protocol:¶
This document discusses the solution of how to apply multipart/*
(see
[RFC2045] and [RFC2046]) response to the ALTO protocol.¶
There are three cases applying Multipart response to ALTO:¶
The application about Multipart request to the single object response is out of the scope of this document.¶
An ALTO Multipart Query resource is requested using the HTTP POST method.¶
The capabilities are defined by an object of type MultipartQueryCapabilities:¶
object { JSONString query-langs<0..*>; } MultipartQueryCapabilities;¶
where query-langs
is an array of JSONString to indicate which query languages
are supported by this resource.¶
The input parameters for a Multipart Query request are supplied in the entity
body of the POST request. This document specifies the input parameters with
a data format indicated by the media type
application/alto-multipartquery+alto
, which is a JSON object of type
ReqMultipartQuery:¶
object { ResourceQuery resources<1..*>; [JsonString query-lang;] } ReqMultipartQuery; object { JsonString resource-id; [JsonValue input;] } ResourceQuery;¶
with fields:¶
resource-id
field to
indicate which resource is to be queried. If the queried resource requires the
POST method, the input
field MUST be specified. The value of the input
field MUST be either a JSONString or a JSONObject. When its value is a
JSONObject, its format MUST be as the accept input parameters of its resource.
When its value is a JSONString, it MUST be a program written in the query
language specified by the query-lang
field.¶
query-lang
field MUST be one of values in the
query-langs
capability. If this field is not specified in the request, the
ALTO client SHOULD NOT use any query language in the input
field.¶
An array with the resource ID(s) of resource(s) which this multipart query
resource can compound. The used resource can be any available ALTO resources
except for the multipart query resource. If the uses
field is not specified,
all the available ALTO resources can be queried except for the multipart query
resource.¶
At the top level, the request of ALTO Multipart Query resource may conduct two types of errors: Partial Error and Entire Error.¶
The Partial Error only occurs when the value of the resource-id
field or the
input
field is invalid.¶
When the Partial Error occurs, the ALTO server MUST still return the response in
the media type multipart/related
. For the resource query entry with an error,
the ALTO server MUST specify the Content-Type
of its resource response entry
as application/alto-error+json
, and include the ALTO error message in its
resource response entry body. For the resource query entry without any error,
the ALTO server MUST perform its query request normally.¶
The value of the resource-id
field is invalid when this resource id is not
defined by the Information Resource Directory. In this case, the ALTO server
MUST return the E_INVALID_FIELD_VALUE error.¶
The validation of each input
field of the multipart query input parameters
depends on the queried resource:¶
input
field of the multipart query input parameters is neither
a JSONObject nor a JSONString, the ALTO server SHOULD return the
E_INVALID_FIELD_TYPE error, unless a future protocol extension supports the
non-JSONObject input parameters.¶
input
field of the multipart query input parameters is a JSONObject,
the ALTO server MUST validate the value using its queried resource and return
the corresponding error if it has.¶
If the input
field of the multipart query input parameters is a JSONString:¶
query-lang
is not specified, the ALTO server MUST return the
E_INVALID_FIELD_TYPE error.¶
query-lang
is specified, the ALTO server MUST execute this
JSONString as a program written in the query-lang
. If the execution
failed, the ALTO server MUST return the E_INVALID_FIELD_VALUE error. If
the execution succeed but the result fails to pass the validation of the
queried resource, the ALTO server MUST return the E_INVALID_FIELD_VALUE
error and attach the error message returned by the queried resource into
the message
field of the ALTO error message.¶
The syntax error is an Entire Error.¶
Any other invalid request will conduct the Entire Error.¶
When the Entire Error occurs, the ALTO server MUST return the error response in
the media type application/alto-error+json
instead of multipart/related
. The
process of the Entire Error is as defined in Section 8.5 of [RFC7285].¶
This document defines a compatible incremental update process for Multipart Query resource with [I-D.ietf-alto-incr-update-sse].¶
An ALTO server's IRD can export an Update Stream service defined in
[I-D.ietf-alto-incr-update-sse] including the Resource ID of a Multipart
Query resource in the uses
field. When an ALTO client subscribe the
incremental update for this Multipart Query resource, the ALTO server sends the
whole Multipart response message back at the first data update message. Then
the ALTO server subscribe all nodes in this multipart resource tree
automatically. Once data updated later, the ALTO server publishes the update
for each node individually.¶
Assume the root IRD is like the following:¶
{ "meta": { "path-vector": { "cost-mode": "array", "cost-metric": "ane-path" }, "num-routingcost": { "cost-mode": "numerical", "cost-metric": "routingcost" }, "num-hopcount": { "cost-mode": "numerical", "cost-metric": "hopcount" } }, "resources": { "my-default-networkmap": { "uri": "http://alto.example.com/networkmap", "media-type": "application/alto-networkmap+json" }, "my-default-costmap": { "uri": "http://alto.example.com/costmap", "media-type": "application/alto-costmap+json", "capabilities": { "cost-type-names": [ "num-routingcost" ] }, "uses": [ "my-default-networkmap" ] }, "my-filtered-costmap": { "uri": "http://alto.example.com/costmap/filtered", "media-type": "application/alto-costmap+json", "accepts": "application/alto-costmapfilter+json", "capabilities": { "cost-type-names": [ "num-hopcount" ] }, "uses": [ "my-default-networkmap" ] }, "endpoint-path-vector": { "uri": "http://alto.exmaple.com/endpointcost", "media-type": "application/alto-endpointcost+json", "accepts": "application/alto-endpointcostparams+json", "capabilities": { "cost-constraints": true, "cost-type-names": [ "path-vector" ], }, "property-map": "propmap-availbw" }, "propmap-availbw-delay": { "uri": "http://alto.exmaple.com/propmap/availbw", "media-type": "application/alto-propmap+json", "accepts": "application/alto-propmapparams+json", "capabilities": { "domain-types": [ "ane" ], "prop-types": [ "availbw" ] } }, "propmap-location": { "uri": "http://alto.exmaple.com/propmap/location", "media-type": "application/alto-propmap+json", "accepts": "application/alto-propmapparams+json", "capabilities": { "domain-types": [ "pid" ], "prop-types": [ "country", "state" ] } }, "multipart-query": { "uri": "http://alto.example.com/multipart", "media-type": "multipart/related", "accepts": "application/alto-multipartquery+json", "capabilities": { "query-langs": [ "xquery", "jsoniq" ] } } } }¶
POST /multipart HTTP/1.1 Host: alto.example.com Accept: multipart/related, application/alto-error+json Content-Lenght: [TBD] Content-Type: application/alto-multipartquery+json { "resources": [ { "resource-id": "my-default-networkmap" }, { "resource-id": "my-default-costmap" } ] }¶
HTTP/1.1 200 OK Content-Lenght: [TBD] Content-Type: multipart/related; boundary=simple-batch-query --simple-batch-query Content-Type: application/alto-networkmap+json { "meta": { "vtag": { "resource-id": "my-default-networkmap", "tag": "75ed013b3cb58f896e839582504f622838ce670f" } }, "network-map": { "PID1" : { "ipv4" : [ "192.0.2.0/24", "198.51.100.0/25" ] }, "PID2" : { "ipv4" : [ "198.51.100.128/25" ] }, "PID3" : { "ipv4" : [ "0.0.0.0/0" ], "ipv6" : [ "::/0" ] } } } --simple-batch-query Content-Type: application/alto-costmap+json { "meta": { "dependent-vtags": [ { "resource-id": "my-default-networkmap", "tag": "75ed013b3cb58f896e839582504f622838ce670f" } ], "cost-type": { "cost-mode": "numerical", "cost-metric": "routingcost" } }, "cost-map": { "PID1": { "PID1": 1, "PID2": 5, "PID3": 10 }, "PID2": { "PID1": 5, "PID2": 1, "PID3": 15 }, "PID3": { "PID1": 20, "PID2": 15 } } }¶
NOTE: In this example, we use the "`" block to express the raw string with
unescaped characters like \n
and \"
. It is not valid HTTP body, but only
used to better present. When the request is sent to the ALTO server, the "`"
block should be escaped.¶
POST /multipart HTTP/1.1 Host: alto.example.com Accept: multipart/related, application/alto-error+json Content-Lenght: [TBD] Content-Type: application/alto-multipartquery+json { "query-lang": "jsoniq", "resources": [ { "resource-id": "propmap-location" }, { "resource-id": "my-default-costmap", "input": ` let $propmap := collection("propmap-location") .("property-map") return { "cost-type": { "cost-mode": "numerical", "cost-metric": "hopcount" }, "pids": { "srcs": [ for $pid in keys($propmap) where $propmap.$pid.country eq "US" return substring-after($pid, "PID:") ], "dsts": [ for $pid in keys($propmap) where $propmap.$pid.country eq "CA" return substring-after($pid, "PID:") ] } } ` } ] }¶
HTTP/1.1 200 OK Content-Lenght: [TBD] Content-Type: multipart/related; boundary=prop-const-query --prop-const-query Content-Type: application/alto-propmap+json { "property-map": { "pid:PID1": { "country": "US", "state": "CA" }, "pid:PID2": { "country": "US", "state": "CT" }, "pid:PID3": { "country": "CA", "state": "QC" }, "pid:PID4": { "country": "CA", "state": "NT" }, "pid:PID5": { "country": "FR" } } } --prop-const-query Content-Type: application/alto-costmap+json { "meta": { "cost-type": { "cost-mode": "numerical", "cost-metric": "hopcount" } }, "cost-map": { "PID1": { "PID3": 5, "PID4": 7 }, "PID2": { "PID3": 8, "PID4": 4 } } }¶
POST /multipart HTTP/1.1 Host: alto.example.com Accept: multipart/related, application/alto-error+json Content-Lenght: [TBD] Content-Type: application/alto-multipartquery+json { "query-lang": "jsoniq", "resources": [ { "resource-id": "endpoint-path-vector", "input": { "cost-type": { "cost-mode": "array", "cost-metric": "ane-path" }, "endpoints": { "srcs": [ "ipv4:192.0.2.2" ], "dsts": [ "ipv4:192.0.2.89", "ipv4:203.0.113.45" ] } } }, { "resource-id": "propmap-availbw", "input": ` let $propmap := collection("endpiont-path-vector") .("endpoint-cost-map") return { "entities": [ distinct-values(flatten( for $src in keys($propmap) let $dsts := $propmap.$src return flatten( for $dst in keys($dsts) return $dsts.$dst ) )) ], "properties": [ "availbw" ] } ` } ] }¶
HTTP/1.1 200 OK Content-Length: [TBD] Content-Type: multipart/related; boundary=path-vector-query --path-vector-query Content-Type: application/alto-endpointcost+json { "meta": { "cost-type": { "cost-mode": "array", "cost-metric": "ane-path" } }, "endpoint-cost-map": { "ipv4:192.0.2.2": { "ipv4:192.0.2.89": [ "ane:L001", "ane:L003", "ane:L004" ], "ipv4:203.0.113.45": [ "ane:L001", "ane:L004", "ane:L005" ], "ipv6:2001:db8::10": [ "ane:L001", "ane:L005", "ane:L007" ] } } } --path-vector-query Content-Type: application/alto-propmap+json { "property-map": { "ane:L001": { "availbw": 50 }, "ane:L003": { "availbw": 48 }, "ane:L004": { "availbw": 55 }, "ane:L005": { "availbw": 60 }, "ane:L007": { "availbw": 35 } } }¶
The multipart query service is a new ALTO service using the new media type. So the legacy ALTO client cannot identify this service from the IRD of the ALTO server supporting it. And the legacy ALTO server also cannot interpret the request of a multipart query service sent by the ALTO client.¶
The multipart query service can use any ALTO resources exchanging JSON data in request/response mechanism. So all the known ALTO extensions like ALTO Calendar [I-D.ietf-alto-cost-calendar], Multi-Cost [RFC8189] and the Path Vector [I-D.ietf-alto-path-vector] extension, which does not change the request/response mechanism, are compatible with the multipart query service.¶
HTTP/2 [RFC7540] provides new features like streams and multiplexing that can essentially improve the web interface communication latency. As the deployment of HTTP/2, it is valuable to consider how to transit the ALTO information resources over HTTP/2.¶
The multipart query service defined in this document includes two parts: the multiple-resource query schema and the multipart response schema.¶
By leveraging HTTP/2 multiplexing in the scope of this document, the multipart response schema can be replaced with sending multiple HTTP/2 streams using HTTP/2 server push. Each stream only needs to include a single ALTO information resource. The benefit is that the Server can include additional meta information in the HTTP HEADERS frame of each stream. And the Client can parse each ALTO information resource in parallel.¶
However, the multiple-resource query schema is required to be reused to keep the consistent request semantics. The Server requires the Client to send the multiple-resource query request in a single HTTP/2 stream. It will enforce the Server to generate the response to different ALTO information resources based on the same database snapshot.¶
Because the response body entry of the multipart query resource is not a single JSON object, it may not be compatible with the current incremental update representation used in [I-D.ietf-alto-incr-update-sse].¶
Some use cases may need the server generates "anonymous" ALTO resources for the on-demand information. The "anonymous" ALTO resources usually cannot appear alone but need to bind with some "non-anonymous" ALTO resources.¶
Allow the ALTO clients to upload the query language script may not be safe. The code injection and many potential attacks can be conducted. The security issue should be discussed and considered.¶
To avoid the attacks like the code injection, this document recommends the following approaches:¶
This document registers an additional ALTO media type, listed in Table 1.¶
Type | Subtype | Specification |
---|---|---|
application | alto-multipartquery+json | Section 6.4 |
application/json
media type. See [RFC8259].¶
TODO: Put additional figures here if we have.¶