gNMI over gRPC: Capabilities, Get, Set, and Subscribe, Packet by Packet

This walkthrough uses captures from the late Nick Russo's free packet-capture library, preserved by the Internet Archive. They are in the gRPC archive, grpc_pcap.zip, under grpc_pcap/: grpc_gnmi_capabilities.pcapng, grpc_gnmi_get.pcapng, grpc_gnmi_set_update.pcapng, grpc_gnmi_set_replace.pcapng, grpc_gnmi_set_delete.pcapng, grpc_gnmi_subscribe.pcapng, and grpc_gnmi_unimplemented.pcapng. The archive also holds the gnmi.proto file needed to decode them. The rest of the library is listed on his job aid page. We decoded the captures with VisualEther, which turns a Wireshark PCAP into a sequence diagram with a plain-English caption on every message.

Network engineers have long configured routers by typing CLI commands and monitored them by polling SNMP counters every few minutes. Model-driven management replaces both with structured data. Every setting and counter has a place in a YANG data model, and a program reads it, changes it, or streams it by path. gNMI is one of the main protocols for doing that, and it runs over gRPC, Google's remote-procedure-call framework, on top of HTTP/2.

That stack is easy to use from a Python library and hard to see from the outside. When a gNMI client reports an error, gets an empty reply, or waits for telemetry that never comes, the answer is in the packets. These captures were made in cleartext, so every layer decodes:

  1. Capabilities. The client asks what the router supports: a 51 kB answer listing 767 YANG models.
  2. Get. One read of the router's VRF configuration, answered in 164 ms.
  3. Set. The same value sent as an update and as a replace, then the path deleted. Only the list it sits in differs.
  4. Subscribe. A telemetry stream sampling every 10 seconds, until the client cancels it.
  5. An error. An HTTP 200 that is really a failure: grpc-status 12, unknown service gnmi.gNMI.

Each capture is drawn as an annotated sequence diagram. Each participant gets a lane, each message is an arrow numbered as in Wireshark, and each carries a caption saying what it does. Every diagram comes as an interactive viewer, an HTML page, and a printable PDF. In the viewer and the HTML page, clicking any message opens its full Wireshark field tree.

💡 Read the walkthrough and a diagram side by side: open the interactive diagram in a split-screen window, or open the HTML version in a new tab and snap the two windows side by side. Each section below links its own diagram.

What is gNMI?

gNMI (gRPC Network Management Interface) is a protocol from the OpenConfig project for reading, changing, and streaming the state of network devices. Its specification defines one gRPC service, gnmi.gNMI, with four methods (section 3):

RPCgRPC call typeRequestResponseIn these captures
CapabilitiesUnary: one request, one responseCapabilityRequest (empty)CapabilityResponse: gNMI version, encodings, models51 kB answer, 261 ms after the request
GetUnaryGetRequest: paths, data type, encodingGetResponse: one Notification per path982-byte answer in 164 ms
SetUnarySetRequest: delete, replace, and update listsSetResponse: one UpdateResult per operation598 to 644 ms
SubscribeBidirectional streamingSubscribeRequest: a SubscriptionListA stream of SubscribeResponsesFirst sample after 10.1 s, then every 10 s

A few terms that run through every capture:

The router is called the target in gNMI. In captures 1 to 4 it is the IOS-XR router in Cisco's public DevNet sandbox, at 10.10.20.50, serving gRPC in cleartext on TCP 5740. The client is a Python script using grpc-python 1.32.0.

How does gNMI use gRPC and HTTP/2?

Every gNMI call in these captures has the same shape. The gRPC rules are in PROTOCOL-HTTP2.md:

sequenceDiagram accTitle: A gNMI Get over gRPC and HTTP/2 accDescr: After the TCP handshake, the client sends the HTTP/2 connection preface with SETTINGS, WINDOW_UPDATE, and PING. The target answers with its own SETTINGS and acknowledgments. The client then sends a HEADERS frame with POST /gnmi.gNMI/Get and a DATA frame holding the GetRequest, on stream 1. The target returns the request's bytes as flow-control window, and, 164 milliseconds after the request, sends response HEADERS with status 200, a DATA frame with the GetResponse, and trailers with grpc-status 0, all in one segment. participant C as gNMI client participant T as IOS-XR target C->>T: [4] Connection preface, SETTINGS, WINDOW UPDATE, PING T->>C: [6] SETTINGS, SETTINGS ACK, PING ACK C->>T: [8] HEADERS POST /gnmi.gNMI/Get + DATA Get Request (stream 1) T->>C: [9] WINDOW UPDATE 44, PING T->>C: [12] HEADERS 200 + DATA Get Response + trailers grpc-status 0
One unary gNMI call (the Get capture). Each arrow is one TCP segment, and frame numbers are in brackets.
  1. HTTP/2 starts without negotiation. In cleartext, the client assumes the server speaks HTTP/2 ("prior knowledge," RFC 9113 section 3.3) and opens with a 24-byte connection preface and a SETTINGS frame. This client also raises its receive window to 4 MiB and sends a PING, which gRPC uses to measure the round trip.
  2. Each call is a POST on a new stream. The client uses odd stream numbers (RFC 9113 section 5.1.1), starting at 1. The HEADERS frame carries :method POST, :path /gnmi.gNMI/Get, content-type: application/grpc, and te: trailers. The path is the whole method name: package gnmi, service gNMI, method Get.
  3. Each message has a 5-byte prefix. The DATA frame holds a 1-byte compressed flag, a 4-byte length, then the protobuf message. A 39-byte GetRequest makes a 44-byte DATA frame.
  4. The result comes last, in trailers. The response is HEADERS with :status 200, then the data, then a second HEADERS frame, the trailers, with grpc-status and grpc-message. PROTOCOL-HTTP2.md requires the status in trailers "even if the status code is OK."

