§5.7.3The Network Configuration Protocol (NETCONF) and YANG

Network layer Kurose & Ross pp. 432–436 · ~15 min read

  • netconf
  • yang
  • running configuration
  • netconf capability

Where you are

  • Application layer
  • Transport layer
  • Network layer you are here
  • Link layer
  • Physical layer

NETCONF (Network Configuration Protocol) configures devices instead of only reading them: every message is an XML (Extensible Markup Language) document, it runs over a secure connection, and it can change a whole set of devices as one transaction.

Words you will meet

  • NETCONF — the Network Configuration Protocol, between a managing server and its managed devices.

  • YANG — the data modelling language that describes what NETCONF is carrying.

  • RPC (Remote Procedure Call) — remote procedure call: ask another machine to run an operation, as if calling a function.

  • Running configuration — the settings a device is actually using right now.

  • Capability — an extra feature a NETCONF endpoint declares it supports.

Why this matters

Section 5.7.2 ended on a finding: in 2002 an IAB (Internet Architecture Board) workshop recorded that the SNMP (Simple Network Management Protocol) and MIB (Management Information Base) approach was valuable for monitoring. It fell short for configuration and for management at scale.

This section is what was built in response. Everything in it answers one of those two complaints.

It is also the last new protocol in the chapter, and the last piece of a picture started in section 5.1: the control plane is not only about computing routes. It is about configuring and managing the devices that use them.

What NETCONF does

NETCONF operates between the managing server and the managed devices, and provides messaging for three things.

  • Retrieve, set and modify configuration data at managed devices.
  • Query operational data and statistics at managed devices.
  • Subscribe to notifications generated by managed devices.

The managing server actively controls a device by sending it configurations, specified as a structured XML (Extensible Markup Language) document, and then activating a configuration at the device.

NETCONF uses a remote procedure call style. Protocol messages are encoded in XML too, and they are exchanged over a secure, connection-oriented session, such as TLS (Transport Layer Security) over TCP (Transmission Control Protocol) . Chapter 8 covers TLS.

A session

Figure 5.22 — one NETCONF session, start to finish
message 9 of 9
Managing serverNETCONF calls this the clientTimeManaged deviceNETCONF calls this the serverTimesecure connection · TLS over TCP<hello> · my capabilities are…<hello> · and mine are…<rpc message-id="101"> <get/><rpc-reply message-id="101"><rpc message-id="102"> <edit-config><rpc-reply message-id="102"> <ok/><notification><close-session>

Click any arrow to see what that message says and why it is sent.

Every message is an XML document. The three shapes are <rpc>/<rpc-reply> pairs, unsolicited <notification>s, and the <hello> and <close-session> that bracket them.

Read this diagram as text
  1. Managing server sends secure connection · TLS over TCP to Managed device. First the managing server establishes a secure, connection-oriented session to the managed device. Compare SNMP, which typically rides on UDP and repairs nothing. NETCONF starts from a reliable, encrypted channel.
  2. Managing server sends <hello> · my capabilities are… to Managed device. Capabilities are NETCONF functionality that supplements the base specification in RFC 6241. Each side declares what it supports before anything else happens.
  3. Managed device sends <hello> · and mine are… to Managing server. The exchange is symmetric. Neither side assumes what the other can do.
  4. Managing server sends <rpc message-id="101"> <get/> to Managed device. Interactions take the form of a remote procedure call. The managing server asks the device to run an operation, and the message carries an id so the reply can be matched to it.
  5. Managed device sends <rpc-reply message-id="101"> to Managing server. The reply carries the same message id. The whole configuration comes back inside it, in XML.
  6. Managing server sends <rpc message-id="102"> <edit-config> to Managed device. The same shape, but this one changes the device. Configuration is where NETCONF puts its emphasis.
  7. Managed device sends <rpc-reply message-id="102"> <ok/> to Managing server. If the device could satisfy the request it replies with an <ok> element. Otherwise it returns an <rpc-error>, and the configuration can be rolled back to its previous state.
  8. Managed device sends <notification> to Managing server. Device notifications are sent proactively from the managed device to the managing server, without a request. This is NETCONF’s equivalent of an SNMP trap, and a server subscribes to them with <create-subscription>.
  9. Managing server sends <close-session> to Managed device. And the session ends.

