Mallikarjunarao Kosuri
Mallikarjunarao Kosuri

Reputation: 1111

snmp string limitations?

While I am learning about SNMP, I have some questions on SNMP string operations:

Upvotes: 5

Views: 16052

Answers (4)

Marcin Nowakowski
Marcin Nowakowski

Reputation: 1

The only limitation is that SNMP uses UDP as transport protocol - I agree. However, MTU for UDP is 64k. Refer to https://en.wikipedia.org/wiki/User_Datagram_Protocol. MTU=1500 is for Ethernet standard packets. So, in this case max size is 64k.

Upvotes: -2

Andrew Komiagin
Andrew Komiagin

Reputation: 6556

The OCTET STRING does not have any size limitations. The only limitation here is that SNMP uses UDP as transport protocol. So the MTU=1500. That's you max size.

Upvotes: -2

Jolta
Jolta

Reputation: 2725

An OCTET STRING may contain any sequence of octets, so there is no guarantee that they are printable characters.

Many other "types" are based on OCTET STRING, by adding restrictions. IpAddress, for example, is simply an OCTET STRING restricted to four bytes. This is defined in a Textual Convention definition in a MIB module. RFC1155-SMI contains the definition for IpAddress.

If you're trying to choose the type of a variable, such as when designing a MIB module, you should try to be as restrictive as possible, because this is more informative to the user of the MIB module.

Particularly, don't use OCTET STRING if you know the string should be printable. Instead choose SnmpAdminString (for almost all purposes) or DisplayString (if you are absolutely sure that the data will only contain ASCII characters, and no extended characters like accents & non-roman characters). Both are restricted to 255 octets, which is reasonable for most network management purposes. If you want to transfer larger amounts of data than this, maybe you are trying to do something that SNMP was not designed to facilitate.

Upvotes: 3

Lex Li
Lex Li

Reputation: 63243

In SNMP there is no string concepts. OCTET STRING is not a real string (compared to high level programming languages such as Java and C#), as this data structure has nowhere to store encoding information. Well, this is really horrible.

The maximum string size is only limited by SNMP network packet size, so you should go to TCP/IP protocol for an answer. No SNMP RFC defines a maximum length.

I personally consider OCTET STRING as an array of bytes, so any characters can be stored in it. If you want to restrict them, you should do it in your SNMP agent/engine implementation. When an "invalid" character is found, you can return an SNMP error. Details can be found in RFC 3416 4.2.1. or RFC 1157, 4.1.5.

Upvotes: 4

Related Questions