开发者

snmp string limitations?

开发者 https://www.devze.com 2023-01-31 01:45 出处:网络
While I am learning about SNMP, I 开发者_如何转开发have some questions on SNMP string operations:

While I am learning about SNMP, I 开发者_如何转开发have some questions on SNMP string operations:

  • What is the maximum size of the string?
  • If we have read permission on string how can you determine the size?
  • The string can basically accept all types of character (like #$%^& etc). How can they be restricted?


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.


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消