Point 4 is the one that catches people. HTTP 200 only says the HTTP/2 stream worked. Whether the gNMI call worked is in grpc-status, where 0 means OK. Capture 5 shows an HTTP 200 with a failure inside.

🔓 The credentials are in cleartext. The client sends username: admin and password: Cisco123 as ordinary request headers, which gRPC calls metadata. These are the public DevNet sandbox defaults, so we show them as they appear in the diagrams. On a real network anyone on the path could read them. That is why the gNMI specification (section 3.1) requires TLS and says neither side may fall back to an unencrypted session. It requires a username and password in the metadata, but doesn't name the keys; username and password are the common convention.

The diagrams show each TCP segment as one arrow, with every HTTP/2 frame it carries listed beneath it. Segments that carry only a piece of a large message are left out.

Capture 1: Capabilities, what the router supports

A client normally starts by asking what the target supports. The CapabilityRequest has no fields, so its DATA frame is just the 5-byte prefix with length 0: the method name in :path is the whole request.

The answer is the largest message in these captures. The target sends response headers one round trip after the request, then a 51,218-byte CapabilityResponse. The target's own SETTINGS were empty, which leaves its frame size at the RFC 9113 default of 16,384 bytes, so the response goes out as three full 16,384-byte DATA frames and one of 2,071. The trailers close the stream with grpc-status: 0, 261 ms after the request. The response says (gNMI specification section 3.2.2):

A client picks its paths and encoding from this list before it sends a Get, Set, or Subscribe.

Capture 2: Get, one read

The client reads the router's VRF configuration. This capture's diagram carries the fullest explanation of the HTTP/2 frames, so it is the one to open first.

The request. The 39-byte GetRequest has three fields that matter:

The full request as Wireshark decodes it, HEADERS and DATA together:

