Meaning of the number sent with Netconf payload

79 Views Asked by At

I am using confd based Netconf agent. When I checked the XML payload received by the agent, I see a number prefixed in the payload. It is not message-id. What is this prefix? Please give any RFC reference which explains the prefix.

For example, "#164" is prefixed with the get-config payload.

#164
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<rpc message-id=\"0\"
    xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">
    <get-config>
        <source>
            <running/>
        </source>
    </get-config>
</rpc>

Similarly, different prefixes are used for the other Netconf operation as listed below.

get 118
close-session 128
lock 154
unlock 158
delete-config 172
edit-config 190
copy-config 193
2

There are 2 best solutions below

0
On

The #164 you are seeing is a part of NETCONF 1.1 over SSH chunked framing mechanism.

RFC6242, Section 4.2, Chunked Framing Mechanism

As an example, the message:

  <rpc message-id="102"
       xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <close-session/>
  </rpc>

could be encoded as (using '\n' as a visible representation of the LineFeed character):

C:  \n#4\n
C:  <rpc
C:  \n#18\n
C:   message-id="102"\n
C:  \n#79\n
C:       xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">\n
C:    <close-session/>\n
C:  </rpc>
C:  \n##\n

The length of bytes in your example matches if you strip away all formatting chars:

<?xml version="1.0" encoding="UTF-8"?><rpc message-id="0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><get-config><source><running/></source></get-config></rpc>
0
On

NETCONF over SSH uses a special form of chunked framing for the exchanged XML stanzas. Essentially, it's a way for the parser at the other side to see when an individual message ends.