<?xml version="1.0" encoding="US-ASCII"?>
<!-- vi: set smarttab sw=4 tabstop=4: -->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="3"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc strict="yes"?>
<rfc category="std" docName="draft-varga-netconf-exi-capability-01" ipr="trust200902">
	<front>
		<title abbrev="EXI Capability">
			Efficient XML Interchange Capability for NETCONF
		</title>

		<author fullname="Robert Varga" initials="R." surname="Varga">
			<organization>Pantheon Technologies SRO</organization>
			<address>
				<postal>
					<street>Mlynske Nivy 56</street>
					<city>Bratislava</city>
					<code>821 05</code>
					<country>Slovakia</country>
				</postal>
				<email>robert.varga@pantheon.sk</email>
			</address>
		</author>

		<date day="21" month="October" year="2013" />

		<workgroup>NETCONF Working Group</workgroup>

		<abstract>
			<t>
				The Network Configuration Protocol (NETCONF) provides mechanisms to install,
				manipulate, and delete the configuration of network devices via exchange of XML
				messages in textual representation. Efficient XML Interchange (EXI) is a
				W3C-recommended binary representation of XML Information Set, which is more
				efficient from both CPU and bandwidth utilization perspective. This document
				defines a capability-based extension to the NETCONF protocol that allows peers
				to agree to exchange protocol messages using EXI encoding.
			</t>
		</abstract>

		<note title="Requirements Language">
			<t>
				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 <xref target="RFC2119"/>.
			</t>
		</note>
	</front>

	<middle>
		<section title="Introduction">
			<t>
				The NETCONF protocol <xref target="RFC6241"/> is defined in terms of two peers,
				client and server, exchanging XML messages in an RPC pattern. These messages are
				encoded as XML text documents, which makes the exchange easily understandable by
				human operators by simply observing them on the wire. Unfortunately, this feature
				takes its toll on both computation and network resources, as the representation
				contains redundant information and verbose names.
			</t>

			<t>
				<xref target="W3C.REC-exi-20110310">Efficient XML Interchange</xref> is a W3C
				Recommendation which defines a more efficient way of encoding XML Information Set
				than the usual text representation. This is achieved by a combination of reduced
				verbosity, binary encoding and, optionally, pruning of non-essential information
				like comments.
			</t>

			<t>
				It seems advantageous to allow clients and servers participating on a NETCONF
				session to sacrifice human readability to increase processing efficiency,
				especially in environments with high transactional activity and/or limited
				computing resources.
			</t>
		</section>

		<section title="Terminology">
			<t>
				This document uses the following terms defined in <xref target="RFC6241"/>:
				<list style="symbols">
					<t>capability</t>
					<t>client</t>
					<t>message</t>
					<t>protocol operation</t>
					<t>remote procedure call</t>
					<t>server</t>
				</list>
			</t>
		</section>

		<section anchor="Capability" title="EXI Capability">
			<section anchor="Overview" title="Overview">
				<t>
					The :exi capability indicates that the peer supports EXI message encoding and
					is willing to use it. The capability has no effect on data being handled by
					the NETCONF protocol, nor does it affect protocol message exchanges.
				</t>
			</section>

			<section anchor="Dependencies" title="Dependencies">
				<t>
					EXI-encoded documents are binary data, this capability may only be used when
					the underlying transport is 8-bit clean and preserves message boundaries in
					face of arbitrary binary data. Notably this requires use of Chunked Framing
					mechanism as described in <xref target="RFC6242"/> when used with SSH
					transport.
				</t>
			</section>

			<section anchor="Identifier" title="Capability Identifier">
				<t>
					The EXI capability is identified by the following capability string:
				</t>
				<t>
					urn:ietf:params:netconf:capability:exi:1.0
				</t>
				<t>
					The identifier MAY have a the following parameters:
					<list style="hanging">
						<t hangText="compression:">
							This indicates that the sender is willing to perform EXI compression.
							The parameter MUST contain a positive integral value, which indicates
							maximum compression block size which the sender can process.
						</t>
						<t hangText="schemas:">
							This indicates that the sender can use schema-informed grammars for
							EXI encoding. The parameter MUST contain a value, which has to be one
							of "builtin" or "base:1.1". The value "builtin" indicates the ability
							to use the XML schema built into the EXI specification. The value of
							"base:1.1" is a superset of the "builtin" value and indicates that the
							sender additionally supports schema-informed EXI encoding, based on
							netconf.xsd schema published in <xref target="RFC6241"/>.
						</t>
					</list>
				</t>
				<t>
					Examples:
					<list style="empty">
						<t>
							urn:ietf:params:netconf:capability:exi:1.0?compression=1000000
						</t>
						<t>
							urn:ietf:params:netconf:capability:exi:1.0?schemas=builtin
						</t>
						<t>
							urn:ietf:params:netconf:capability:exi:1.0?schemas=base:1.1
						</t>
						<t>
							urn:ietf:params:netconf:capability:exi:1.0?compression=20000&amp;schemas=builtin
						</t>
					</list>
				</t>
			</section>

			<section anchor="Operations" title="New Operations">
				<section anchor="start-exi" title="&lt;start-exi>">
					<t>
						<list style="hanging">
							<t hangText="Description:">
								The &lt;start-exi> operation requests that the message encoding be
								switched to EXI. The operation is invoked by the client and
								validated by the server. If the server finds the parameters
								acceptable, it will issue a positive response in the current
								session encoding. It MUST encode all subsequent messages using EXI
								encoding with the supplied parameters. It will also expect all
								incoming messages to be EXI-encoded.

								The client MUST NOT send any messages to the server between the
								time is sends this request and the time it receives a response.
								Once it receives a positive reply, it MUST encode all subsequent
								messages using the EXI encoding with the parameters supplied in the
								RPC.

								If the operation fails, the session message encoding remains
								unchanged.
							</t>
							<t hangText="Parameters:">
								<list style="hanging">
									<t hangText="alignment:">
										Requested EXI alignment. If this parameter is not present,
										bit-packed is assumed. The following values are valid:
										<list style="hanging">
											<t hangText="bit-packed:">
												Set EXI alignment to bit-packed.
											</t>
											<t hangText="byte-aligned:">
												Set EXI alignment to byte-aligned.
											</t>
											<t hangText="pre-compression:">
												Set EXI alignment to pre-compression.
											</t>
											<t hangText="compressed:">
												Do not specify EXI alignment, but perform EXI
												compression instead.
											</t>
										</list>
									</t>
									<t hangText="fidelity:">
										Requested EXI fidelity options. If this parameter is not
										present or empty, all fidelity options are disabled. The 
										following items may be specified:
										<list style="hanging">
											<t hangText="&lt;comments/>:">
												Preserve.comments EXI Fidelity option
											</t>
											<t hangText="&lt;dtd/>:">
												Preserve.dtd EXI Fidelity option
											</t>
											<t hangText="&lt;lexical-values/>:">
												Preserve.lexicalValues EXI Fidelity option
											</t>
											<t hangText="&lt;pis/>:">
												Preserve.pis EXI Fidelity option
											</t>
											<t hangText="&lt;prefixes/>:">
												Preserve.prefixes EXI Fidelity option
											</t>
										</list>
									</t>
									<t hangText="schema:">
										Optional parameter. This specifies what schema options
										should be enabled in the EXI encoding process. The
										following values are valid:
										<list style="hanging">
											<t hangText="none">
												Do not use schema-informed grammars at all. This
												translates to using schemaId of
												&lt;xsd:nil>true&lt;/xsd:nil> in the EXI Options
												header.
											</t>
											<t hangText="builtin">
												Do no use schema-informed grammars, but use the
												build-in XML data types. This translates to using
												an empty schemaId in the EXI Options header.
											</t>
											<t hangText="base:1.1">
												Use schema-informed grammar based on netconf.xsd
												as published in <xref target="RFC6241"/> in
												non-strict mode. The value "base:1.1" should be
												carried in the schemaId field in the EXI Options.
											</t>
										</list>
									</t>
								</list>
							</t>
							<t hangText="Positive Response:">
								If the device was able to satisfy the request, an &lt;rpc-reply> is
								sent that contains an &lt;ok> element.
							</t>
							<t hangText="Negative Response:">
								An &lt;rpc-error> element is included in the &lt;rpc-reply> if the
								request cannot be completed for any reason.
							</t>
						</list>
					</t>
					<figure>
						<preamble>Example:</preamble>
						<artwork type="xml">