📡 [00005] Frame 8 GetRequest 2020-09-20T18:57:21.745203Z 💻 gNMI client → 🎯 IOS-XR target
frame : Frame 8: Packet, 419 bytes on wire (3352 bits), 419 bytes captured (3352 bits) on interface utun2, id 0
Section number : 1
Interface id : 0 (utun2)
Interface name : utun2
Encapsulation type : NULL/Loopback (15)
Arrival Time : Sep 21, 2020 00:27:21.745203000 India Standard Time
UTC Arrival Time : Sep 20, 2020 18:57:21.745203000 UTC
Epoch Arrival Time : 1600628241.745203000
Time shift for this packet : 0.000000000 seconds
Time delta from previous captured frame : 204.000 microseconds
Time delta from previous displayed frame : 204.000 microseconds
Time since reference or first frame : 163.050000 milliseconds
Frame Number : 8
Frame Length : 419 bytes (3352 bits)
Capture Length : 419 bytes (3352 bits)
Frame is marked : False
Frame is ignored : False
Protocols in frame : null:ip:tcp:http2:grpc:protobuf
Character encoding : ASCII (0)
null : Null/Loopback
Family : IP (2)
ip : Internet Protocol Version 4, Src: 192.168.45.1, Dst: 10.10.20.50
0100 .... = Version : 4
.... 0101 = Header Length : 20 bytes (5)
Differentiated Services Field : 0x02 (DSCP: CS0, ECN: ECT(0))
0000 00.. = Differentiated Services Codepoint : Default (0)
.... ..10 = Explicit Congestion Notification : ECN-Capable Transport codepoint '10' (2)
Total Length : 415
Identification : 0x0000 (0)
010. .... = Flags : 0x2, Don't fragment
0... .... = Reserved bit : Not set
.1.. .... = Don't fragment : Set
..0. .... = More fragments : Not set
...0 0000 0000 0000 = Fragment Offset : 0
Time to Live : 64
Protocol : TCP (6)
Header Checksum : 0x2d72 [validation disabled]
Header checksum status : Unverified
Source Address : 192.168.45.1
Source or Destination Address : 192.168.45.1
Source Host : 192.168.45.1
Source or Destination Host : 192.168.45.1
Destination Address : 10.10.20.50
Source or Destination Address : 10.10.20.50
Destination Host : 10.10.20.50
Source or Destination Host : 10.10.20.50
Stream index : 0
tcp : Transmission Control Protocol, Src Port: 58176, Dst Port: 5740, Seq: 100, Ack: 36, Len: 363
Source Port : 58176
Destination Port : 5740
Source or Destination Port : 58176
Source or Destination Port : 5740
Stream index : 0
Stream Packet Number : 8
Conversation completeness : Complete, WITH_DATA (31)
..0. .... = RST : Absent
...1 .... = FIN : Present
.... 1... = Data : Present
.... .1.. = ACK : Present
.... ..1. = SYN-ACK : Present
.... ...1 = SYN : Present
Completeness Flags : ·FDASS
TCP Segment Len : 363
Sequence Number : 100 (relative sequence number)
Sequence Number (raw) : 284334780
Next Sequence Number : 463 (relative sequence number)
Acknowledgment Number : 36 (relative ack number)
Acknowledgment number (raw) : 1695887499
1000 .... = Header Length : 32 bytes (8)
Flags : 0x018 (PSH, ACK)
000. .... .... = Reserved : Not set
...0 .... .... = Accurate ECN : Not set
.... 0... .... = Congestion Window Reduced : Not set
.... .0.. .... = ECN-Echo : Not set
.... ..0. .... = Urgent : Not set
.... ...1 .... = Acknowledgment : Set
.... .... 1... = Push : Set
.... .... .0.. = Reset : Not set
.... .... ..0. = Syn : Not set
.... .... ...0 = Fin : Not set
TCP Flags : ·······AP···
Window : 2064
Calculated window size : 132096
Window size scaling factor : 64
Checksum : 0x556d [unverified]
Checksum Status : Unverified
Urgent Pointer : 0
Options : (12 bytes), No-Operation (NOP), No-Operation (NOP), Timestamps
TCP Option - No-Operation (NOP)
Kind : No-Operation (1)
TCP Option - No-Operation (NOP)
Kind : No-Operation (1)
TCP Option - Timestamps : TSval 1362243465, TSecr 3405997052
Kind : Time Stamp Option (8)
Length : 10
Timestamp value : 1362243465
Timestamp echo reply : 3405997052
Timestamps
Time since first frame in this TCP stream : 163.050000 milliseconds
Time since previous frame in this TCP stream : 204.000 microseconds
SEQ/ACK analysis
iRTT : 80.745000 milliseconds
Bytes in flight : 363
Bytes sent since last PSH flag : 363
Client Contiguous Streams : 1
Server Contiguous Streams : 1
TCP payload (363 bytes)
PDU Size : 9
PDU Size : 275
PDU Size : 13
PDU Size : 53
PDU Size : 13
http2 : HyperText Transfer Protocol 2
Stream : SETTINGS, Stream ID: 0, Length 0
Length : 0
Type : SETTINGS (4)
Flags : 0x01, ACK
0000 000. = Unused : 0x00
.... ...1 = ACK : True
0... .... .... .... .... .... .... .... = Reserved : 0x0
.000 0000 0000 0000 0000 0000 0000 0000 = Stream Identifier : 0
http2 : HyperText Transfer Protocol 2
Stream : HEADERS, Stream ID: 1, Length 266, POST /gnmi.gNMI/Get
Length : 266
Type : HEADERS (1)
Flags : 0x04, End Headers
00.0 ..0. = Unused : 0x00
..0. .... = Priority : False
.... 0... = Padded : False
.... .1.. = End Headers : True
.... ...0 = End Stream : False
0... .... .... .... .... .... .... .... = Reserved : 0x0
.000 0000 0000 0000 0000 0000 0000 0001 = Stream Identifier : 1
Pad Length : 0
Header Block Fragment […] : 8683400a3a617574686f726974791031302e31302e32302e35303a3537343040053a706174680e2f676e6d692e674e4d492f4765740008757365726e616d650561646d696e000870617373776f726408436973636f3132334002746508747261696c657273400c636f
Header Length : 347
Header Count : 11
Header : :scheme: http
Name Length : 7
Name : :scheme
Value Length : 4
Value : http
:scheme : http
Unescaped : http
Representation : Indexed Header Field
Index : 6
Header : :method: POST
Name Length : 7
Name : :method
Value Length : 4
Value : POST
:method : POST
Unescaped : POST
Representation : Indexed Header Field
Index : 3
Header : :authority: 10.10.20.50:5740
Name Length : 10
Name : :authority
Value Length : 16
Value : 10.10.20.50:5740
:authority : 10.10.20.50:5740
Unescaped : 10.10.20.50:5740
Representation : Literal Header Field with Incremental Indexing - New Name
Header : :path: /gnmi.gNMI/Get
Name Length : 5
Name : :path
Value Length : 14
Value : /gnmi.gNMI/Get
:path : /gnmi.gNMI/Get
Unescaped : /gnmi.gNMI/Get
Representation : Literal Header Field with Incremental Indexing - New Name
Header : username: admin
Name Length : 8
Name : username
Value Length : 5
Value : admin
Unescaped : admin
Representation : Literal Header Field without Indexing - New Name
Header : password: Cisco123
Name Length : 8
Name : password
Value Length : 8
Value : Cisco123
Unescaped : Cisco123
Representation : Literal Header Field without Indexing - New Name
Header : te: trailers
Name Length : 2
Name : te
Value Length : 8
Value : trailers
Unescaped : trailers
Representation : Literal Header Field with Incremental Indexing - New Name
Header : content-type: application/grpc
Name Length : 12
Name : content-type
Value Length : 16
Value : application/grpc
content-type : application/grpc
Unescaped : application/grpc
Representation : Literal Header Field with Incremental Indexing - New Name
Header : user-agent: grpc-python/1.32.0 grpc-c/12.0.0 (osx; chttp2)
Name Length : 10
Name : user-agent
Value Length : 46
Value : grpc-python/1.32.0 grpc-c/12.0.0 (osx; chttp2)
user-agent : grpc-python/1.32.0 grpc-c/12.0.0 (osx; chttp2)
Unescaped : grpc-python/1.32.0 grpc-c/12.0.0 (osx; chttp2)
Representation : Literal Header Field with Incremental Indexing - New Name
Header : grpc-accept-encoding: identity,deflate,gzip
Name Length : 20
Name : grpc-accept-encoding
Value Length : 21
Value : identity,deflate,gzip
Unescaped : identity,deflate,gzip
Representation : Literal Header Field with Incremental Indexing - New Name
Header : accept-encoding: identity,gzip
Name Length : 15
Name : accept-encoding
Value Length : 13
Value : identity,gzip
accept-encoding : identity,gzip
Unescaped : identity,gzip
Representation : Literal Header Field with Incremental Indexing - New Name
Response in frame : 12
Full request URI : http://10.10.20.50:5740/gnmi.gNMI/Get
http2 : HyperText Transfer Protocol 2
Stream : WINDOW_UPDATE, Stream ID: 1, Length 4
Length : 4
Type : WINDOW_UPDATE (8)
Flags : 0x00
0000 0000 = Unused : 0x00
0... .... .... .... .... .... .... .... = Reserved : 0x0
.000 0000 0000 0000 0000 0000 0000 0001 = Stream Identifier : 1
0... .... .... .... .... .... .... .... = Reserved : 0x0
.000 0000 0000 0000 0000 0000 0000 0101 = Window Size Increment : 5
Stream window size (before) : 4194304
Stream window size (after) : 4194309
Full request URI : http://10.10.20.50:5740/gnmi.gNMI/Get
http2 : HyperText Transfer Protocol 2
Stream : DATA, Stream ID: 1, Length 44
Length : 44
Type : DATA (0)
Flags : 0x01, End Stream
0000 .00. = Unused : 0x00
.... 0... = Padded : False
.... ...1 = End Stream : True
0... .... .... .... .... .... .... .... = Reserved : 0x0
.000 0000 0000 0000 0000 0000 0000 0001 = Stream Identifier : 1
Pad Length : 0
DATA payload (44 bytes)
Connection window size (before) : 65535
Connection window size (after) : 65491
Stream window size (before) : 4194304
Stream window size (after) : 4194260
Full request URI : http://10.10.20.50:5740/gnmi.gNMI/Get
grpc : GRPC Message: /gnmi.gNMI/Get, Request
0... .... = Frame Type : Data (0)
.... ...0 = Compressed Flag : Not Compressed (0)
Message Length : 39
Message Data : 39 bytes
protobuf : Protocol Buffers: /gnmi.gNMI/Get,request (Message: gnmi.GetRequest)
Message : gnmi.GetRequest
Message Name : gnmi.GetRequest
Field(2) : path
Field Name : path
Field Type : message (11)
.001 0... = Field Number : 2
.... .010 = Wire Type : Length-delimited (2)
Value Length : 35
Value : 1a210a1f436973636f2d494f532d58522d696e6672612d7273692d6366673a76726673
path : (35 bytes) (Message: gnmi.Path)
Message : gnmi.Path
Message Name : gnmi.Path
Field(3) : elem
Field Name : elem
Field Type : message (11)
.001 1... = Field Number : 3
.... .010 = Wire Type : Length-delimited (2)
Value Length : 33
Value : 0a1f436973636f2d494f532d58522d696e6672612d7273692d6366673a76726673
elem : (33 bytes) (Message: gnmi.PathElem)
Message : gnmi.PathElem
Message Name : gnmi.PathElem
Field(1) : name =
Field Name : name
Field Type : string (9)
.000 1... = Field Number : 1
.... .010 = Wire Type : Length-delimited (2)
Value Length : 31
Value : 436973636f2d494f532d58522d696e6672612d7273692d6366673a76726673
String : Cisco-IOS-XR-infra-rsi-cfg:vrfs
name : Cisco-IOS-XR-infra-rsi-cfg:vrfs
Field(5) : encoding =
Field Name : encoding
Field Type : enum (14)
.010 1... = Field Number : 5
.... .000 = Wire Type : varint (0)
Value : 04
Int32 : 4 (JSON_IETF)
encoding : JSON_IETF (4)
http2 : HyperText Transfer Protocol 2
Stream : WINDOW_UPDATE, Stream ID: 0, Length 4
Length : 4
Type : WINDOW_UPDATE (8)
Flags : 0x00
0000 0000 = Unused : 0x00
0... .... .... .... .... .... .... .... = Reserved : 0x0
.000 0000 0000 0000 0000 0000 0000 0000 = Stream Identifier : 0
0... .... .... .... .... .... .... .... = Reserved : 0x0
.000 0000 0000 0000 0000 0000 0000 0101 = Window Size Increment : 5
Connection window size (before) : 65535
Connection window size (after) : 65540
Rendered from a Wireshark PCAP by VisualEther.

