I've read https://en.wikipedia.org/wiki/YANG but still having problems to understand the practical use of YANG
, and the benefits it provides. As I understand, it now is used not only by NETCONF, as was originally designed. YANG
is not a language in a common sense, as C
or python
for instance, i.e. whatever we write in YANG
is not compiled or translated; as I understand is is used as a reference model for a higher level library or application. Then the question is how does the high level code understand YANG
?

- 5,753
- 72
- 57
- 129

- 6,052
- 8
- 61
- 129
1 Answers
YANG is a specialized schema language, akin to XSD Schema or RelaxNG but (was) specific to NETCONF. Its goal is to model all content that is exchanged during protocol sessions between peers, as described in RFC6020:
YANG is a language used to model data for the NETCONF protocol. A YANG module defines a hierarchy of data that can be used for NETCONF- based operations, including configuration, state data, Remote Procedure Calls (RPCs), and notifications. This allows a complete description of all data sent between a NETCONF client and server.
The model defined by YANG may be consumed in the usual way - code generation for example, like what JAXB does for XSD Schema and Java. There are tools and server implementations out there that simply consume the YANG module set (a YANG model) and are ready to be used as dummy implementations. There are also tools that use the model to enable users to query a device, without actually implementing anything specific about the device. You could say that a set of YANG modules exposes the interface provided by a device. What you do with this interface is entirely up to you.
I suggest reading the high level overview provided in the specification:
Also check the wiki page of the ietf-netmod-yang tag.
Edit: You may also benefit from reading the An Architecture for Network Management Using NETCONF and YANG document. It further explains the architecture which YANG a is part of, including how different roles such as application developers should approach it (in the context of network management).
-
thanks for comment, it makes more sense to me now. Given that YANG defines types, as well as ranges which values can accept -- is it a responsibility of YANG-YIN conversion API/tool/etc. to validate types and values? – Mark Jan 07 '16 at 16:15
-
YANG-YIN conversion is only about presenting YANG modules in XML and it has nothing to do with data validation. YANG is used in context of some communication protocols. If a device claims that it implements certain YANG module, then it must implement the validation defined in the YANG module for all the data it transfers using that protocol. – Piotr Babij Jan 08 '16 at 06:53
-
@Mark, yes. Enforcing module compliance of instance documents is a responsibility of a tool that processes YANG/YIN. The tool may also be a human that implements the client or server or both by hand. – predi Jan 08 '16 at 12:46
-
@Piotr, Do you mean that a protocol using YANG models should be implementing YANG validation for whatever data it sends or receives in XML format? – Mark Jan 08 '16 at 14:51
-
1Although it was originally specified that way, YANG isn't specific to NETCONF any more. It is also used by other protocols, e.g. RESTCONF & CoAP, using multiple different encodings (XML, JSON, CBOR). There is also a proprietary gRPC implementation. – Rob Wilton Jun 16 '16 at 10:17
-
@Rob, this is explained in the linked documents. – predi Jun 16 '16 at 11:57