Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Starting the NETCONF Session

Each NETCONF session begins with a handshake in which the NETCONF server and the client application specify the NETCONF capabilities they support. The following sections describe how to start a NETCONF session:

Exchanging <hello> Tag Elements

The NETCONF server and client application each begin by emitting a <hello> tag element to specify which operations, or capabilities, they support from among those defined in the NETCONF specification. The <hello> tag element encloses the <capabilities> tag element and the <session-id> tag element, which specifies the UNIX process ID (PID) of the NETCONF server for the session. Within the <capabilities> tag element, a <capability> tag element specifies each supported function.

The client application must emit the <hello> tag element before any other tag element during the NETCONF session, and must not emit it more than once.

Each capability defined in the NETCONF specification is represented in a <capability> tag element by a uniform resource name (URN). Capabilities defined by individual vendors are represented by uniform resource identifiers (URIs), which can be URNs or URLs. The NETCONF XML management protocol for Junos OS Release 13.2 emits the following <hello> tag element (each <capability> tag element appears on three lines for legibility only):

<hello><capabilities><capability>urn:ietf:params:xml:ns:netconf:base:1.0</capability><capability>urn:ietf:params:xml:ns:netconf:capability:candidate:1.0</capability><capability>urn:ietf:params:xml:ns:netconf:capability:confirmed-commit:1.0</capability><capability>urn:ietf:params:xml:ns:netconf:capability:validate:1.0</capability><capability>urn:itf:params:xml:ns:netconf:capability:url:1.0?protocol=http,ftp,file</capability><capability>http://xml.juniper.net/netconf/junos/1.0</capability></capabilities><session-id>3911</session-id></hello>
]]>]]>

(For information about the ]]>]]> character sequence, see Generating Well-Formed XML Documents.)

The URIs in the <hello> tag element indicate the following supported capabilities:

To comply with the NETCONF specification, the client application also emits a <hello> tag element to define the capabilities it supports. It does not include the <session-id> tag element:

<hello>
<capabilities><capability>first-capability</capability> <!-- tag elements for additional capabilities --></capabilities>
</hello>]]>]]>

The session continues when the client application sends a request to the NETCONF server. The NETCONF server does not emit any tag elements after session initialization except in response to the client application’s requests.

Verifying Compatibility

Exchanging <hello> tag elements enables a client application and the NETCONF server to determine if they support the same capabilities. In addition, we recommend that the client application determine the version of the Junos OS running on the NETCONF server. After emitting its <hello> tag, the client application emits the <get-software-information> tag element in an <rpc> tag element:

<rpc><get-software-information/></rpc>
]]>]]>

The NETCONF server returns the <software-information> tag element, which encloses the <host-name> and <product-name> tag elements plus a <package-information> tag element for each Junos OS module. The <comment> tag element within the <package-information> tag element specifies the Junos OS Release number (in the following example, 8.2 for Junos OS Release 8.2) and the build date in the format YYYYMMDD (year, month, day—12 January 2007 in the following example). Some tag elements appear on multiple lines, for legibility only:

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" \
                xmlns:junos="http://xml.juniper.net/junos/8.2R1/junos">
    <software-information>
        <host-name>router1</host-name>
        <product-name>m20</product-name>
        <package-information>
            <name>junos</name>
            <comment>JUNOS Base OS boot [8.2-20070112.0]</comment>
        </package-information>
        <package-information>
            <name>jbase</name>
            <comment>JUNOS Base OS Software Suite \
                                [8.2-20070112.0]</comment>
        </package-information>
        <!-- <package-information> tag elements for additional modules -->
    </software-information>
    </capabilities>
</rpc-reply>
]]>]]>

Normally, the version is the same for all Junos OS modules running on the device (we recommend this configuration for predictable routing performance). Therefore, verifying the version number of just one module is usually sufficient.

The client application is responsible for determining how to handle any differences in version or capabilities. For fully automated performance, include code in the client application that determines whether it supports the same capabilities and Junos OS version as the NETCONF server. Decide which of the following options is appropriate when there are differences, and implement the corresponding response:

  • Ignore differences in capabilities and Junos version, and do not alter the client application’s behavior to accommodate the NETCONF server. A difference in Junos versions does not necessarily make the server and client incompatible, so this is often a valid approach. Similarly, it is a valid approach if the capabilities that the client application does not support are operations that are always initiated by a client, such as validation of a configuration and confirmed commit. In that case, the client maintains compatibility by not initiating the operation.
  • Alter standard behavior to be compatible with the NETCONF server. If the client application is running a later version of the Junos OS, for example, it can choose to emit only NETCONF and Junos XML tag elements that represent the software features available in the NETCONF server’s version of the Junos OS.
  • End the NETCONF session and terminate the connection. This is appropriate if you decide that it is not practical to accommodate the NETCONF server’s version or capabilities. For instructions, see Ending a NETCONF Session and Closing the Connection.

Published: 2013-07-26