Method, device and equipment for determining complexity of yang model and storage medium
By transforming the YANG model into a directed graph and calculating its complexity index, the problem of determining the complexity of the YANG model is solved, thereby improving the data interaction efficiency between network devices and management systems.
Patent Information
- Application Number
- CN202210603166.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-30
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2042-05-30
AI Technical Summary
The lack of a systematic approach in the existing technology to determine the complexity of the YANG model leads to inefficient data interaction between network devices and management systems.
The YANG model is transformed into a directed graph. By determining the parameter values and weight values of multiple complexity indicators of the directed graph, the complexity of the YANG model is calculated, including the average values of indicators such as the number of nodes, the number of node attributes, the number of adjacent edges, and the number of reachable nodes. The test coefficients are then adjusted by weight adjustment to ensure that they meet the preset values.
Clearly defining the structural characteristics of the YANG model improves the interaction efficiency of the data hierarchy between network devices and the management and control system, allowing for the selection of a YANG model that meets the requirements.
Smart Images

Figure CN114996523B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of communication, and particularly relates to a method and device for determining complexity of a YANG model, equipment and a storage medium. BACKGROUND
[0002] A network configuration protocol (Netconf) is a standard protocol for installing, operating and deleting configurations of network equipment. YANG is a data modeling language, and a model established by using the YANG language is referred to as a YANG model. The YANG model can be used to describe configuration data, state data, remote procedure calls and notifications exchanged between network equipment and a management and control system related to the Netconf protocol, and to define a data hierarchy of the network equipment and the management and control system related to the Netconf protocol.
[0003] Generally, the higher the complexity of the YANG model, the more complex the data hierarchy exchanged between the network equipment and the management and control system related to the Netconf protocol. The network equipment needs to spend a long time in parsing data from the management and control system, and the management and control system needs to spend a long time in parsing data from the network equipment. Therefore, after the YANG model between the network equipment and the management and control system is established, the complexity of the YANG model needs to be determined first, and then it is determined whether the YANG model meets the requirements.
[0004] However, there is no systematic method for determining the complexity of the YANG model at present, and therefore, how to determine the complexity of the YANG model becomes a technical problem to be solved urgently. SUMMARY
[0005] The present application provides a method and device for determining complexity of a YANG model, equipment and a storage medium, to solve the technical problem of how to determine the complexity of the YANG model.
[0006] To achieve the above object, the present application adopts the following technical solutions:
[0007] In a first aspect, the present application provides a method for determining complexity of a YANG model, comprising: obtaining a YANG model corresponding to a target device; converting the YANG model into a directed graph; the directed graph comprising a plurality of nodes and a pointing relationship of the plurality of nodes; determining parameter values of a plurality of complexity indicators of the directed graph and corresponding weight values, the complexity indicators being used to represent structural relationships of the plurality of nodes of the directed graph; and determining the complexity of the YANG model according to the parameter values of the plurality of complexity indicators of the directed graph and the corresponding weight values.
[0008] Optionally, the parameter values of the plurality of complexity indicators comprise at least: a total number of the plurality of nodes, an average value of a number of attributes of the plurality of nodes, an average value of a number of adjacent edges of each node in the plurality of nodes, and an average value of a number of reachable nodes corresponding to each node in the plurality of nodes.
[0009] Optionally, the converting the YANG model into the directed graph comprises: converting the YANG model into a tree graph by using a preset tool, the tree graph comprising a root node and a plurality of leaf nodes having a hierarchical relationship; determining a pointing relationship between the root node and the plurality of leaf nodes having the hierarchical relationship; and determining the directed graph according to the pointing relationship between the root node and the plurality of leaf nodes having the hierarchical relationship.
[0010] Optionally, the determining the weight values of the plurality of complexity indicators comprises: determining an evaluation indicator of a first complexity indicator, the evaluation indicator of the first complexity indicator being used to represent an importance of the first complexity indicator compared with the plurality of complexity indicators, the first complexity indicator being any one of the plurality of complexity indicators; and performing normalization processing on the evaluation indicators of the plurality of complexity indicators to obtain a first weight value corresponding to each complexity indicator.
[0011] Optionally, the determining the complexity of the YANG model according to the parameter values of the plurality of complexity indicators of the directed graph and the corresponding weight values comprises: determining a parameter value of a random consistency indicator RI corresponding to the plurality of complexity indicators according to a number of the plurality of complexity indicators and a preset corresponding relationship, the number of the plurality of complexity indicators being positively correlated with the parameter value of the RI; calculating a test coefficient corresponding to the plurality of complexity indicators according to the first weight values of the plurality of complexity indicators and the RI; when the test coefficient is less than a preset value, calculating the complexity of the YANG model according to the parameter values of the plurality of complexity indicators and the corresponding first weight values; when the test coefficient is greater than or equal to the preset value, adjusting the first weight values corresponding to the plurality of complexity indicators to obtain a second weight value corresponding to each complexity indicator, and calculating the complexity of the YANG model according to the parameter values of the plurality of complexity indicators and the corresponding second weight values, the test coefficient corresponding to the second weight values of the plurality of complexity indicators being less than the preset value.
[0012] In a second aspect, the present application provides a device for determining a complexity of a YANG model, comprising: an obtaining unit, a converting unit, and a determining unit; the obtaining unit is configured to obtain a YANG model corresponding to a target device; the converting unit is configured to convert the YANG model into a directed graph; the directed graph comprises a plurality of nodes and a pointing relationship of the plurality of nodes; the determining unit is configured to determine parameter values of a plurality of complexity indicators of the directed graph and corresponding weight values, the complexity indicators being used to represent a structural relationship of the plurality of nodes of the directed graph; and the determining unit is further configured to determine the complexity of the YANG model according to the parameter values of the plurality of complexity indicators of the directed graph and the corresponding weight values.
[0013] Optionally, the parameter values of the plurality of complexity indicators comprise at least: a total number of the plurality of nodes, an average value of a number of attributes of the plurality of nodes, an average value of a number of adjacent edges of each node in the plurality of nodes, and an average value of a number of reachable nodes corresponding to each node in the plurality of nodes.
[0014] Optionally, the converting unit is specifically configured to: convert the YANG model into a tree graph using a preset tool, the tree graph comprising a root node and a plurality of leaf nodes having a hierarchical relationship; determine a pointing relationship between the root node and the plurality of leaf nodes having the hierarchical relationship; and determine a directed graph according to the pointing relationship between the root node and the plurality of leaf nodes having the hierarchical relationship.
[0015] Optionally, the determining unit is specifically configured to: determine an evaluation indicator of the first complexity indicator, the evaluation indicator of the first complexity indicator being used to represent an importance of the first complexity indicator compared with the plurality of complexity indicators, the first complexity indicator being any one of the plurality of complexity indicators; and normalize the evaluation indicators of the plurality of complexity indicators to obtain a first weight value corresponding to each complexity indicator.
[0016] Optionally, the determining unit is specifically configured to: determine a parameter value of a random consistency indicator RI corresponding to the plurality of complexity indicators according to a number of the plurality of complexity indicators and a preset corresponding relationship, the number of the plurality of complexity indicators being positively correlated with the parameter value of the RI; calculate a test coefficient corresponding to the plurality of complexity indicators according to the first weight values of the plurality of complexity indicators and the RI; when the test coefficient is less than a preset value, calculate the complexity of the YANG model according to the parameter values of the plurality of complexity indicators and the corresponding first weight values; and when the test coefficient is greater than or equal to the preset value, adjust the first weight values corresponding to the plurality of complexity indicators to obtain a second weight value corresponding to each complexity indicator, and calculate the complexity of the YANG model according to the parameter values of the plurality of complexity indicators and the corresponding second weight values, the test coefficient corresponding to the second weight values of the plurality of complexity indicators being less than the preset value.
[0017] In a third aspect, the present application provides a determining device, the determining device comprising: a processor, a communication interface and a memory; wherein the memory is configured to store one or more programs, the one or more programs comprising computer execution instructions; when the determining device is running, the processor executes the computer execution instructions stored in the memory, so that the determining device executes the YANG model complexity determination method of any one of the first aspect and various optional implementation manners thereof.
[0018] In a fourth aspect, the present application provides a computer readable storage medium storing one or more programs, the one or more programs comprising instructions, when a computer executes the instructions, the computer executes the YANG model complexity determination method of any one of the first aspect and various optional implementation manners thereof.
[0019] Based on the technical solutions provided in the embodiments of the present application, the YANG model corresponding to the target device is acquired, the YANG model is converted into a directed graph, the directed graph includes multiple nodes and a pointing relationship of the multiple nodes, parameter values of multiple complexity indexes of the directed graph are determined and corresponding weight values are determined, the complexity indexes are used to represent structural relationships of the multiple nodes of the directed graph, and the complexity of the YANG model is determined according to the parameter values of the multiple complexity indexes of the directed graph and the corresponding weight values. In this way, the structure characteristics of the YANG model can be determined more clearly by the determining apparatus, and the complexity of the YANG model can be determined through each complexity index in the directed graph and the corresponding weight, so that the YANG model with a complexity meeting the requirements can be selected, and the efficiency of defining the data hierarchy of the network device and the management and control system related to the Netconf is improved. BRIEF DESCRIPTION OF DRAWINGS
[0020] Figure 1 A structural schematic diagram of a network architecture provided in the embodiments of the present application;
[0021] Figure 2 A structural schematic diagram of a determining apparatus provided in the embodiments of the present application;
[0022] Figure 3 A flow schematic diagram of a determining method provided in the embodiments of the present application;
[0023] Figure 4 A schematic diagram of a directed graph provided in the embodiments of the present application;
[0024] Figure 5 A flow schematic diagram of a determining method provided in the embodiments of the present application;
[0025] Figure 6 A structural schematic diagram of a determining apparatus provided in the embodiments of the present application. DETAILED DESCRIPTION
[0026] The determining method, apparatus, device and storage medium for the complexity of a YANG model provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0027] The term “and / or” in the present document merely describes an association relationship of associated objects, and indicates that there can be three relationships, for example, A and / or B can represent the following three cases: A exists alone, A and B exist simultaneously, and B exists alone.
[0028] The terms “first” and “second” and the like in the specification and the accompanying drawings of the present application are used to distinguish different objects, or to distinguish different treatments of the same object, and are not used to describe a specific order of the objects.
[0029] Furthermore, the terms "comprise", "comprising", "have", "having", "include", "including", "contain", "containing", "provide", "providing", "offer", "offering", "specify", "specifying", and any variations thereof in the description of the application are intended to cover a non-exclusive inclusion. For example, a process, method, system, product, or apparatus that comprises a list of steps or elements is not necessarily limited to the listed steps or elements, but can optionally include additional steps or elements not expressly listed or inherent to such process, method, system, product, or apparatus.
[0030] It should be noted that the terms "exemplary" or "for example" in the embodiments of the present application are used to mean "an example of" or "an example", not "an ideal". Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or having more advantages than other embodiments or design schemes. Rather, the use of "exemplary" or "for example" is intended to present the relevant concept in a specific manner.
[0031] In the description of the present application, the meaning of "a plurality of" is two or more, unless otherwise specified.
[0032] The Netconf protocol is a standard protocol for installing, operating and deleting the configuration of a network device. YANG is a data modeling language, and a model established using the YANG language is referred to as a YANG model. The YANG model can be used to describe the configuration data, state data, remote procedure calls and notifications exchanged between a network device and a management and control system related to the Netconf protocol, and to define the data hierarchy of the network device and the management and control system related to the Netconf protocol.
[0033] Generally, the higher the complexity of the YANG model, the more complex the data hierarchy exchanged between the network device and the management and control system related to the Netconf protocol. The network device needs to spend a long time in parsing the data from the management and control system, and the management and control system needs to spend a long time in parsing the data from the network device. Therefore, after the YANG model between the network device and the management and control system is established, the complexity of the YANG model needs to be determined, and then it is determined whether the YANG model meets the requirements.
[0034] However, there is currently no systematic method for determining the complexity of the YANG model. Therefore, how to determine the complexity of the YANG model has become a technical problem to be solved.
[0035] In view of this, embodiments of this application provide a method for determining the complexity of a YANG model, comprising: obtaining a YANG model corresponding to a target device, wherein the YANG model is associated with a configuration file of the target device; converting the YANG model into a directed graph; wherein the directed graph includes multiple nodes and the pointing relationships between the nodes; determining the parameter values and corresponding weight values of multiple complexity indicators of the directed graph, wherein the complexity indicators are used to characterize the structural relationships between the multiple nodes of the directed graph; and determining the complexity of the YANG model based on the parameter values and corresponding weight values of the multiple complexity indicators of the directed graph.
[0036] The following description, in conjunction with the accompanying drawings, illustrates a method for determining the complexity of a YANG model (hereinafter referred to as the determination method) provided in an embodiment of this application.
[0037] The determination method provided in the embodiments of this application can be applied to... Figure 1 In the network architecture shown, such as Figure 1 As shown, the network architecture 10 may include a network device 11 and a determining device 12. The network device 11 may be communicatively connected to the determining device 12. For example, they may be wirelessly connected.
[0038] Network device 11 may include one or more YANG models. YANG models can be used to define the data hierarchy of network devices and management systems related to Netconf. Higher complexity of the YANG model results in lower efficiency in defining the data hierarchy of network devices and management systems related to Netconf. Conversely, lower complexity of the YANG model results in higher efficiency in defining the data hierarchy of network devices and management systems related to Netconf. For example, network device 11 can be a computer, router, switch, gateway, etc.
[0039] The determining device 12 is used to determine the complexity of one or more YANG models included in the network device 11. For example, the determining device 12 can be a server, a computer, etc.
[0040] It should be noted that, Figure 1 This is merely an illustrative architecture diagram, except... Figure 1 In addition to the functional units shown, the network architecture may also include other functional units, which are not limited in this application embodiment.
[0041] In practical implementation, Figure 1 The various devices in the process can adopt Figure 2 The shown composition structure, or including Figure 2 The components shown. Figure 2 This is a schematic diagram of the composition of a determining device 20 provided in an embodiment of this application. The determining device 20 includes a processor 201, a communication interface 202, a communication line 203, and a memory 204.
[0042] The processor 201 can be a CPU, a general-purpose processor, a network processor (NP), a digital signal processor (DSP), a microprocessor, a microcontroller, a programmable logic device (PLD), or any combination thereof. The processor 201 can also be other devices with processing capabilities, such as a circuit, a device, or a software module, without limitation. In an example, the processor 201 can include one or more CPUs, such as CPU0 and CPU1 in FIG. 1. Figure 2
[0043] The communication interface 202 is configured to perform data processing with other devices or other data processing networks. The other data processing networks can be an Ethernet, a radio access network (RAN) device, a wireless local area networks (WLAN), or the like. The communication interface can be a module, a circuit, a data processing interface, or any device capable of performing data processing.
[0044] The communication line 203 is configured to transmit messages between components included in the determination device.
[0045] The memory 204 is configured to store instructions. The instructions can be a computer program.
[0046] The memory 204 can be a read-only memory (ROM) or other type of static storage device that can store static messages and / or instructions, a random access memory (RAM) or other type of dynamic storage device that can store messages and / or instructions, an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM), or other optical disk storage, a magneto-optical disk, a magnetic disk storage or other magnetic storage devices, or the like, without limitation.
[0047] It should be noted that the memory 204 can exist independently of the processor 201, or can be integrated with the processor 201. The memory 204 can be used to store instructions or program codes or some network data, etc. The memory 302 can be located in the determination apparatus 20 or outside the determination apparatus 20, without limitation. The processor 201 is configured to execute the instructions stored in the memory 204, so as to implement the determination method provided in the embodiments of the present application.
[0048] As an optional implementation, the determination apparatus 20 includes a plurality of processors, for example, in addition to the processor 201 in the determination apparatus 20, the determination apparatus 20 can further include a processor 207. Figure 2
[0049] As an optional implementation, the determination apparatus 20 further includes an output device 205 and an input device 206. For example, the input device 206 is a keyboard, a mouse, a microphone or a joystick, and the output device 205 is a display screen, a speaker, etc.
[0050] In the embodiments of the present application, the chip system can be composed of a chip, or can include a chip and other discrete devices.
[0051] In addition, the actions, terms, etc. involved among the embodiments of the present application can be mutually referred to, without limitation. The message name or parameter name in the message exchanged between the devices in the embodiments of the present application is only an example, and other names can also be used in the specific implementation, without limitation.
[0052] The determination method provided in the embodiments of the present application can be applied to the determination apparatus shown in the foregoing Figure 1 or Figure 2 .
[0053] It should be noted that the execution subject of the determination method provided in the present application is the determination apparatus, or can be a chip or a system on chip, etc. in the determination apparatus, without limitation.
[0054] As shown in Figure 3 , the determination method provided in the embodiments of the present application can include S301-S304.
[0055] S301, the determination apparatus acquires a YANG model corresponding to a target device.
[0056] The determination apparatus can be the determination apparatus 12 in the foregoing Figure 1 , or can be a device such as a chip in the determination apparatus 12. The target device is a device such as a chip in the determination apparatus 12. Figure 1 The network device 11 in the device 11 in the network device 11, such as a chip. The YANG model can include multiple types, for example, can be ietf-device-pkg-2019-01-10@1.1.0, ietf-L3VPN-pkg-2019-08-01@1.0.0 and ietf-dc-fabric-topology@2019-02-25.yang and the like.
[0057] In a possible implementation, the determining apparatus can use the restconf protocol to obtain the corresponding YANG model from the target device.
[0058] The restconf protocol is a hyper text transfer protocol (HTTP) based protocol, which can add, delete, modify, query and the like operation on the data of the network device.
[0059] It should be noted that before obtaining the corresponding YANG model from the target device, the determining apparatus can also verify the identity information of the operation user. For example, the determining apparatus can output first prompt information in response to the request operation. The first prompt information is used to prompt the input of verification information. For example, the verification information can include the user's account and the corresponding password. The determining apparatus can also be provided with an input device (such as a keyboard, a touch screen). The user can input the verification information through the input device. Then the determining apparatus can determine whether the user has the right to obtain the YANG model according to the received verification information. In the case of determining that the input account and the account password are correct, the determining apparatus can send a request information to the target device, and the request information is used to request the corresponding YANG model on the target device.
[0060] S302, the determining apparatus converts the YANG model into a directed graph.
[0061] The directed graph can include multiple nodes and the pointing relationship of multiple nodes.
[0062] In a possible implementation, the determining apparatus can convert the YANG model into a tree graph through a preset tool, and determine the directed graph according to the pointing relationship between the root node and the multiple leaf nodes with hierarchical relationship.
[0063] The preset tool can be set according to the need. For example, it can be YANG Designer tool or PYANG tool and the like. The tree graph can include a root node and multiple leaf nodes with hierarchical relationship.
[0064] An example is taken as ietf-dc-fabric-topology@2019-02-25.yang in YANG model. The specific content of ietf-dc-fabric-topology@2019-02-25.yang can refer to prior art and will not be described here. The tree graph converted by the determination apparatus by using the preset tool is as follows:
[0065]
[0066]
[0067] It should be noted that "!" represents a container node, "*" represents a list node and a left-list node, "?" represents an optional node, "rw" represents configuration data (read and write), and "ro" represents state data (read only).
[0068] In an example, the determination apparatus can abstract the module name of the YANG model in the above tree graph as a root node, a container node, and a list node in the directed graph, abstract the leaf node at the bottom layer as an attribute of the node at the upper layer, and not display the leaf node in the directed graph, to obtain a plurality of nodes as shown in Table 1.
[0069] Table 1 node table
[0070] Node Node content Node 1 ietf-dc-fabric-topology Node 2 / nw:networks / nw:network / nw:network-types Node 3 fabric-network Node 4 / nw:networks / nw:network / nw:node Node 5 fabric-attributes Node 6 vni-capacity Node 7 options Node 8 device-nodes Node 9 device-links Node 10 device-ports Node 11 / nw:networks / nw:network / nw:node / nt:termination-point Node 12 fport-attributes
[0071] It should be noted that Table 1 is only an example and can include other nodes without limitation.
[0072] In an example, in combination with the above tree graph and Table 1, the directed graph generated according to the tree graph in the embodiment of the application can be as shown in Table 2. Figure 4 Figure 4 In Table 2, the node hierarchy of the directed graph can include four hierarchies. The four hierarchies can have a pointing relationship.
[0073] The first hierarchy includes node 1. Node 1 can point to node 2, node 4, and node 11 in the second hierarchy.
[0074] The second hierarchy includes node 2, node 4, and node 11. Node 2 can point to node 3 in the third hierarchy, node 4 can point to node 5 in the third hierarchy, and node 11 can point to node 12 in the third hierarchy.
[0075] The third hierarchy includes node 3, node 5, and node 12. Node 5 points to node 6, node 7, node 8, node 9, and node 10 in the fourth hierarchy.
[0076] The fourth level includes: node 6, node 7, node 8, node 9, node 10.
[0077] In a possible implementation, the determining apparatus can further convert the YANG model into a unified model language (UML) diagram, and the UML diagram contains relationships between various nodes. For example, the relationships can include inheritance, aggregation, association, and the like. For details, refer to the prior art, which will not be described here.
[0078] S303, the determining apparatus determines parameter values of a plurality of complexity indicators of the directed graph and corresponding weight values.
[0079] The complexity indicators are used to represent the structural relationships of the plurality of nodes of the directed graph. The parameter values of the plurality of complexity indicators at least include: a total number of the plurality of nodes, an average value of a number of attributes of the plurality of nodes, an average value of a number of adjacent edges of each node in the plurality of nodes, and an average value of a number of reachable nodes corresponding to each node in the plurality of nodes. The total number of the plurality of nodes, the average value of the number of attributes of the plurality of nodes, the average value of the number of adjacent edges of each node in the plurality of nodes, and the average value of the number of reachable nodes corresponding to each node in the plurality of nodes will be described below.
[0080] 1. The total number of the plurality of nodes.
[0081] The total number of the plurality of nodes can be the sum of the number of root nodes, container nodes (container), and list nodes in the YANG model. For example, taking the YANG model ietf-dc-fabric-topology@2019-02-25.yang as an example, the specific description of the nodes can refer to Table 1 above, which will not be described here. The total number of the plurality of nodes can be 12.
[0082] 2. The average value of the number of attributes of the plurality of nodes.
[0083] The attributes of the nodes can include a gateway mode, a fabric ID, a name, a type, a minimum value, a maximum value, a description, a traffic behavior, a capability supported, a device reference, a role, a device port, a tunnel option, a link reference, a bandwidth, and the like. The determining apparatus can determine an average value of the number of attributes of the plurality of nodes by calculating a ratio of the number of attributes of the plurality of nodes to the number of the plurality of nodes. For example, taking the YANG model ietf-dc-fabric-topology@2019-02-25.yang as an example, the number of attributes of the plurality of nodes is 20, and the total number of the plurality of nodes is 12, and thus the average value of the number of attributes of the plurality of nodes can be 20 / 12=1.67.
[0084] 3. An average value of the number of adjacent edges of each node in the plurality of nodes.
[0085] The average value of the number of adjacent edges of each node in the plurality of nodes can be determined according to the adjacency matrix A and the number of nodes. For example, taking the YANG model ietf-dc-fabric-topology@2019-02-25.yang as an example, the adjacency matrix A can be:
[0086]
[0087] It should be noted that "0" in the adjacency matrix A represents that two nodes are not adjacent, and "1" represents that two nodes are adjacent. For example, "1" in the first row and the second column represents that node 1 is adjacent to node 2, "0" in the first row and the third column represents that node 1 is not adjacent to node 3, and "1" in the second row and the third column represents that node 2 is adjacent to node 3. Thus, the determining apparatus can calculate that the number of adjacent edges is 11, and thus the average value of the number of adjacent edges of each node in the plurality of nodes can be 11 / 12=0.92.
[0088] 4. An average value of the number of reachable nodes corresponding to each node in the plurality of nodes.
[0089] The average value of the number of reachable nodes corresponding to each node in the plurality of nodes can be determined according to the reachable matrix B and the number of nodes.
[0090] For example, taking the YANG model of ietf-dc-fabric-topology@2019-02-25.yang as an example, the reachable matrix B can be:
[0091]
[0092] It should be noted that "0" in the reachable matrix B indicates that two nodes are not reachable, and "1" indicates that two nodes are reachable. The "1" in the first row and the second column indicates that node 1 can reach node 2, the "1" in the first row and the third column indicates that node 1 can reach node 3, and the "0" in the second row and the third column indicates that node 2 cannot reach node 3. Thus, the number of reachable nodes can be calculated to be 35, and the average of the number of reachable nodes corresponding to each node in the plurality of nodes can be 35 / 12 = 2.92.
[0093] In a possible implementation, the determining apparatus can determine an evaluation index of each complexity in the plurality of complexity indexes, and perform geometric averaging and normalization processing on the evaluation indexes of the plurality of complexity indexes to obtain a first weight value corresponding to each complexity index.
[0094] For example, taking the first complexity as an example, the first complexity index is any one of the plurality of complexity indexes, and the evaluation index of the first complexity index can be used to represent the importance of the first complexity index compared to the plurality of complexity indexes. For example, the evaluation index of the first complexity index can be as shown in Table 2.
[0095] Table 2: Evaluation index of first complexity index
[0096] C1 C2 C3 C4 C1 1 1 / 4 1 / 3 1 / 5 C2 4 1 2 1 / 2 C3 3 1 / 2 1 1 / 3 C4 5 2 3 1
[0097] It should be noted that Table 2 is only exemplary, and the first complexity index can also include other numerical values, which are not limited.
[0098] It should be noted that C1 represents the total number of the plurality of nodes, C2 represents the average of the number of attributes of the plurality of nodes, C3 represents the average of the number of adjacent edges of each node in the plurality of nodes, and C4 represents the average of the number of reachable nodes corresponding to each node in the plurality of nodes. The importance of the specific numerical values in Table 2 can be as shown in Table 3.
[0099] Table 3: Importance table
[0100] Complexity indicator Ci is more important than complexity indicator Cj Numerical value Equally important 1 Slightly more important 3 More important 5 Strongly important 7 Extremely important 9 Mid value between two adjacent judgments 2,4,6,8
[0101] It should be noted that Table 3 is only exemplary, and the importance ratio of the complexity index Ci to the complexity index Cj can also be other numerical values, which are not limited. Ci and Cj are any one of C1-C4.
[0102] For example, when the ratio of C2 to C1 is 4, it indicates that the importance of C2 to C1 is between slightly important and relatively important. When the ratio of C3 to C1 is 3, it indicates that the importance of C3 to C1 is slightly important.
[0103] In the case where the evaluation indexes of the first complexity indicators are as shown in Table 2, the evaluation indexes W' of the plurality of complexity indicators after geometric averaging can be respectively:
[0104]
[0105] Further, the first weight value W corresponding to the normalized W' can be:
[0106]
[0107] S304, the determining device determines the complexity of the YANG model according to the parameter values of the plurality of complexity indicators of the directed graph and the corresponding weight values.
[0108] In one possible implementation, the determining device can perform weighted summation according to the parameter values of the plurality of complexity indicators and the corresponding weight values to determine the complexity of the YANG model.
[0109] For example, in the case where the parameter values of the plurality of complexity indicators of the directed graph and the corresponding weight values are as shown in S303, i.e., the total number of the plurality of nodes is 12, the average of the number of attributes of the plurality of nodes is 1.67, the average of the number of adjacent edges of each node in the plurality of nodes is 0.92, and the average of the number of reachable nodes corresponding to each node in the plurality of nodes is 2.92. The corresponding weight values are 0.08, 0.28, 0.17, and 0.47 respectively. The complexity CPX of the YANG model can be:
[0110] CPX = 0.08 * 12 + 0.28 * 1.67 + 0.17 * 0.92 + 0.47 * 2.92 = 2.95.
[0111] Based on the technical solutions provided in the embodiments of the present application, the YANG model corresponding to the target device is acquired, the YANG model is associated with the configuration file of the target device, the YANG model is converted into a directed graph, the directed graph includes multiple nodes and a pointing relationship of the multiple nodes, the parameter values of multiple complexity indexes of the directed graph and corresponding weight values are determined, the complexity indexes are used to represent the structural relationship of the multiple nodes of the directed graph, and the complexity of the YANG model is determined according to the parameter values of the multiple complexity indexes of the directed graph and the corresponding weight values. In this way, the structural features of the YANG model can be determined more clearly by the determining apparatus, and the complexity of the YANG model can be determined through each complexity index in the directed graph and the corresponding weight, so that the YANG model meeting the requirement in complexity can be selected, and the efficiency of defining the data hierarchy of the network device and the management and control system related to the Netconf is improved.
[0112] In a possible embodiment, the method for determining the complexity of the YANG model provided in the embodiments of the present application can include the following S501-S504 as shown in the following table 3. Figure 5
[0113] S501, the determining apparatus determines the parameter value of the random consistency index RI corresponding to the multiple complexity indexes according to the number of the multiple complexity indexes and a preset corresponding relationship.
[0114] In this embodiment, the number of the multiple complexity indexes is positively correlated with the parameter value of the RI, and the preset corresponding relationship can be set as required. For example, the preset corresponding relationship can be shown in the following table 4.
[0115] Table 4: Preset corresponding relationship
[0116]
[0117] It should be noted that the table 4 is only exemplary, and the number of the complexity indexes and the corresponding RI can also be other values, for example, when the number of the complexity indexes is 11, the RI can be 1.53. No limitation is given.
[0118] S502, the determining apparatus calculates the inspection coefficient corresponding to the multiple complexity indexes according to the first weight value of the multiple complexity indexes and the RI.
[0119] In this embodiment, the inspection coefficient can be used to detect whether the weight values of the multiple complexity indexes meet the consistency inspection. When the inspection coefficient is greater than a preset value, it means that the consistency inspection is passed, and when the inspection coefficient is less than or equal to the preset value, it means that the consistency inspection is failed.
[0120] As a possible implementation manner, the determining apparatus can calculate the inspection coefficient corresponding to the multiple complexity indexes through a first preset formula.
[0121] wherein the first preset formula is related to the first weight values of the plurality of complexity indicators and the RI.
[0122] In an example, the first preset formula can be:
[0123]
[0124] wherein CR represents a checking coefficient, and CI represents a consistency indicator. The CI can be determined by a second preset formula. For example, the second preset formula can be:
[0125]
[0126] wherein λ max represents a maximum eigenvalue of the first weight values W, and the calculation method of the maximum eigenvalue can refer to the prior art, which is not described herein. n represents the number of complexity indicators. For example, when the number n of complexity indicators is 4, the maximum eigenvalue λ max of W can be calculated as 4.05,
[0127] Further, the determination apparatus can determine, according to the preset correspondence relationship in Table 4 above, that the RI = 0.9 when the number n of complexity indicators is 4.
[0128] S503, when the checking coefficient is less than a preset value, the determination apparatus calculates the complexity of the YANG model according to the parameter values of the plurality of complexity indicators and the corresponding first weight values.
[0129] wherein the preset value can be set as needed. For example, the preset value can be 0.1, 0.09, 0.11, etc. which is not limited.
[0130] It should be noted that the specific process of calculating the complexity of the YANG model according to the parameter values of the plurality of complexity indicators and the corresponding first weight values by the determination apparatus can refer to the description of S304 above, which is not described herein.
[0131] S504, when the checking coefficient is greater than or equal to the preset value, the determination apparatus adjusts the first weight values corresponding to the plurality of complexity indicators to obtain the second weight values corresponding to each complexity indicator, and calculates the complexity of the YANG model according to the parameter values of the plurality of complexity indicators and the corresponding second weight values.
[0132] wherein the checking coefficient corresponding to the second weight values of the plurality of complexity indicators is less than the preset value.
[0133] Therefore, the determining apparatus determines the complexity of the YANG model by calculating the inspection coefficient in the case that the inspection coefficient is less than the preset value, which can avoid the phenomenon that the weight of the complexity index is unreasonable. The setting may exist contradictory situations. For example, the importance of C1 is greater than that of C2, but the weight of C1 is less than that of C2.
[0134] The embodiments of the present application can divide the function modules or function units of the server according to the above-mentioned method examples. For example, each function module or function unit can be divided according to each function, or two or more functions can be integrated in two modules. The integrated modules can be realized in the form of hardware or in the form of software function modules or function units. The division of the modules or units in the embodiments of the present application is illustrative, and is only a logical function division. In actual implementation, another division mode can be used.
[0135] Figure 6 A possible structure diagram of the determining apparatus involved in the above-mentioned embodiments is shown. As shown in Figure 6 The determining apparatus 60 includes an acquisition unit 601, a conversion unit 602, and a determining unit 603.
[0136] The acquisition unit 601 is configured to acquire a YANG model corresponding to a target device, the YANG model being associated with a configuration file of the target device. For example, as shown in Figure 3 The acquisition unit 601 can be configured to perform S301.
[0137] The conversion unit 602 is configured to convert the YANG model into a directed graph, the directed graph including a plurality of nodes and a pointing relationship of the plurality of nodes. For example, as shown in Figure 3 The conversion unit 602 can be configured to perform S302.
[0138] The determining unit 603 is configured to determine parameter values of a plurality of complexity indexes of the directed graph and corresponding weight values, the complexity indexes being used to represent structural relationships of the plurality of nodes of the directed graph. For example, as shown in Figure 3 The determining unit 603 can be configured to perform S303.
[0139] The determining unit 603 is further configured to determine the complexity of the YANG model according to the parameter values of the plurality of complexity indexes of the directed graph and the corresponding weight values. For example, as shown in Figure 3 The determining unit 603 can be configured to perform S304.
[0140] In a possible design, the parameter values of the plurality of complexity indexes at least include: a total number of the plurality of nodes, an average value of a number of attributes of the plurality of nodes, an average value of a number of adjacent edges of each node in the plurality of nodes, and an average value of a number of reachable nodes corresponding to each node in the plurality of nodes.
[0141] In a possible design, the converting unit 602 is specifically configured to: convert the YANG model into a tree graph by using a preset tool, the tree graph including a root node and a plurality of leaf nodes having a hierarchical relationship; and determine a pointing relationship between the root node and the plurality of leaf nodes having the hierarchical relationship, and determine a directed graph according to the pointing relationship between the root node and the plurality of leaf nodes having the hierarchical relationship.
[0142] In a possible design, the determining unit 603 is specifically configured to: determine an evaluation index of a first complexity index, the evaluation index of the first complexity index being used to represent an importance of the first complexity index compared with the plurality of complexity indexes, and the first complexity index being any one of the plurality of complexity indexes; and normalize the evaluation indexes of the plurality of complexity indexes to obtain a first weight value corresponding to each complexity index.
[0143] In a possible design, the determining unit 603 is specifically configured to: determine a parameter value of a random consistency index RI corresponding to the plurality of complexity indexes according to a number of the plurality of complexity indexes and a preset corresponding relationship, the number of the plurality of complexity indexes being positively correlated with the parameter value of the RI; calculate a test coefficient corresponding to the plurality of complexity indexes according to the first weight values of the plurality of complexity indexes and the RI; when the test coefficient is less than a preset value, calculate the complexity of the YANG model according to the parameter values of the plurality of complexity indexes and the corresponding first weight values; and when the test coefficient is greater than or equal to the preset value, adjust the first weight values corresponding to the plurality of complexity indexes to obtain a second weight value corresponding to each complexity index, and calculate the complexity of the YANG model according to the parameter values of the plurality of complexity indexes and the corresponding second weight values, the test coefficient corresponding to the second weight values of the plurality of complexity indexes being less than the preset value. For example, as shown in FIG. 5, the determining unit 603 can be configured to perform S501-S504. Figure 5
[0144] Those skilled in the art can clearly understand the system, apparatus and unit by referring to the description of the foregoing embodiments. For the convenience and brevity of description, only the division of the foregoing functional modules is taken as an example for description. In actual applications, the foregoing functions can be completed by different functional modules according to requirements, that is, the internal structure of the apparatus is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, apparatus and unit described above can refer to the corresponding process in the foregoing method embodiments, which will not be described herein again.
[0145] The embodiment of the present application provides a computer program product containing instructions, when the computer program product is executed on a computer, the computer is caused to execute the method for determining complexity of a YANG model in the above method embodiment.
[0146] The embodiment of the present application also provides a computer readable storage medium, and the computer readable storage medium stores instructions, when a determining device executes the instructions, the determining device executes each step in the method flow shown in the method embodiment.
[0147] The computer readable storage medium may, for example, be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination of the above. More specific examples (a non-exhaustive list) of the computer readable storage medium include an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a register, a hard disk, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above, or any other form of computer readable storage medium known in the art. An exemplary storage medium is coupled to the processor such that the processor can read information from, and write information to, the storage medium. Of course, the storage medium can be a part of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). In the embodiment of the present application, the computer readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device.
[0148] The above merely provides the specific implementation of the present application, but the protection scope of the present application is not limited to this. Any change or replacement within the technical scope disclosed in the present application should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method for determining the complexity of a YANG model, characterized in that, The method comprises: determining a device to obtain a corresponding YANG model from a target device using a restconf protocol; the target device is a network device or a device in the network device; determining a device to convert the YANG model into a directed graph; the directed graph comprises a plurality of nodes and a pointing relationship of the plurality of nodes; wherein the plurality of nodes comprises a root node, a container node, a leaf node and an optional node; the pointing relationship of the plurality of nodes comprises inheritance, aggregation and association; determining parameter values of a plurality of complexity indicators of the directed graph and corresponding weight values, the complexity indicators being used to represent structural relationships of the plurality of nodes of the directed graph; the parameter values of the plurality of complexity indicators comprise: a total number of the plurality of nodes, an average value of a number of attributes of the plurality of nodes, an average value of a number of adjacent edges of each node in the plurality of nodes, and an average value of a number of reachable nodes corresponding to each node in the plurality of nodes; determining a complexity of the YANG model according to the parameter values of the plurality of complexity indicators of the directed graph and the corresponding weight values, comprising: determining a parameter value of a random consistency indicator RI corresponding to the plurality of complexity indicators according to a number of the complexity indicators and a preset corresponding relationship, the number of the plurality of complexity indicators being positively correlated with the parameter value of the RI; calculating a test coefficient corresponding to the plurality of complexity indicators according to the first weight values of the plurality of complexity indicators and the RI; when the test coefficient is less than a preset value, calculating the complexity of the YANG model according to the parameter values of the plurality of complexity indicators and the corresponding first weight values; when the test coefficient is greater than or equal to the preset value, adjusting the first weight values corresponding to the plurality of complexity indicators to obtain second weight values corresponding to each complexity indicator, and calculating the complexity of the YANG model according to the parameter values of the plurality of complexity indicators and the corresponding second weight values, the test coefficient corresponding to the second weight values of the plurality of complexity indicators being less than the preset value.
2. The method of claim 1, wherein, The parameter values of the plurality of complexity indicators at least comprise: the total number of the plurality of nodes, the average value of the number of attributes of the plurality of nodes, the average value of the number of adjacent edges of each node in the plurality of nodes, and the average value of the number of reachable nodes corresponding to each node in the plurality of nodes.
3. The method of claim 2, wherein, The conversion of the YANG model into a directed graph comprises: using a preset tool to convert the YANG model into a tree graph, the tree graph comprising a root node and a plurality of leaf nodes having a hierarchical relationship; determining a pointing relationship between the root node and the plurality of leaf nodes having a hierarchical relationship; determining the directed graph according to the pointing relationship between the root node and the plurality of leaf nodes having a hierarchical relationship.
4. The method of claim 3, wherein, Determining the weight values of the plurality of complexity indicators comprises: determining an evaluation indicator of a first complexity indicator, the evaluation indicator of the first complexity indicator being used to represent an importance of the first complexity indicator compared to the plurality of complexity indicators, the first complexity indicator being any one of the plurality of complexity indicators; The evaluation indexes of the plurality of complexity indexes are normalized to obtain a first weight value corresponding to each complexity index.
5. A device for determining the complexity of a YANG model, characterized in that, The device comprises an acquisition unit, a conversion unit and a determination unit. The acquisition unit is configured to acquire a corresponding YANG model from a target device using a restconf protocol, the target device being a network device or a device in the network device. The conversion unit is configured to convert the YANG model into a directed graph, the directed graph comprising a plurality of nodes and a pointing relationship of the plurality of nodes, wherein the plurality of nodes comprise a root node, a container node, a leaf node and an optional node, and the pointing relationship of the plurality of nodes comprises inheritance, aggregation and association. The determination unit is configured to determine parameter values of a plurality of complexity indexes of the directed graph and corresponding weight values, the complexity indexes being used to represent structural relationships of the plurality of nodes of the directed graph, and the parameter values of the plurality of complexity indexes comprising a total number of the plurality of nodes, an average value of a number of attributes of the plurality of nodes, an average value of a number of adjacent edges of each node in the plurality of nodes, and an average value of a number of reachable nodes corresponding to each node in the plurality of nodes. The determination unit is further configured to determine complexity of the YANG model according to the parameter values of the plurality of complexity indexes of the directed graph and the corresponding weight values. The determination unit is specifically configured to: determine a parameter value of a random consistency index RI corresponding to the plurality of complexity indexes according to a number of the plurality of complexity indexes and a preset corresponding relationship, the number of the plurality of complexity indexes being positively correlated with the parameter value of the RI; calculate a test coefficient corresponding to the plurality of complexity indexes according to the first weight values of the plurality of complexity indexes and the RI; when the test coefficient is less than a preset value, calculate the complexity of the YANG model according to the parameter values of the plurality of complexity indexes and the corresponding first weight values; when the test coefficient is greater than or equal to the preset value, adjust the first weight values corresponding to the plurality of complexity indexes to obtain second weight values corresponding to each complexity index, and calculate the complexity of the YANG model according to the parameter values of the plurality of complexity indexes and the corresponding second weight values, the test coefficient corresponding to the second weight values of the plurality of complexity indexes being less than the preset value.
6. The apparatus of claim 5, wherein, The parameter values of the plurality of complexity indexes at least comprise the total number of the plurality of nodes, the average value of the number of attributes of the plurality of nodes, the average value of the number of adjacent edges of each node in the plurality of nodes, and the average value of the number of reachable nodes corresponding to each node in the plurality of nodes.
7. The apparatus of claim 6, wherein, The conversion unit is specifically configured to: convert the YANG model into a tree graph using a preset tool, the tree graph comprising a root node and a plurality of leaf nodes having a hierarchical relationship; determine a pointing relationship between the root node and the plurality of leaf nodes having the hierarchical relationship; and determine the directed graph according to the pointing relationship between the root node and the plurality of leaf nodes having the hierarchical relationship.
8. The apparatus of claim 7, wherein, The determination unit is specifically configured to: determine an evaluation index of the first complexity index, the evaluation index of the first complexity index being used to represent an importance of the first complexity index compared to the plurality of complexity indexes, the first complexity index being any one of the plurality of complexity indexes; normalize the evaluation indexes of the plurality of complexity indexes to obtain a first weight value corresponding to each complexity index.
9. A determination device, characterized in that The determining apparatus includes a processor, a communication interface, and a memory; wherein the memory is used to store one or more programs, the one or more programs including computer execution instructions; when the determining apparatus is running, the processor executes the computer execution instructions stored in the memory, so that the determining apparatus executes the method in any one of claims 1-4.
10. A computer-readable storage medium storing one or more programs, the one or more programs comprising instructions for: The one or more programs include instructions that, when executed by a computer, cause the computer to perform the method in any one of claims 1-4.