<![CDATA[	<rpc message-id="101"
		xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
		<start-exi>
			<alignment>pre-compression</alignment>
			<fidelity>
				<dtd/>
				<lexical-values/>
			</fidelity>
		</start-exi>
	</rpc>

	<rpc-reply message-id="101"
		xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
		<ok/>
	</rpc-reply>]]>
						</artwork>
					</figure>
				</section>

				<section anchor="stop-exi" title="&lt;stop-exi>">
					<t>
						<list style="hanging">
							<t hangText="Description:">
								The &lt;stop-exi> operation requests that the message encoding be
								switched to textual XML. The operation is invoked by the client and
								validated by the server. If the server is able to switch the
								encoding to XML, it will issue a positive response in the current
								session encoding. It MUST encode all subsequent messages using
								standard XML encoding. It will also expect all incoming messages to
								be XML-encoded.

								The client MUST NOT send any messages to the server between the time
								is sends this request and the time it receives a response. Once it
								receives a positive reply, it MUST encode all subsequent messages
								using the standard XML encoding.

								If the operation fails, the session message encoding remains
								unchanged. If the session currently uses XML encoding, this RPC
								is a no-operation and SHOULD NOT fail.
							</t>
							<t hangText="Positive Response:">
								If the device was able to satisfy the request, an &lt;rpc-reply> is
								sent that contains an &lt;ok> element.
							</t>
							<t hangText="Negative Response:">
								An &lt;rpc-error> element is included in the &lt;rpc-reply> if the
								request cannot be completed for any reason.
							</t>
						</list>
					</t>
					<figure>
						<preamble>Example:</preamble>
						<artwork type="xml">