The response. 164 ms after the request, about one round trip plus 83 ms of work on the target, the whole answer arrives in one TCP segment: response headers, a 982-byte GetResponse, and trailers with grpc-status: 0. The GetResponse holds one Notification:

The response also carries an error field, which can mislead a reader into thinking the Get failed. It is a zero-length gnmi.Error, a field that gnmi.proto marks deprecated. Errors now go in the trailers (section 2.5), and the trailers say grpc-status: 0.

Where the time went. The answer came 327 ms after the SYN: one round trip for TCP, one for the HTTP/2 settings, one for the request, and 83 ms at the target. A client that keeps its gRPC channel open pays the first two only once.

What do gNMI Set update, replace, and delete do?

A SetRequest has three lists: delete (paths), replace (path and value), and update (path and value). The library has three Set captures made a minute or two apart against the same vrfs container. The update and replace captures send the same 472-byte JSON value, VRF C with route targets 3:3, byte for byte; only the list it sits in differs. The delete capture sends the path alone. The diagram draws the replace; the other two differ only in that one field and in the result.

SetRequest listWhat the target does (section 3.4.4)op in the SetResponseRequest to response
updateMerges: changes only what the value names. VRF C is added; A and B stay.UPDATE (3)598 ms
replaceMakes the node match the value: anything not in it is deleted or reset to its default. VRFs A and B go.REPLACE (2)644 ms
deleteRemoves the node and everything under it.DELETE (1)636 ms