Lifelines, left to right: Managing server (server), Managed device (router).

NETCONF calls the managing server the “client”

The book flags this and then deliberately ignores it, and so does this page.

In NETCONF’s own vocabulary the managing server is the client, and the managed device is the server, because the managing server is the one that establishes the connection.

That is the opposite of the network-management terminology of Figure 5.20, which this chapter has used throughout. Both namings are correct in their own documents. If you read RFC (Request For Comments) 6241 after this page, expect the words to swap.

The operations

Table 5.3 — selected NETCONF operations
OperationWhat it does

Cells marked ⓘ have an explanation — click to read it.

Two of these have an SNMP counterpart. The other four are why NETCONF exists. Click a cell marked ⓘ.

Two of those have an SNMP counterpart: <get> retrieves state, and the subscription pair delivers events. The other four — <get-config>, <edit-config>, <lock> and <unlock> — are what demonstrate NETCONF’s particular emphasis on device configuration.

In plain words

<lock> is the operation with no equivalent anywhere earlier in this chapter.

It lets a managing server lock the entire configuration datastore of a device. The server can then make a change without fear of interaction with other NETCONF, SNMP or CLI (Command Line Interface) commands arriving from elsewhere at the same instant. Locks are meant to be short-lived.

Think about what that admits. A real device is being configured by several tools at once, by different people, and until now nothing coordinated them.

And transactions across many devices

The basic operations can be composed into more sophisticated management transactions. Such a transaction either completes atomically on a set of devices, or is fully reversed, leaving every device in its pre-transaction state.

That is not a bonus feature. RFC 3535 recorded it as an operator requirement, in words worth keeping:

enable operators to concentrate on the configuration of the network as a whole rather than individual devices

SNMP and NETCONF, side by side
SNMP / MIBin use since the late 1980sNETCONF / YANGRFC 6241, after the 2002 workshop
Built mainly for
Message format
Transport
How many devices at a time
Language the data is defined in
Unsolicited events

Cells marked ⓘ have a reason behind them — click to read it.

Both manage networks. Almost every design choice differs, and each difference traces back to what each was built to do. Click any cell.

The messages are XML documents

This is the first protocol in the book whose messages are XML documents. The traditional kind has header fields and a body, as Figure 5.21’s SNMP PDU (Protocol Data Unit) does.

Few people can parse XML completely by eye. But the book’s point is that a NETCONF command is relatively human-readable, and much more reminiscent of HTTP (HyperText Transfer Protocol) and HTML (HyperText Markup Language) than an SNMP PDU is.

Here is a <get> command asking for all of a device’s configuration and operational data.

01 <?xml version="1.0" encoding="UTF-8"?>
02 <rpc message-id="101"
03    xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
04 <get/>
05 </rpc>

The RPC message itself spans lines 02–05, carries a message id of 101, and contains a single NETCONF <get> command. The device’s reply carries the matching id and all of the configuration data, in XML of course.

01 <?xml version="1.0" encoding="UTF-8"?>
02 <rpc-reply message-id="101"
03    xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
04 <!-- . . . all configuration data returned... -->
 . . .
</rpc-reply>

A second example, read line by line

This one, adapted from RFC 6241, sets the maximum transmission unit of an interface named Ethernet0/0 to 1500 bytes.

01 <?xml version="1.0" encoding="UTF-8"?>
02 <rpc message-id="101"
03   xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
04   <edit-config>
05     <target>
06        <running/>
07     </target>
08     <config>
09        <top xmlns="http://example.com/schema/1.2/config">
10           <interface>
11                <name>Ethernet0/0</name>
12                <mtu>1500</mtu>
13            </interface>
14        </top>
15     </config>
16   </edit-config>
17 </rpc>
The <edit-config> document, as the book reads it
Lines 02–17 · the remote procedure callstep 1 of 5
01 <?xml version="1.0" encoding="UTF-8"?>02 <rpc message-id="101"03 xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">04 <edit-config>05 <target>06 <running/>07 </target>08 <config>09 <top xmlns="http://example.com/schema/1.2/config">10 <interface>11 <name>Ethernet0/0</name>12 <mtu>1500</mtu>13 </interface>14 </top>15 </config>16 </edit-config>17 </rpc>the <rpc>, id 101

