Subject: [6lowpan] snmp message size calculation

From: Juergen Schoenwaelder <[email-masked]>
Date: Tue, 28 Jul 2009 14:32:21 +0200

Hi,

I found a bug in my SNMP message size calculation and to make things
transparent, I am posting the full details here - just in case someone
wants to check what I did. Note that the calculation assumes no
payload and messages are sent without security (noAuthNoPriv in SNMP
speak). 

A very rough way to estimate the size needed by a varbind that is
essentially a number is the following formula:

    varbind-size = 6 + number-of-OID-subidentifier

That is for sysUpTime (1.3.6.1.2.1.1.3), we get 14 bytes and thus the
SNMPv1 message is 34 bytes and the SNMPv3/USM message is 81 bytes.
And here are the promised details of my calculation.

* SNMPv3 minimum message size calculation

SNMPv3Message			2 byte
  msgVersion			3 byte
  msgGlobalData (HeaderData)   15 byte
  msgSecurityParameters	       23 byte
  msgData (ScopedPDU)	       24 byte
			       -------
			       67 byte

UsmSecurityParameters		2 byte
  msgAuthoritativeEngineID	7 byte
  msgAuthoritativeEngineBoots   3 byte
  msgAuthoritativeEngineTime    3 byte
  msgUserName			2 byte
  msgAuthenticationParameters	2 byte
  msgPrivacyParameters		2 byte
                               -------
			       21 byte

HeaderData			2 byte
  msgID				3 byte
  msgMaxSize			4 byte
  msgFlags			3 byte
  msgSecurityModel		3 byte
                               -------
                               15 byte

ScopedPDU			2 byte
  contextEngineID		7 byte
  contextName			2 byte
  PDU			       13 byte
                               -------
			       24 byte

PDU				2 byte
  request-id			3 byte
  error-status			3 byte
  error-index			3 byte
  variable-bindings		2 byte
			       -------
			       13 byte

* SNMPv1 / SNMPv2c minimum mesage size calculation

SNMPv1Message		        2 byte
  version			3 byte
  community			2 byte
  data (PDU)		       13 byte
                               -------
                               20 byte

/js

-- 
Juergen Schoenwaelder           Jacobs University Bremen gGmbH
Phone: +49 421 200 3587         Campus Ring 1, 28759 Bremen, Germany
Fax:   +49 421 200 3103         <http://www.jacobs-university.de/>