The difference between update and replace is the one to remember. Sending the same value with replace instead of update wipes every list entry you left out, so a replace on the wrong container can remove configuration you meant to keep.

One transaction. A single SetRequest can mix all three lists. The target processes deletes, then replaces, then updates, and applies them all or none (sections 3.4 and 3.4.3).

The response. The 55-byte SetResponse has one UpdateResult per operation, giving the path and the op, plus a timestamp for the change. The response also carries empty deprecated error fields, like the Get's. The trailers carry grpc-status: 0. All three runs succeeded.

Why a Set is slower. A Get took 164 ms; each Set took about 600 ms, with the same round-trip time to the sandbox. The extra half second is the target applying the change to its configuration. The capture can't show what happens inside the router, only the wait. The replace capture's file runs to 2.12 s only because of a stray SSH segment from another sandbox host at the end; the RPC ends at 956 ms.

How does gNMI streaming telemetry work?

Streaming telemetry replaces SNMP polling: instead of the client asking every few minutes, the router pushes data on a schedule or whenever it changes. In gNMI that is the Subscribe RPC, the only bidirectional-streaming method. Either side can send messages for as long as the call stays open.

sequenceDiagram accTitle: A gNMI Subscribe stream sampling every 10 seconds accDescr: The client sends a SubscribeRequest asking for STREAM mode with a SAMPLE subscription every 10 seconds, then half-closes its side of the stream. Ten seconds later the target sends the response headers and the first sample, followed by sync_response. Further samples arrive at about 20, 30, and 40 seconds. At 45 seconds the client cancels the call with RST_STREAM CANCEL. participant C as gNMI client participant T as IOS-XR target C->>T: [8] Subscribe Request: STREAM, SAMPLE every 10 s C->>T: [9] empty DATA, END STREAM (client half-closes) Note over C,T: 10 seconds of silence T->>C: [17-23] HEADERS 200, first sample, sync response T->>C: [31] sample at 20.3 s T->>C: [40] sample at 30.4 s T->>C: [48] sample at 40.4 s C->>T: [50] RST STREAM CANCEL
The Subscribe capture at a glance. Frame numbers are in brackets.

The request. The 108-byte SubscribeRequest carries a SubscriptionList:

The client then sends an empty DATA frame with END_STREAM. That closes only the client's direction: this script has no more requests to send. The subscription stays up.

Ten seconds of nothing. The target's response headers arrive 10.13 s after the request, together with the first sample. IOS-XR took the first sample one interval after the subscription started, not at once; its own data shows the collection starting ten seconds after the request. The specification doesn't say when the first SAMPLE update must go out. A client that gives up, or reports "no telemetry," in the first interval may simply be impatient.

The first sample and sync_response. The first SubscribeResponse is 4,929 bytes: one Notification with a timestamp, a prefix shared by all its updates, and 63 Updates. A second, 2-byte SubscribeResponse follows in the same TCP segment with only sync_response: true. It marks the end of the initial set of values, which the specification requires once per subscription (section 3.5.2.3). A client that waits until it is in sync before acting waits for this message.

The stream reports on itself. The path asked for the router's telemetry destinations, and the only destination is this subscription, GNMI_1001. Its counters tick up with each sample: total-collections goes 0, 1, 2, 3, and total-num-of-bytes-sent goes 0, 4,929, 9,868, 14,807, the exact running total of the SubscribeResponse sizes. The target's timestamps run 10.003, 10.004, and 10.003 s apart.

How it ends. A STREAM subscription never ends on its own. At 45.16 s the client cancels the call by resetting stream 1 with RST_STREAM error code CANCEL (8). That is how the gNMI specification says to end a subscription (section 3.5), and gRPC maps it to call cancellation. No trailers follow, so the client's library reports status CANCELLED locally. The TCP teardown after it is messy, ending with a client RST and a run of retransmitted FINs from the target, but that is cleanup on a connection the client had already abandoned.

What is the difference between gNMI Get and Subscribe?

Both read data by path, and both return Notification messages with the same timestamp, prefix, and Update structure. The difference is time:

GetSubscribe
gRPC call typeUnaryBidirectional streaming
AnswersOnce, then the call endsRepeatedly, until someone cancels
Initial snapshot markerNone neededsync_response: true
Typical useRead configuration, check a valueMonitor counters, state, and events
In these capturesAnswer in 164 msFirst sample after 10.1 s, then every 10 s

