Home » Network Programmability: YANG Models, NETCONF, RESTCONF, gNMI, gRPC และ Model-Driven Telemetry
Network Programmability: YANG Models, NETCONF, RESTCONF, gNMI, gRPC และ Model-Driven Telemetry
Network Programmability: YANG Models, NETCONF, RESTCONF, gNMI, gRPC และ Model-Driven Telemetry
Network Programmability เปลี่ยน network management จาก CLI-based เป็น API-driven YANG Models กำหนด data structure ของ network devices, NETCONF ใช้ XML/SSH สำหรับ configuration, RESTCONF ใช้ HTTP/JSON สำหรับ RESTful access, gNMI ใช้ gRPC สำหรับ streaming telemetry, gRPC เป็น high-performance RPC framework และ Model-Driven Telemetry push real-time data จาก devices
CLI (Command Line Interface) ถูกออกแบบ สำหรับคน ไม่ใช่สำหรับ automation: output เป็น unstructured text → ต้อง screen-scrape + regex → fragile, breaks เมื่อ vendor เปลี่ยน format YANG + NETCONF/RESTCONF/gNMI แก้ปัญหานี้: structured data (XML/JSON), well-defined models, transactional operations (commit/rollback), vendor-neutral standards ทุก major vendor รองรับ (Cisco, Juniper, Arista, Nokia) → future ของ network management
YANG Models
| Feature |
รายละเอียด |
| คืออะไร |
Data modeling language (RFC 7950) — define structure of network device data (config + state) |
| Modules |
Each module defines a feature area: ietf-interfaces, openconfig-bgp, cisco-ios-xe-native |
| Standard Models |
IETF (ietf-*): vendor-neutral standards | OpenConfig: operator-driven multi-vendor models |
| Native Models |
Vendor-specific: cisco-ios-xe-*, junos-*, arista-* — full device feature coverage |
| Containers |
Grouping nodes: container interfaces { list interface { leaf name; leaf enabled; } } |
| Leaf |
Single data element: leaf name { type string; } — the actual config/state values |
| List |
Collection of entries: list interface { key name; } — multiple instances (eth0, eth1) |
| Tools |
pyang (validate/view YANG), YANG Explorer, YANG Suite (Cisco) |
NETCONF
| Feature |
รายละเอียด |
| Protocol |
RFC 6241 — SSH transport (port 830), XML encoding, RPC-based operations |
| Operations |
get (state), get-config (config), edit-config (modify), copy-config, delete-config, lock/unlock |
| Datastores |
running (active config), candidate (staging), startup (boot config) |
| Candidate Config |
Edit candidate → validate → commit to running → rollback if error — transactional! |
| Subtree Filtering |
XPath or subtree filter → request only specific data (not entire config) |
| Python Library |
ncclient: connect → get_config → edit_config → commit → close_session |
| Advantage |
Transactional (commit/rollback), structured data (XML), well-defined operations |
RESTCONF
| Feature |
รายละเอียด |
| Protocol |
RFC 8040 — HTTP/HTTPS transport, JSON or XML encoding, RESTful API |
| Methods |
GET (read), POST (create), PUT (replace), PATCH (update), DELETE (remove) |
| URL Structure |
https://device/restconf/data/ietf-interfaces:interfaces/interface=GigabitEthernet1 |
| JSON Support |
Accept: application/yang-data+json — JSON response (easier than XML for developers) |
| vs NETCONF |
RESTCONF = simpler (HTTP/JSON, stateless) | NETCONF = more powerful (candidate config, lock, transactions) |
| Use Case |
Quick read/write operations, integration with web apps, Postman-friendly testing |
| Python |
Standard requests library: requests.get/put/patch with headers and auth |
gNMI / gRPC
| Feature |
รายละเอียด |
| gRPC |
Google’s high-performance RPC framework — HTTP/2, Protocol Buffers, bidirectional streaming |
| gNMI |
gRPC Network Management Interface — YANG-based, designed for telemetry and config |
| Operations |
Get (read config/state), Set (update/replace/delete config), Subscribe (streaming telemetry) |
| Subscribe |
STREAM: continuous updates | ONCE: one-time snapshot | POLL: on-demand |
| Performance |
Much faster than NETCONF/RESTCONF — binary encoding (protobuf), HTTP/2 multiplexing |
| Telemetry |
Primary protocol for model-driven telemetry — push data at high frequency (100ms+) |
| Adoption |
Arista, Nokia, Juniper (native) | Cisco (growing support) — becoming the standard |
Model-Driven Telemetry
| Feature |
Traditional (SNMP Poll) |
Model-Driven Telemetry |
| Direction |
Pull: NMS polls device every 5 min |
Push: device streams data to collector continuously |
| Frequency |
Minutes (5-15 min typical) |
Sub-second possible (100ms-10s) |
| Data Format |
OIDs (cryptic numbers) |
YANG models (human-readable paths) |
| Encoding |
BER (binary, complex) |
JSON, protobuf, KVGPB |
| Transport |
UDP (unreliable) |
gRPC (reliable, HTTP/2), TCP |
| Scale |
Polling overhead increases with devices |
Device does the work — collector just receives |
| Collectors |
SNMP NMS (LibreNMS, PRTG) |
Telegraf → InfluxDB → Grafana, Pipeline (Cisco), gNMIc |
Protocol Comparison
| Feature |
NETCONF |
RESTCONF |
gNMI |
| Transport |
SSH (port 830) |
HTTPS (port 443) |
gRPC/HTTP2 (port 50051+) |
| Encoding |
XML |
JSON or XML |
Protobuf (binary) |
| Connection |
Stateful (persistent SSH) |
Stateless (HTTP) |
Stateful (gRPC stream) |
| Transactions |
Yes (candidate, commit, rollback) |
Limited (no candidate) |
Set (atomic replace/update) |
| Telemetry |
Not designed for it |
Not designed for it |
Native subscribe (streaming) |
| Performance |
Moderate |
Moderate |
Highest (binary, HTTP/2) |
| Best For |
Config management, transactions |
Quick reads, web integration |
Telemetry, high-frequency data, config |
ทิ้งท้าย: Programmability = Future of Network Management
Network Programmability YANG: data modeling language — standard (IETF, OpenConfig) + vendor-native models define all config/state NETCONF: SSH/XML, transactional (candidate config + commit/rollback), ncclient Python library RESTCONF: HTTP/JSON, RESTful (GET/POST/PUT/PATCH/DELETE), simple, Postman-friendly gNMI: gRPC/protobuf, fastest, streaming telemetry (subscribe), becoming the standard Model-Driven Telemetry: push (not poll), sub-second, YANG-based, Telegraf+InfluxDB+Grafana stack Comparison: NETCONF = transactions, RESTCONF = simplicity, gNMI = performance + telemetry Key: CLI → API transition is happening — YANG + NETCONF/RESTCONF/gNMI = vendor-neutral, structured, automatable
อ่านเพิ่มเติมเกี่ยวกับ Network Automation Ansible Python Netmiko NAPALM และ Network Monitoring SNMP NetFlow Prometheus Grafana ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com