# NETCONF ###### tags: `WG4` [WG4 overview](https://hackmd.io/fsvGLtXiQ0ael62w5LvNBg) The **Network Configuration Protocol** (NETCONF) is a network management protocol developed and standardized by the IETF. NETCONF(Network Configuration Protocol) is a network configuration and management protocol that base on XML(Extensible Markup Language). It use RPC mechanism to implement communication between server and client. 客戶端可以是腳本或者網管上運行的一個應用程序。服務器是一個典型的網絡設備。 ### 優點 --- - NETCONF協議以XML格式定義消息,運用RPC機制修改配置信息,這樣既能方便管理配置信息,又能滿足來自不同製造商設備之間的互操作性。 - 可減少由於人工配置錯誤引起的網絡故障。 - 可提高使用配置工具升級系統軟件的效率。 - 擴展性好,不同製造商設備可以定義自己的協議操作,以實現獨特的管理功能。 - NETCONF提供了認證、鑑權等安全機制,保證了消息傳遞的安全。 ### Layer --- **NETCONF協議在概念上可以劃分為4層:** 1. The Secure Transport layer provides a secure and reliable transport of messages between a client and a server. 2. The Messages layer provides a mechanism for encoding remote procedure calls (RPCs) and notifications. 3. The Operations layer defines a set of base protocol operations to retrieve and edit the configuration data. 4. The Content layer consists of configuration data and notification data. ![](https://i.imgur.com/eLHE82H.png) ### **Messages** The NETCONF messages layer provides a simple, transport-independent framing mechanism for encoding - first connection using `<hello>` Message - RPC invocations (`<rpc>` messages) 1. client send request to server use `<rpc>` - RPC results (`<rpc-reply>` messages) 1. server sned response to client use `<rpc-reply>` 2. define two element `<ok>`(success)、`<rpc-error>` (error) ![](https://i.imgur.com/agG3Azt.png) - event notifications (`<notification>` messages) 1. server only send notification message to client of subscription ### Netconf struct ![](https://i.imgur.com/pviMZdq.png) ### operation --- The base protocol defines the following protocol operations: ![](https://i.imgur.com/icvpzKr.png) [ORAN专题系列-16:5G O-RAN FrontHaul前传接口的网络配置管理协议netconf_文火冰糖(王文兵)的博客-CSDN博客](https://blog.csdn.net/HiWangWenBing/article/details/108414447) ## **Netconf基本網絡結構:** NETCONF基本網絡架構的主要元素: - **客戶端(Client)**。主要作用如下: - 利用NETCONF協議對網絡設備進行系統管理。 - 向NETCONF Server發送請求,查詢或修改一個或多個具體的參數值。 - 接收NETCONF Server主動發送的告警和事件,以獲知被管理設備的當前狀態。 - **服務器(Server)**。主要用於維護被管理設備的信息數據並響應客戶端的請求。 - 服務器收到客戶端的請求後會進行數據解析,然後給客戶端返迴響應。 - 當設備發生故障或其他事件時,服務器利用Notification機制主動將設備的告警和事件通知給客戶端,向客戶端報告設備的當前狀態變化。 - **配置數據集(Datastores)** - Configure database 1. <running/> save already effective configuration data 2. <candidate/>save the effective data that can submit to the server 3. <startup/> save the startup configuration data [Netconf協議學習筆記](https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a91d4bd5-0e64-4ed1-9288-8ee7a22b7626/Untitled.png) [](https://cshihong.github.io/2019/12/29/Netconf%E5%8D%8F%E8%AE%AE%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/) ## First connect 1. client sned **<hello Message>** to server 2. server send **<hello Message>** to client 3. client sned **<rpc>** to server 4. server send **<rpc-reply>** to client ![](https://i.imgur.com/VdFaSyE.png) ### RPC 介紹 [Day 16 - 分散式系統溝通的方法 - RPC - iT 邦幫忙::一起幫忙解決難題,拯救 IT 人的一天](https://ithelp.ithome.com.tw/articles/10223580) ## YANG **YANG(Yet Another Next Generation):** A Data Modeling Language for the Network Configuration Protocol (NETCONF) YANG將數據進行模型化和結構化,它把某一个系统的所有數據组成為一棵樹。 ### **葉節點(Leaf Nodes)** 葉子節點包含簡單的數據,如整數或字符串。它只有一個特定類型的值 YANG ```css leaf host-name { type string; description "Hostname for this system."; } ``` XML ```xml <host-name>my.example.com</host-name> ``` --- ### 葉列表節點(Leaf-List Nodes) YANG ```css leaf-list domain-search { type string; description "List of domain names to search."; } ``` XML ```xml <domain-search>high.example.com</domain-search> <domain-search>low.example.com</domain-search> <domain-search>everywhere.example.com</domain-search> ``` --- ### 容器節點(Container Nodes) 用於分組樹中的相關節點,一個容器只有子節點,沒有值 容器可以包含任何類型、任何數量的子節點(葉子,列表,容器,葉子列表,動作和通知) YANG ```css container system { container login { leaf message { type string; description "Message given at start of login session."; } } ``` XML ```xml <system> <login> <message>Good morning</message> </login> </system> ``` --- ### typedef YANG ```css typedef percent { type uint8 { range "0 .. 100"; } } leaf completed { type percent; } ``` XML ```xml <completed>20</completed> ``` ![](https://i.imgur.com/vgtdjhX.png) ![](https://i.imgur.com/1UNynaH.png) ![](https://i.imgur.com/gWDb73U.png) ![](https://i.imgur.com/QzmTHgu.png) ## NETCONF, YANG, XML 三者的關係 [(交换机)NETCONF\YANG\XML的关系_a961634066的博客-CSDN博客](https://blog.csdn.net/a961634066/article/details/98494764) ### NETCONF 是為了可以自動化配置網路設定而設計出來的,以前需要在command line 輸入語法去設定電腦,有了NETCONF 協定後就不需要在意輸入的指令的是什麼,可以專注在配置的內容。 - NETCONF 用來操作和維護網絡設備的協 ### **YANG** 因為不同的的設備對於要配置相同的功能所需要的參數內容設定可能不一樣,因此需要一種模組來規範要如何配置。 - YANG 是描述業務數據模型的語言,表達數據的模板,描述什麼才是符合設備期望的數據,類似C語言數據結構,有了它,就知道怎麼填空 - 例如需要配置IP和MASK ### XML 以結構化的格式存儲數據,用一種開放的自我描述方式定義數據結構,在描述數據內容的同時突出對結構的描述,從而體現出數據之間的關係,XML的自我描述性質能夠很好地表現許多複雜的數據關係,使得基於XML的應用程式可以在XML文件中準確高效地搜索相關韻數據內容,忽略其他不相關部分。 XML是一種數據表示格式,類似的還有JSON格式,表達用戶要操作的數據本身。但數據是千變萬化的,什麼才是符合設備期望的格式呢 ```xml interface{ ip{ address x.x.x.x mask x.x.x.x } } ```