Subscribe with list mode ONCE sits between the two: one snapshot, a sync_response, and the target closes the call.

What does "unknown service gnmi.gNMI" mean?

This capture is from the same client a day earlier, against a different IOS-XR router reached over the internet on TCP 57400. That router's gRPC server is clearly running: it answers Cisco's own gRPC configuration service in other captures from the same library. The client sends a normal GetRequest for openconfig-interfaces.

14.3 ms later, one HEADERS frame with END_STREAM answers and ends the call:

❌ [00010] Frame 17 gRPC error (grpc-status 12) 2020-09-19T16:00:01.697715Z 🎯 IOS-XR target → 💻 gNMI client
frame : Frame 17: Packet, 133 bytes on wire (1064 bits), 133 bytes captured (1064 bits) on interface en0, id 0
Section number : 1
Interface id : 0 (en0)
Interface name : en0
Interface description : Wi-Fi
Encapsulation type : Ethernet (1)
Arrival Time : Sep 19, 2020 21:30:01.697715000 India Standard Time
UTC Arrival Time : Sep 19, 2020 16:00:01.697715000 UTC
Epoch Arrival Time : 1600531201.697715000
Time shift for this packet : 0.000000000 seconds
Time delta from previous captured frame : 184.000 microseconds
Time delta from previous displayed frame : 184.000 microseconds
Time since reference or first frame : 53.110000 milliseconds
Frame Number : 17
Frame Length : 133 bytes (1064 bits)
Capture Length : 133 bytes (1064 bits)
Frame is marked : False
Frame is ignored : False
Protocols in frame : eth:ethertype:ip:tcp:http2
Character encoding : ASCII (0)
eth : Ethernet II, Src: 48:5d:36:c9:c9:6b, Dst: c8:e0:eb:13:de:6d
Destination : c8:e0:eb:13:de:6d
Destination (resolved) : c8:e0:eb:13:de:6d
Destination OUI : c8:e0:eb (Apple, Inc.)
Destination OUI (resolved) : Apple, Inc.
.... ..0. .... .... .... .... = LG bit : Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit : Individual address (unicast)
Address : c8:e0:eb:13:de:6d
Address (resolved) : c8:e0:eb:13:de:6d
Address OUI : c8:e0:eb (Apple, Inc.)
Address OUI (resolved) : Apple, Inc.
.... ..0. .... .... .... .... = LG bit : Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit : Individual address (unicast)
Source : 48:5d:36:c9:c9:6b
Source (resolved) : 48:5d:36:c9:c9:6b
Source OUI : 48:5d:36 (Verizon)
Source OUI (resolved) : Verizon
.... ..0. .... .... .... .... = LG bit : Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit : Individual address (unicast)
Address : 48:5d:36:c9:c9:6b
Address (resolved) : 48:5d:36:c9:c9:6b
Address OUI : 48:5d:36 (Verizon)
Address OUI (resolved) : Verizon
.... ..0. .... .... .... .... = LG bit : Globally unique address (factory default)
.... ...0 .... .... .... .... = IG bit : Individual address (unicast)
Type : IPv4 (0x0800)
Stream index : 0
ip : Internet Protocol Version 4, Src: 18.206.119.175, Dst: 192.168.1.151
0100 .... = Version : 4
.... 0101 = Header Length : 20 bytes (5)
Differentiated Services Field : 0x00 (DSCP: CS0, ECN: Not-ECT)
0000 00.. = Differentiated Services Codepoint : Default (0)
.... ..00 = Explicit Congestion Notification : Not ECN-Capable Transport (0)
Total Length : 119
Identification : 0xf009 (61449)
010. .... = Flags : 0x2, Don't fragment
0... .... = Reserved bit : Not set
.1.. .... = Don't fragment : Set
..0. .... = More fragments : Not set
...0 0000 0000 0000 = Fragment Offset : 0
Time to Live : 53
Protocol : TCP (6)
Header Checksum : 0x08bb [validation disabled]
Header checksum status : Unverified
Source Address : 18.206.119.175
Source or Destination Address : 18.206.119.175
Source Host : 18.206.119.175
Source or Destination Host : 18.206.119.175
Destination Address : 192.168.1.151
Source or Destination Address : 192.168.1.151
Destination Host : 192.168.1.151
Source or Destination Host : 192.168.1.151
Stream index : 0
tcp : Transmission Control Protocol, Src Port: 57400, Dst Port: 61190, Seq: 49, Ack: 456, Len: 67
Source Port : 57400
Destination Port : 61190
Source or Destination Port : 57400
Source or Destination Port : 61190
Stream index : 0
Stream Packet Number : 17
Conversation completeness : Complete, WITH_DATA (31)
..0. .... = RST : Absent
...1 .... = FIN : Present
.... 1... = Data : Present
.... .1.. = ACK : Present
.... ..1. = SYN-ACK : Present
.... ...1 = SYN : Present
Completeness Flags : ·FDASS
TCP Segment Len : 67
Sequence Number : 49 (relative sequence number)
Sequence Number (raw) : 2369632046
Next Sequence Number : 116 (relative sequence number)
Acknowledgment Number : 456 (relative ack number)
Acknowledgment number (raw) : 4149411935
1000 .... = Header Length : 32 bytes (8)
Flags : 0x018 (PSH, ACK)
000. .... .... = Reserved : Not set
...0 .... .... = Accurate ECN : Not set
.... 0... .... = Congestion Window Reduced : Not set
.... .0.. .... = ECN-Echo : Not set
.... ..0. .... = Urgent : Not set
.... ...1 .... = Acknowledgment : Set
.... .... 1... = Push : Set
.... .... .0.. = Reset : Not set
.... .... ..0. = Syn : Not set
.... .... ...0 = Fin : Not set
TCP Flags : ·······AP···
Window : 22
Calculated window size : 45056
Window size scaling factor : 2048
Checksum : 0x0797 [unverified]
Checksum Status : Unverified
Urgent Pointer : 0
Options : (12 bytes), No-Operation (NOP), No-Operation (NOP), Timestamps
TCP Option - No-Operation (NOP)
Kind : No-Operation (1)
TCP Option - No-Operation (NOP)
Kind : No-Operation (1)
TCP Option - Timestamps : TSval 251414286, TSecr 1309840497
Kind : Time Stamp Option (8)
Length : 10
Timestamp value : 251414286
Timestamp echo reply : 1309840497
Timestamps
Time since first frame in this TCP stream : 53.110000 milliseconds
Time since previous frame in this TCP stream : 184.000 microseconds
SEQ/ACK analysis
This is an ACK to the segment in frame : 14
The RTT to ACK the segment was : 14.264000 milliseconds
iRTT : 18.803000 milliseconds
Bytes in flight : 45
Bytes sent since last PSH flag : 67
Client Contiguous Streams : 1
Server Contiguous Streams : 1
TCP payload (67 bytes)
PDU Size : 67
http2 : HyperText Transfer Protocol 2
Stream : HEADERS, Stream ID: 1, Length 58, 200 OK
Length : 58
Type : HEADERS (1)
Flags : 0x05, End Headers, End Stream
00.0 ..0. = Unused : 0x00
..0. .... = Priority : False
.... 0... = Padded : False
.... .1.. = End Headers : True
.... ...1 = End Stream : True
0... .... .... .... .... .... .... .... = Reserved : 0x0
.000 0000 0000 0000 0000 0000 0000 0001 = Stream Identifier : 1
Pad Length : 0
Header Block Fragment : 885f8b1d75d0620d263d4c4d656440889acac8b21234da8f02313240899acac8b5254207317f93b6aeb51fc54a20b677310aa4d55265e6d3a327
Header Length : 120
Header Count : 4
Header : :status: 200 OK
Name Length : 7
Name : :status
Value Length : 3
Value : 200
:status : 200
Unescaped : 200
Representation : Indexed Header Field
Index : 8
Header : content-type: application/grpc
Name Length : 12
Name : content-type
Value Length : 16
Value : application/grpc
content-type : application/grpc
Unescaped : application/grpc
Representation : Literal Header Field with Incremental Indexing - Indexed Name
Index : 31
Header : grpc-status: 12
Name Length : 11
Name : grpc-status
Value Length : 2
Value : 12
Unescaped : 12
Representation : Literal Header Field with Incremental Indexing - New Name
Header : grpc-message: unknown service gnmi.gNMI
Name Length : 12
Name : grpc-message
Value Length : 25
Value : unknown service gnmi.gNMI
Unescaped : unknown service gnmi.gNMI
Representation : Literal Header Field with Incremental Indexing - New Name
Time since request : 14.264000 milliseconds
Request in frame : 14
Full request URI : http://18.206.119.175:57400/gnmi.gNMI/Get
Rendered from a Wireshark PCAP by VisualEther.