The RPC message itself spans lines 02 to 17 and has a message id of 101. The reply will carry the same id. Line 01 is the XML declaration and line 03 names the NETCONF namespace — neither is part of the call.

Adapted from RFC 6241. It sets the maximum transmission unit of the interface named Ethernet0/0 to 1500 bytes. The line numbers are the book’s own, added for teaching.

Read all steps as text
  1. Lines 02–17 · the remote procedure callThe RPC message itself spans lines 02 to 17 and has a message id of 101. The reply will carry the same id. Line 01 is the XML declaration and line 03 names the NETCONF namespace — neither is part of the call.
  2. Lines 04–15 · one NETCONF operationInside the call is exactly one command: <edit-config>. An RPC carries a single NETCONF operation, and Table 5.3 lists the ones the book covers.
  3. Line 06 · which configuration to changeA device may hold several configurations. <running/> names the one the device is actually using, so this change takes effect immediately rather than being staged.
  4. Lines 11–12 · and the actual changeThe interface named Ethernet0/0 gets a maximum transmission unit of 1500 bytes. Everything above these two lines is addressing: which call, which operation, which configuration, which device model, which interface.
  5. What the device sends backOnce the device has changed the interface’s MTU in the configuration, it responds with an OK reply, again as an XML document: <rpc-reply message-id="101"> containing a single <ok/> element. Same id, so the server knows which call succeeded.

Everyday picture

Two ways to change what a shop sells.

The SNMP (Simple Network Management Protocol) way is to phone each branch and read out a new price, one branch at a time. If you are cut off halfway through the list, half the branches have the new price and half do not, and nothing tells you which.

The NETCONF way is to send every branch a signed instruction and wait for all of them to confirm they can do it. Only then do you tell them all to apply it. If one branch cannot, nobody changes anything.

Where the picture stops. A shop assistant would notice an absurd price and phone back. A device applies whatever a valid configuration says, which is why YANG lets a modeller write down constraints that a configuration must satisfy before anybody sends it.

YANG

YANG is the data modelling language used to specify the structure, syntax and semantics of the network management data NETCONF uses. The book gives the comparison directly: YANG is to NETCONF much as SMI is to MIBs in SNMP.

All YANG definitions live in modules, and an XML document describing a device and its capabilities can be generated from a module.

Two properties matter beyond that.

A small set of built-in data types, as SMI also has.

Constraints. A data modeller can express conditions that any valid NETCONF configuration must satisfy. The book calls this a powerful aid in ensuring that configurations meet specified correctness and consistency constraints, and it is the thing SMI has no equivalent for.

YANG is also used to specify NETCONF notifications.

In plain words

SMI let you say what a value is: this object is a 32-bit read-only counter.

YANG lets you say what a configuration must be true for: this interface’s maximum transmission unit must be within these bounds, this field is required when that one is present.

That is the difference between describing data and validating it, and it is why the newer pair is aimed at configuration while the older one settled into monitoring.

Check yourself

Check yourself

0 of 7 answered
  1. 1.NETCONF and YANG exist because of a specific finding. What was it?

  2. 2.What does a NETCONF session begin with, after the secure connection is established?

  3. 3.Which NETCONF operation has no counterpart anywhere in SNMP, and why does it exist?

  4. 4.predictAn <edit-config> names <running/> as its target and sets an interface's MTU. When does the change take effect?

  5. 5.What is the relationship between YANG and SMI?

  6. 6.RFC 3535 recorded an operator requirement that NETCONF's multi-device transactions are meant to satisfy. What was it?

  7. 7.In NETCONF's own terminology, which end is called the "client"?

What to remember

  • Every NETCONF message is an XML document, including the configurations themselves. It is a remote procedure call over a secure session — connection-oriented and encrypted from the start, unlike SNMP over UDP (User Datagram Protocol) .
  • Four of the five operations are about configuration. <get-config>, <edit-config>, <lock> and <unlock> have no SNMP counterpart, and <lock> exists because NETCONF, SNMP and CLI commands can arrive at one device together.
  • Transactions span devices. A group of operations either completes on all of them or is fully reversed, which is what RFC 3535’s operators asked for.