Network Working Group B. Carpenter Internet-Draft Univ. of Auckland Intended status: Standards Track B. Liu, Ed. Expires: December 26, 2016 Huawei Technologies W. Wang X. Gong BUPT University June 24, 2016 Generic Autonomic Signaling Protocol Application Program Interface (GRASP API) draft-liu-anima-grasp-api-01 Abstract This document specifies the application programming interface (API) of the Generic Autonomic Signaling Protocol (GRASP). The API is used for Autonomic Service Agents (ASA) calling the GRASP protocol module to communicate autonomic network signalings with other ASAs. Status of This Memo 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 http://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 December 26, 2016. Copyright Notice Copyright (c) 2016 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 (http://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 Carpenter, et al. Expires December 26, 2016 [Page 1] Internet-Draft GRASP API June 2016 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. Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 2. GRASP API for ASA . . . . . . . . . . . . . . . . . . . . . . 3 2.1. Design Principles . . . . . . . . . . . . . . . . . . . . 3 2.2. API definition . . . . . . . . . . . . . . . . . . . . . 4 2.2.1. Parameters and data structures . . . . . . . . . . . 4 2.2.2. Registration . . . . . . . . . . . . . . . . . . . . 6 2.2.3. Discovery . . . . . . . . . . . . . . . . . . . . . . 8 2.2.4. Negotiation . . . . . . . . . . . . . . . . . . . . . 8 2.2.5. Synchronization and Flooding . . . . . . . . . . . . 13 3. Example Logic Flows . . . . . . . . . . . . . . . . . . . . . 15 4. Security Considerations . . . . . . . . . . . . . . . . . . . 16 5. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 16 6. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 16 7. References . . . . . . . . . . . . . . . . . . . . . . . . . 16 7.1. Normative References . . . . . . . . . . . . . . . . . . 16 7.2. Informative References . . . . . . . . . . . . . . . . . 16 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 17 1. Introduction As defined in [I-D.ietf-anima-reference-model] , the Autonomic Serveice Agent (ASA) is the atomic entity of an autonomic function; and it is instantiated on autonomic nodes. When ASAs communicate with each other, they should use the Generic Autonomic Signaling Protocol (GRASP) [I-D.ietf-anima-grasp]. As the following figure shows, the GRASP could contain two major sub- layers. The bottom is the GRASP base protocol module, which is only responsible for sending and recieving GRASP messages. The upper layer is some extended functions based upon GRASP basic protocol. For example, [I-D.liu-anima-grasp-distribution] is one of the extended functions. It is desirable that ASAs can be designed as portable user-space programs using a portable API. In many operating systems, the GRASP module will therefore be split into two layers, one being a library that provides the API and the other being kernel code containing common components such as multicast handling and the discovery cache. The details of this are system-dependent. Carpenter, et al. Expires December 26, 2016 [Page 2] Internet-Draft GRASP API June 2016 +----+ +----+ |ASAs| |ASAs| +----+ +----+ | | | GRASP Function API | | | +------------------+ |GRASP API | GRASP Extended | | | Function Modules | | +------------------+ | +------------------------------------------+ | GRASP Library | | GRASP Module - - - - - - - - - - - - - -| | GRASP Kernel | +------------------------------------------+ Both the GRASP base module and the extended function modules should be available to the ASAs. Thus, there needs to be two sub-sets of API. However, since the extended functions are expected to be added in an incremental manner, it is inappropriate to define the function APIs in a single document. This document only defines the base GRASP API. 2. GRASP API for ASA 2.1. Design Principles The assumption of this document is that any Autonomic Service Agent (ASA) needs to call a GRASP module that handles protocol details (security, sending and listening for GRASP messages, waiting, caching discovery results, negotiation looping, sending and receiving sychronization data, etc.) but understands nothing about individual objectives. So this is a high level abstract API for use by ASAs. Individual language bindings should be defined in separate documents. An assumption of this API is that ASAs may fall into various classes: o ASAs that only use GRASP for discovery purposes. o ASAs that use GRASP negotiation but only as an initiator (client). o ASAs that use GRASP negotiation but only as a responder. o ASAs that use GRASP negotiation as an initiator or responder. o ASAs that use GRASP synchronization but only as an initiator (recipient). Carpenter, et al. Expires December 26, 2016 [Page 3] Internet-Draft GRASP API June 2016 o ASAs that use GRASP synchronization but only as a responder and/or flooder. o ASAs that use GRASP synchronization as an initiator, responder and/or flooder. The API also assumes that one ASA may support multiple objectives. Nothing prevents an ASA from supporting some objectives for synchronization and others for negotiation. This is a preliminary version. Two particular gaps exist: o Authorization of ASAs is out of scope. o The Rapid mode of GRASP is not supported. 2.2. API definition 2.2.1. Parameters and data structures Wherever a 'timeout' parameter appears, it is an integer expressed in milliseconds. If it is zero, the GRASP default timeout (GRASP_DEF_TIMEOUT, see [I-D.ietf-anima-grasp]) will apply. If no response is received before the timeout expires, the call will fail unless otherwise noted. An 'objective' parameter is a data structure with the following components: o name (UTF-8 string) - the objective's name o neg (Boolean) - True if objective supports negotiation (default False) o synch (Boolean) - True if objective supports synchronization (default False) o loop_count (integer) - Limit on negotiation steps etc. (default GRASP_DEF_LOOPCT, see [I-D.ietf-anima-grasp]) o value - a specific data structure expressing the value of the objective. The format is language dependent, with the constraint that it can be validly represented in CBOR (default integer = 0). An 'ASA_locator' parameter is a data structure with the following contents: Carpenter, et al. Expires December 26, 2016 [Page 4] Internet-Draft GRASP API June 2016 o locator - The actual locator, either an IP address or an ASCII string. o ifi (integer) - The interface identifier index via which this was discovered - probably no use to a normal ASA o expire (system dependent type) - The time on the local system clock when this locator will expire from the cache o is_ipaddress (Boolean) - True if the locator is an IP address o is_fqdn (Boolean) - True if the locator is an FQDN o is_uri (Boolean) - True if the locator is a URI o diverted (Boolean) - True if the locator was discovered via a Divert option o protocol (integer) - Applicable transport protocol (IPPROTO_TCP or IPPROTO_UDP) o port (integer) - Applicable port number In most calls, an 'asa_nonce' parameter is required. It is generated when an ASA registers with GRASP, and any call in which an invalid nonce is presented will fail. It is an up to 24-bit opaque value (for example represented as a uint32_t, depending on the language). It should be unpredictable; a possible implementation is to use the same mechanism that GRASP uses to generate Session IDs [I-D.ietf-anima-grasp]. Another possible implementation is to hash the name of the ASA with a locally defined secret key. In some calls, a 'session_nonce' parameter is required. This is an opaque data structure as far as the ASA is concerned, used to identify calls to the API as belonging to a specific GRASP session. In fully threaded implementations this parameter might not be needed, but it is included to act as a session handle if necessary. It will also allow GRASP to detect and ignore malicious calls or calls from timed-out sessions. A possible implementation is to form the nonce from the underlying GRASP Session ID and the source address of the session. Other parameters are described in the following sections. Carpenter, et al. Expires December 26, 2016 [Page 5] Internet-Draft GRASP API June 2016 2.2.2. Registration These functions are used to register an ASA and the objectives that it supports with the GRASP module. If an authorization model is added to GRASP, it would be added here. o register_asa() Input parameter: name of the ASA (UTF-8 string) Return parameters: success (Boolean) result if success: asa_nonce (integer) if not success: error message (UTF-8 string) This initialises state in the GRASP module for the calling entity (the ASA). In the case of success, an 'asa_nonce' is returned which the ASA must present in all subsequent calls. In the case of failure, the ASA has not been authorized and cannot operate. o deregister_asa() Input parameters: asa_nonce (integer) name of the ASA (UTF-8 string) Return parameters: success (Boolean) result if success: none if not success: error message (UTF-8 string) This removes all state in the GRASP module for the calling entity (the ASA), and deregisters any objectives it has Carpenter, et al. Expires December 26, 2016 [Page 6] Internet-Draft GRASP API June 2016 registered. Note that these actions must also happen automatically if an ASA crashes. Note - the ASA name is strictly speaking redundant in this call, but is present for clarity. o register_objective() Input parameters: asa_nonce (integer) objective (structure) discoverable (Boolean - default False) Return parameters: success (Boolean) result if success: none if not success: error message (UTF-8 string) This registers an objective that this ASA supports and may modify. The 'objective' becomes a candidate for discovery. However, discovery responses should not be enabled until the ASA calls listen_negotiate() or listen_synchronize(), showing that it is able to act as a responder. This can be overridden by setting the optional parameter 'discoverable' to True, intended for objectives that are only defined for GRASP discovery, and which do not support negotiation or synchronization. The ASA may negotiate the objective or send synchronization or flood data. Registration is not needed if the ASA only wants to receive synchronization or flood data for the objective concerned. This call may be repeated for multiple objectives. o deregister_objective() Input parameters: asa_nonce (integer) objective (structure) Carpenter, et al. Expires December 26, 2016 [Page 7] Internet-Draft GRASP API June 2016 Return parameters: success (Boolean) result if success: none if not success: error message (UTF-8 string) The 'objective' must have been registered by the calling ASA; if not, this call fails. Otherwise, it removes all state in the GRASP module for the given objective. 2.2.3. Discovery o discover() Input parameters: asa_nonce (integer) objective (structure) timeout (integer) flush (Boolean - default False) Return parameters: locator_list (structure) This returns a list of discovered 'ASA_locator's for the given objective. If the optional parameter 'flush' is True, any locally cached locators for the objective are deleted first. Otherwise, they are returned immediately. If not, GRASP discovery is performed, and all results obtained before the timeout expires are returned. If no results are obtained, an empty list is returned after the timeout. This should be called in a separate thread if asynchronous operation is required. 2.2.4. Negotiation o request_negotiate() Input parameters: Carpenter, et al. Expires December 26, 2016 [Page 8] Internet-Draft GRASP API June 2016 asa_nonce (integer) objective (structure) peer (ASA_locator) timeout (integer) Return parameters: success (Boolean) session_nonce (structure) result if success: objective (structure) if not success: error message (UTF-8 string) This function opens a negotiation session. The 'objective' parameter must include the requested value, and its loop count should be set to a suitable value by the ASA. If not, the GRASP default will apply. The 'peer' parameter is the target node; it must be an 'ASA_locator' as returned by discover(). If the peer is null, GRASP discovery is performed first. If the 'success' parameter is 'true', the negotiation has successfully started. There are then two cases: 1. The 'session_nonce' parameter is null. In this case the negotiation has succeeded (the peer has accepted the request). The returned objective contains the value accepted by the peer. 2. The 'session_nonce' parameter is not null. In this case negotiation must continue. The returned objective contains the first value proffered by the negotiation peer. Note that this instance of the objective must be used in the subsequent negotiation call because it also contains the current loop count. The 'session_nonce' must be presented in all subsequent negotiation steps. This function must be followed by calls to 'negotiate_step' and/or 'negotiate_wait' and/or 'end_negotiate' until the Carpenter, et al. Expires December 26, 2016 [Page 9] Internet-Draft GRASP API June 2016 negotiation ends. 'request_negotiate' may then be called again to start a new negotation. If the 'success' parameter is 'false', the negotiation has failed for the reason given in the result parameter. An exponential backoff is recommended before any retry. This should be called in a separate thread if asynchronous operation is required. Special note for the ACP infrastructure ASA: It is likely that this ASA will need to discover and negotiate with its peers in each of its on-link neighbors. It will therefore need to know not only the link-local IP address but also the physical interface and transport port for connecting to each neighbor. One implementation approach to this is to include these details in the 'session_nonce' data structure, which is opaque to normal ASAs. o listen_negotiate() Input parameters: asa_nonce (integer) objective (structure) Return parameters: success (Boolean) result if success: session_nonce (structure) if not success: error message (UTF-8 string) requested_objective (structure) This function instructs GRASP to listen for negotiation requests for the given 'objective'. It also enables discovery responses for the objective. It will block waiting for an incoming request, so should be called in a separate thread if asynchronous operation is required. Unless there is an unexpected failure, this call only returns after an incoming negotiation request. When it does so, 'requested_objective' contains the first value requested by the negotiation peer. Note that this instance of the objective must be used in the Carpenter, et al. Expires December 26, 2016 [Page 10] Internet-Draft GRASP API June 2016 subsequent negotiation call because it also contains the current loop count. The 'session_nonce' must be presented in all subsequent negotiation steps. This function must be followed by calls to 'negotiate_step' and/or 'negotiate_wait' and/or 'end_negotiate' until the negotiation ends. 'listen_negotiate' may then be called again to await a new negotation. If an ASA is capable of handling multiple negotiations simultaneously, it may call 'listen_negotiate' simultaneously from multiple threads. The API and GRASP implementation must support re-entrant use of the listening state and the negotiation calls. Simultaneous sessions will be distinguished by the threads themselves, the GRASP Session IDs, and the underlying unicast transport sockets. o stop_listen_negotiate() Input parameters: asa_nonce (integer) objective (structure) Return parameters: success (Boolean) result if success: null if not success: error message (UTF-8 string) Instructs GRASP to stop listening for negotiation requests for the given objective, i.e., cancels 'listen_negotiate'. Of course, it must be called from a different thread. o negotiate_step() Input parameters: asa_nonce (integer) session_nonce (structure) objective (structure) Carpenter, et al. Expires December 26, 2016 [Page 11] Internet-Draft GRASP API June 2016 timeout (integer) Return parameters: Exactly as for 'request_negotiate' Executes the next negotation step with the peer. The 'objective' parameter contains the next value being proffered by the ASA in this step. o negotiate_wait() Input parameters: asa_nonce (integer) session_nonce (structure) timeout (integer) Return parameters: success (Boolean) result if success: null if not success: error message (UTF-8 string) Delay negotiation session by 'timeout' milliseconds. o end_negotiate() Input parameters: asa_nonce (integer) session_nonce (structure) reply (Boolean) reason (UTF-8 string) Return parameters: success (Boolean) Carpenter, et al. Expires December 26, 2016 [Page 12] Internet-Draft GRASP API June 2016 result if success: null if not success: error message (UTF-8 string) End the negotiation session. 'reply' = True for accept (successful negotiation), False for decline (failed negotiation). 'reason' = optional string describing reason for decline. 2.2.5. Synchronization and Flooding o synchronize() Input parameters: asa_nonce (integer) objective (structure) peer (ASA_locator) timeout (integer) Return parameters: success (Boolean) result if success: objective (structure) if not success: error message (UTF-8 string) This call requests the synchronized value of the given 'objective'. If the objective was already flooded, the flooded value is returned immediately in the 'result' parameter. In this case, the 'source' and 'timeout' are ignored. Otherwise, synchronization with a discovered ASA is performed. The 'peer' parameter is an 'ASA_locator' as returned by discover(). If 'peer' is null, GRASP discovery is performed first. Carpenter, et al. Expires December 26, 2016 [Page 13] Internet-Draft GRASP API June 2016 This call should be repeated whenever the latest value is needed. Call in a separate thread if asynchronous operation is required. Since this is essentially a read operation, any ASA can use it. Therefore GRASP checks that the calling ASA is registered but the objective doesn't need to be registered by the calling ASA. In the case of failure, an exponential backoff is recommended before retrying. o listen_synchronize() Input parameters: asa_nonce (integer) objective (structure) Return parameters: success (Boolean) result if success: null if not success: error message (UTF-8 string) This instructs GRASP to listen for synchronization requests for the given objective, and to respond with the value given in the 'objective' parameter. It also enables discovery responses for the objective. This call is non-blocking and may be repeated whenever the value changes. o stop_listen_synchronize() Input parameters: asa_nonce (integer) objective (structure) Return parameters: Carpenter, et al. Expires December 26, 2016 [Page 14] Internet-Draft GRASP API June 2016 success (Boolean) result if success: null if not success: error message (UTF-8 string) This call instructs GRASP to stop listening for synchronization requests for the given 'objective', i.e. it cancels a previous listen_synchronize. o flood() Input parameters: asa_nonce (integer) objectives (type) Return parameters: success (type) result (type) if success: name (type) if not success: error message (UTF-8 string) This call instructs GRASP to flood the given synchronization objective(s) and their value(s) to all GRASP nodes. The 'objectives' parameter is a list of one or more objectives. Checks that the ASA registered each objective. This call may be repeated whenever any value changes. 3. Example Logic Flows TBD (Until this section is written, some Python examples can be found at and .) Carpenter, et al. Expires December 26, 2016 [Page 15] Internet-Draft GRASP API June 2016 4. Security Considerations Security issues for the GRASP protocol are discussed in [I-D.ietf-anima-grasp]. Authorization of ASAs is a subject for future study. The 'asa_nonce' parameter is used in the API as a first line of defence against a malware process attempting to imitate a legitimately registered ASA. The 'session_nonce' parameter is used in the API as a first line of defence against a malware process attempting to hijack a GRASP session. 5. IANA Considerations This does not need IANA assignment. 6. Acknowledgements This document was produced using the xml2rfc tool [RFC7749]. 7. References 7.1. Normative References [I-D.ietf-anima-grasp] Bormann, C., Carpenter, B., and B. Liu, "A Generic Autonomic Signaling Protocol (GRASP)", draft-ietf-anima- grasp-05 (work in progress), May 2016. 7.2. Informative References [I-D.ietf-anima-reference-model] Behringer, M., Carpenter, B., Eckert, T., Ciavaglia, L., Liu, B., Nobre, J., and J. Strassner, "A Reference Model for Autonomic Networking", draft-ietf-anima-reference- model-01 (work in progress), March 2016. [I-D.liu-anima-grasp-distribution] Liu, B. and S. Jiang, "Information Distribution over GRASP", draft-liu-anima-grasp-distribution-01 (work in progress), March 2016. [RFC7749] Reschke, J., "The "xml2rfc" Version 2 Vocabulary", RFC 7749, DOI 10.17487/RFC7749, February 2016, . Carpenter, et al. Expires December 26, 2016 [Page 16] Internet-Draft GRASP API June 2016 Authors' Addresses Brian Carpenter Department of Computer Science University of Auckland PB 92019 Auckland 1142 New Zealand Email: brian.e.carpenter@gmail.com Bing Liu (editor) Huawei Technologies Q14, Huawei Campus No.156 Beiqing Road Hai-Dian District, Beijing 100095 P.R. China Email: leo.liubing@huawei.com Wendong Wang BUPT University Beijing University of Posts & Telecom. No.10 Xitucheng Road Hai-Dian District, Beijing 100876 P.R. China Email: wdwang@bupt.edu.cn Xiangyang Gong BUPT University Beijing University of Posts & Telecom. No.10 Xitucheng Road Hai-Dian District, Beijing 100876 P.R. China Email: xygong@bupt.edu.cn Carpenter, et al. Expires December 26, 2016 [Page 17]