This is a gRPC Trailers-Only response: the status line and the trailers in one header block, with no body. PROTOCOL-HTTP2.md allows it "for calls that produce an immediate error." It reads:

The router's gRPC server parsed the request, but has no service named gnmi.gNMI registered, so the call never reached a gNMI handler. The gRPC status code table lists "Method not found at server" as UNIMPLEMENTED. grpc-go writes exactly "unknown service" when the service is missing and "unknown method" when the service exists but the method doesn't.

When you see this error, check:

  1. Is gNMI enabled on the device? On many platforms, the gRPC server and the gNMI service are separate settings.
  2. Is the client on the right port? A device can run several gRPC servers, and only some may serve gNMI.
  3. Does the software release support gNMI at all?

Whichever it is, the fix is on the target, not in the request. And a client that logs only "HTTP 200" here has hidden the failure: always check grpc-status.

Can one connection carry many gNMI calls?

Yes, and that is the point of HTTP/2 streams. Nick's captures each open a new TCP connection for one call. In a capture of our own against a lab gNMI target, one TCP connection carries 16 calls: four Capabilities requests in a single TCP segment, on streams 1, 3, 5, and 7, then four Gets, four Sets, and four Subscribes, each on its own stream.

sequenceDiagram accTitle: Many gNMI calls on one HTTP/2 connection accDescr: One TCP connection and one HTTP/2 settings exchange. The client then opens streams 1, 3, 5, and 7 for four Capabilities calls in one TCP segment, streams 9 to 15 for four Gets, streams 17 to 23 for four Sets, and streams 25 to 31 for four Subscribes. participant C as gNMI client participant T as gNMI target C->>T: TCP handshake, HTTP/2 preface and SETTINGS (once) C->>T: [1, 3, 5, 7] four Capabilities requests in one segment C->>T: [9 to 15] four Get requests C->>T: [17 to 23] four Set requests C->>T: [25 to 31] four Subscribe requests T->>C: responses on each stream, matched by stream number
Sixteen gNMI calls multiplexed on one HTTP/2 connection, from our own lab capture. Stream numbers are in brackets.