<![CDATA[	<rpc message-id="101"
		xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
		<stop-exi/>
	</rpc>

	<rpc-reply message-id="101"
		xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
		<ok/>
	</rpc-reply>]]>
						</artwork>
					</figure>
				</section>
			</section>
		</section>

		<section anchor="yang" title="YANG module for &lt;start-exi> and &lt;stop-exi> Operations">
			<t>
				The following YANG module defines the new operations introduced in this document.
				The YANG language is defined in <xref target="RFC6020"/>.  Every NETCONF speaker
				that supports the :exi capability MUST implement this YANG module.
			</t>
			<figure>
				<artwork type="yang">
				<![CDATA[
<CODE BEGINS> file "ietf-netconf-exi@2013-10-21.yang"

module ietf-netconf-exi {
	namespace "urn:ietf:params:xml:ns:netconf:exi:1.0";

	prefix exi;

	organization
		"IETF NETCONF (Network Configuration) Working Group";

	contact
		"Robert Varga <robert.varga@pantheon.sk>";

	description
		"NETCONF Protocol Operations for Efficient XML Interchange.";

	revision 2013-10-21 {
		description
			"Initial revision";
		reference
			"I-D.varga-netconf-exi-capability-01";
	}

	typedef exi-alignment {
		type enumeration {
			enum bit-packed {
				description
					"Use bit-packed EXI alignment";
			}
			enum byte-aligned {
				description
					"Use byte-aligned EXI alignment";
			}
			enum pre-compression {
				description
					"Use pre-compression EXI alignment";
			}
			enum compressed {
				description
					"Do not set EXI alignment, use EXI compression
					instead";
			}
		}

		description "EXI alignment specification.";
	}


	typedef exi-fidelity {
		type enumeration {
			enum comments {
				description
					"Preserve.comments EXI Fidelity option";
			}
			enum dtd {
				description
					"Preserve.dtd EXI Fidelity option";
			}
			enum lexical-values {
				description
					"Preserve.lexicalValues EXI Fidelity option";
			}
			enum pis {
				description
					"Preserve.pis EXI Fidelity option";
			}
			enum prefixes {
				description
					"Preserve.prefixes EXI Fidelity option";
			}
		}

		description "EXI fidelity options.";
	}

	rpc start-exi {
		description
			"Start encoding protocol messages in Efficient XML
			Interchange format.";

		reference "I-D.varga-netconf-exi-capability";

		input {
			leaf alignment {
				type exi-alignment;
				default "bit-packed";
				description "EXI alignment to use.";
			}

			leaf-list fidelity {
				type exi-fidelity;
				description "EXI fidelity options to use.";
			}
		}
	}

	rpc stop-exi {
		description
			"Stop encoding protocol messages in Efficient XML
			Interchange format. Revert back to using the usual text
			XML encoding.";
	}
}
]]>
				</artwork>
			</figure>
		</section>

		<section anchor="IANA-considerations" title="IANA considerations">
			<t>
				This document registers the following capability identifier URN in the 'Network
				Configuration Protocol (NETCONF) Capability URNs' registry:

				urn:ietf:params:netconf:capability:exi:1.0
			</t>
		</section> 

		<section anchor="Security" title="Security Considerations">
			<t>
				The compression option present in EXI specification may increase CPU and memory
				requirements for encoding the response. Devices should ensure this overhead is
				acceptable before agreeing to using EXI encoding, such that no operational risks
				are introduced.
			</t>
		</section>

		<section anchor="Acknowledgements" title="Acknowledgements">
			<t>
				The author would like to thank Anton Tkacik, Miroslav Miklus and Stefan Kobza for
				their contributions to this document.
			</t>
		</section>
	</middle>

	<back>
		<references title="Normative References">
			<?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?>
			<?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.6020.xml"?>
			<?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.6241.xml"?>
			<?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.6242.xml"?>
			<?rfc include="http://xml.resource.org/public/rfc/bibxml4/reference.W3C.REC-exi-20110310.xml"?>
		</references>
	</back>
</rfc>

