What Type Data Is Associated With YANG?


Larry Thompson

In YANG, various types of data can be associated with different elements. These data types define the format and constraints for the values that can be assigned to these elements. Understanding the different types of data in YANG is crucial for building robust and interoperable network management systems.

Basic Data Types

YANG provides several built-in basic data types, such as:

  • string: Represents a sequence of characters.
  • boolean: Represents a true or false value.
  • decimal64: Represents decimal numbers with fixed precision.
  • int8, int16, int32, int64: Represent signed integer values of different sizes.
  • uint8, uint16, uint32, uint64: Represent unsigned integer values of different sizes.

Derived Data Types

In addition to basic data types, YANG also supports derived data types that are based on these basic types. Some examples include:

  • enumeration: Represents a set of named values. Only one value from the set can be assigned to an element.
  • bits: Represents a set of named bit positions.

    Multiple bit positions can be assigned to an element using bitwise operations.

  • union: Represents a choice between multiple data types. Only one type from the union can be assigned to an element.

User-Defined Data Types

In addition to built-in and derived data types, YANG allows you to define your own custom data types. This is particularly useful when you need to represent complex data structures or application-specific requirements.

To define a user-defined data type, you can use the typedef statement in YANG. This statement allows you to assign a name to a specific data type and specify its constraints.

Constraints and Validation

In YANG, you can define various constraints on the values that can be assigned to elements. These constraints ensure that the data adheres to specific rules and limitations.

You can use range, length, and other statements to define constraints on numerical ranges, string lengths, and other properties of the data.


typedef temperature {
  type int16 {
    range "0..100";

In this example, we define a user-defined data type called “temperature” that represents an integer value between 0 and 100 (inclusive).


In YANG, various types of data are associated with different elements. Understanding these types is essential for defining the structure and constraints of network management systems. By leveraging built-in, derived, and user-defined data types, along with appropriate constraints, developers can build robust and interoperable systems that effectively manage network resources.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy