Home » Network Programmability: REST API, gRPC, YANG, RESTCONF, NETCONF และ Model-Driven Telemetry
Network Programmability: REST API, gRPC, YANG, RESTCONF, NETCONF และ Model-Driven Telemetry
Network Programmability: REST API, gRPC, YANG, RESTCONF, NETCONF และ Model-Driven Telemetry
Network Programmability เปลี่ยน network management จาก CLI-based เป็น API-driven automation REST API ให้ programmatic access ผ่าน HTTP, gRPC เป็น high-performance RPC framework, YANG เป็น data modeling language สำหรับ network configuration, RESTCONF ให้ REST interface สำหรับ YANG models, NETCONF ให้ XML-based configuration management และ Model-Driven Telemetry ส่ง real-time data จาก devices โดยไม่ต้อง poll
CLI-based management ไม่ scale สำหรับ modern networks: screen-scraping output ของ “show” commands เป็น brittle (เปลี่ยน format = script พัง), SSH to 1,000 devices ช้าและ error-prone, ไม่มี structured data (text parsing), ไม่มี transaction support (partial config = broken state) YANG + NETCONF/RESTCONF แก้ทุกปัญหา: structured data models, transactional config, validation before commit, rollback
Network Programmability Stack
| Layer |
Technology |
Purpose |
| Data Model |
YANG |
Define structure of configuration and operational data |
| Transport Protocol |
NETCONF (SSH), RESTCONF (HTTPS), gNMI (gRPC) |
Carry data between client and device |
| Encoding |
XML (NETCONF), JSON (RESTCONF), Protobuf (gNMI) |
Serialize data for transport |
| Automation Tool |
Ansible, Python (ncclient, requests), Terraform |
Orchestrate operations across multiple devices |
| Telemetry |
Model-Driven Telemetry (gNMI, gRPC) |
Real-time streaming data from devices (push model) |
YANG Data Models
| Feature |
รายละเอียด |
| คืออะไร |
Data modeling language (RFC 7950) ที่กำหนด structure ของ network config/state data |
| Model Types |
IETF (standard: ietf-interfaces), OpenConfig (vendor-neutral), Native (vendor-specific: Cisco-IOS-XE) |
| Structure |
module → container → list → leaf → leaf-list → choice → augment |
| Container |
Group of related data nodes (like a directory) |
| List |
Collection of entries with key (like a table: interface list keyed by name) |
| Leaf |
Single data value (like a field: interface name, IP address, status) |
| Tools |
pyang (validate/convert), YANG Explorer, YANG Suite (Cisco) |
NETCONF
| Feature |
รายละเอียด |
| คืออะไร |
Network Configuration Protocol (RFC 6241) — XML-based config management over SSH (port 830) |
| Operations |
get, get-config, edit-config, copy-config, delete-config, lock, unlock, commit, validate |
| Datastores |
running (active config), candidate (staged config), startup (boot config) |
| Transaction |
Candidate datastore → edit → validate → commit (all-or-nothing) → rollback if error |
| Filtering |
Subtree filtering (XPath) → get only specific data (not entire config) |
| Python |
ncclient library: connect → edit_config → commit → close_session |
| Advantage |
Transactional, structured (XML), validation, rollback, standard (multi-vendor) |
RESTCONF
| Feature |
NETCONF |
RESTCONF |
| Transport |
SSH (port 830) |
HTTPS (port 443) |
| Encoding |
XML |
JSON or XML |
| Operations |
RPC-based (get, edit-config, etc.) |
HTTP methods (GET, POST, PUT, PATCH, DELETE) |
| URL Structure |
N/A |
https://device/restconf/data/[yang-module]:[container]/[list]=[key] |
| Ease of Use |
More complex (XML, RPC) |
Easier (familiar HTTP/REST, JSON) |
| Candidate DS |
Full support |
Limited (depends on implementation) |
| Best For |
Full config management, transactions |
Quick queries, web integrations, developers familiar with REST |
gRPC and gNMI
| Feature |
รายละเอียด |
| gRPC |
Google’s RPC framework: HTTP/2, Protocol Buffers, bidirectional streaming, high performance |
| gNMI |
gRPC Network Management Interface: Get, Set, Subscribe operations on YANG data |
| Subscribe |
Streaming telemetry: device pushes data to collector → real-time monitoring (no polling) |
| Modes |
ONCE (one-time), POLL (on-demand), STREAM (continuous: ON_CHANGE or SAMPLE) |
| Encoding |
Protocol Buffers (compact binary) or JSON |
| Performance |
Much faster than NETCONF/RESTCONF — 10x+ for telemetry streaming |
| Tools |
gnmic (CLI client), Telegraf (collector), InfluxDB + Grafana (visualization) |
Model-Driven Telemetry
| Feature |
SNMP Polling |
Model-Driven Telemetry |
| Model |
Pull (manager polls device) |
Push (device streams to collector) |
| Frequency |
Minutes (5-min typical) |
Seconds to sub-second (10s, 5s, 1s) |
| Data Model |
MIBs (flat, limited) |
YANG models (hierarchical, comprehensive) |
| Encoding |
ASN.1/BER (verbose) |
Protobuf (compact) or JSON |
| Scale |
Poor at high frequency (CPU intensive on device) |
Efficient — designed for high-frequency streaming |
| Use Case |
Basic monitoring (up/down, utilization) |
Real-time analytics, anomaly detection, capacity planning |
| Pipeline |
SNMP → NMS |
gNMI → Telegraf → InfluxDB → Grafana (TIG stack) |
REST API Examples
| Platform |
API |
Example |
| Cisco DNA Center |
Intent API (REST) |
GET /dna/intent/api/v1/network-device → list all devices |
| Cisco Meraki |
Dashboard API (REST) |
GET /api/v1/organizations/{orgId}/networks → list networks |
| Cisco IOS-XE |
RESTCONF |
GET /restconf/data/ietf-interfaces:interfaces → list interfaces |
| Arista EOS |
eAPI (JSON-RPC) |
POST /command-api → {“cmds”: [“show interfaces”]} → structured JSON |
| Palo Alto |
PAN-OS REST API |
GET /api/?type=config&action=get&xpath=/config/devices → get config |
ทิ้งท้าย: Network Programmability = APIs Replace CLI
Network Programmability YANG: data modeling language — IETF (standard), OpenConfig (vendor-neutral), Native (vendor-specific) NETCONF: XML over SSH (port 830), transactional (candidate → validate → commit → rollback) RESTCONF: JSON/XML over HTTPS, HTTP methods (GET/POST/PUT/PATCH/DELETE), easier for developers gRPC/gNMI: high-performance (Protobuf, HTTP/2), streaming telemetry (subscribe), fastest option Telemetry: push model (device → collector), sub-second frequency, YANG-based, TIG stack (Telegraf+InfluxDB+Grafana) REST APIs: DNA Center, Meraki, IOS-XE RESTCONF, Arista eAPI, Palo Alto — programmatic access to everything Key: YANG is the foundation — NETCONF for full config management, RESTCONF for quick access, gNMI for telemetry
อ่านเพิ่มเติมเกี่ยวกับ Network Automation Ansible Terraform GitOps และ Software-Defined Networking SDN Controller OpenFlow ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com