Each call is matched to its response by stream number, so responses can come back in any order. The TCP handshake and the HTTP/2 settings exchange happen once. In the Get capture those two cost two round trips, about half the time to the answer; a long-lived client pays them once for all its calls.

gNMI vs NETCONF

NETCONF is the older model-driven protocol, standardized by the IETF in 2006 and revised as RFC 6241 in 2011. Both carry YANG-modeled data; they differ in how:

gNMINETCONF
TransportgRPC over HTTP/2, TLS requiredSSH required (RFC 6241 section 2.3)
Encodingprotobuf messages, values in JSON_IETF or PROTOXML
ReadGet<get>, <get-config>
WriteSet with update, replace, delete<edit-config> with merge, replace, create, delete, remove
Candidate configuration and commitNot in the core specification; each SetRequest is one transactionCandidate datastore and <commit> (section 8.3)
Streaming telemetryBuilt in: SubscribeA separate mechanism (YANG-Push)

In practice gNMI is the usual choice for streaming telemetry, and many operators use NETCONF or gNMI for configuration depending on what their devices and tools support. OpenConfig has added a commit-confirmed extension to gNMI for operators who want NETCONF-style rollback.

Troubleshooting a gNMI client

Capture on the client, or on a port mirror, and decode the gRPC TCP port as HTTP/2. Production gNMI uses TLS, so you need the session keys first. Then:

  1. No connection? Look for the TCP SYN and SYN-ACK. No SYN-ACK points to a firewall or the wrong port.
  2. Connection, but no HTTP/2? A client speaking cleartext to a TLS port, or the reverse, never gets a SETTINGS frame back.
  3. HTTP 200, but an error? Read grpc-status and grpc-message in the trailers or the Trailers-Only header block. 12 with "unknown service" means gNMI isn't served there; 16 means bad credentials; 3 means an invalid argument, such as a bad path.
  4. A response with an error field? If it is empty and grpc-status is 0, the call succeeded. The field is deprecated.
  5. No telemetry? Check how long you waited against sample_interval, and look for the SubscribeResponse and sync_response. These captures waited 10 seconds for the first sample.
  6. A Set that removed too much? Check whether the request used replace where update was meant.

Wireshark needs the .proto files to name protobuf fields. Point its protobuf search path at the folder holding gnmi.proto, gnmi_ext.proto, and everything they import, and turn on the options that load all files and show fields as Wireshark fields. Nick's gnmi.proto imports any.proto and descriptor.proto by bare name, so those two must sit in the same folder.

Frequently asked questions

What port does gNMI use? There is no single standard port. These captures use TCP 5740 (the DevNet sandbox) and TCP 57400 (a Cisco IOS-XR default); 9339 is also common. Check the device configuration.

Does gNMI work without TLS? The specification says no: TLS is required, and fallback to cleartext is forbidden. Lab devices such as the DevNet sandbox often allow cleartext anyway, which is what made these captures readable.

Is a gNMI path the same as an XPath? Close, but not the same. A gNMI path is a list of elements, each with a name and optional keys, such as destination[destination-id=GNMI_1001]. Tools often print it in an XPath-like form.

What is origin in a gNMI path? It says which schema the path belongs to. An empty origin defaults to openconfig (section 2.7.1). The Subscribe responses here set it to the Cisco module Cisco-IOS-XR-telemetry-model-driven-oper.

Why did my Subscribe get no data for a while? In SAMPLE mode, the target may wait one interval before the first sample, as IOS-XR did here. With ON_CHANGE, after the initial snapshot, nothing arrives until something changes.

How does a gNMI client stop a subscription? It cancels the RPC (on the wire, RST_STREAM with code CANCEL) or closes the whole connection.

What is the difference between gRPC and gNMI? gRPC is the general framework for remote calls. gNMI is one service defined on top of it, with four methods for network management. A device can run gRPC without serving gNMI, which is what capture 5 shows.

Takeaways

  1. gNMI is four gRPC methods. Capabilities, Get, and Set are unary; Subscribe streams in both directions.
  2. Each call is an HTTP/2 POST on its own stream. :path names the method, and each message has a 5-byte prefix.
  3. The result is in the trailers, not the HTTP status. HTTP 200 with grpc-status 12 is a failure. An empty deprecated error field with grpc-status 0 is a success.
  4. replace deletes what it doesn't mention; update merges. The same value in the wrong list can remove configuration.
  5. Telemetry may not start for one interval. IOS-XR sent its first 10-second sample after 10 seconds, then sync_response.
  6. "unknown service gnmi.gNMI" is a target-side problem. The gRPC server is up, but gNMI isn't served on that port.
  7. Production gNMI needs TLS. Here the credentials crossed the wire in cleartext.

For another protocol that pushes data from devices, see How MQTT Works over TCP, WebSockets, and TLS.