1

We have snmp agent in our product, which sends system alerts to snmp server, and our alerts may be in Unicode. We are using 3rd party lib for sending out, which encodes stings into a ASKII byte array by default. Finally we got garbage on messages.

Is there unicode support for snmp protocol?

  • SNMP only transfers bytes (its OCTET STRING type is not for "modern string" with encoding). Thus, it would be your responsibility to encode the data before sending, and parse the data when received with proper decoding code. You should not expect SNMP to do anything more for you. – Lex Li Jun 23 '17 at 01:32
  • Sure, but how receiver will determine is it Unicode or not, to decide how to decode? I assume it should be supported by protocol itself. – Armen Yeganyan Jun 26 '17 at 15:09
  • Text encoding is out of scope of SNMP. After receiving the bytes for that text, it would be your application's responsibility to assert its encoding and decode bytes to text. – Lex Li Jun 26 '17 at 15:24
  • Is it means that in case of the 3rd party SNMP receiver there is no way to localize messages? – Armen Yeganyan Jun 26 '17 at 16:00
  • Do you have source code of the 3rd party library? A well designed one should give you flexibility to specify text encoding (my personal project is in that way), and if you happen to hit a bad one, you are stuck. – Lex Li Jun 26 '17 at 18:04
  • No actually only snmp agent is in my product, receiver's are in costumer side. – Armen Yeganyan Jun 27 '17 at 05:56

2 Answers2

1

It is the SNMP agents job to localize the message properly. It is the SNMP management tool's job to decode the message properly.

A WireShark trace will show whether your agent put the correct byte array on the wire. If your message is Unicode the bytes should start with a valid Unicode preamble.

Also depending on your device type there are other areas in the agent's MIB that help the management tool decode the message properly.

For example the prtLocalizationTable for printers should show support for Unicode, and prtGeneralCurrentLocalization helps management tools know how to decode the message properly.

Larry Meyer
  • 90
  • 1
  • 9
  • Larry, I understand, but is there any way to "specify" the correct localization for the message via protocol, I've found prtGeneralCurrentLocalization snmp object , but not sure what is it about. – Armen Yeganyan Jul 12 '17 at 10:42
  • A management tools can set the value of prtGeneralCurrentLocalization so that localized strings are retrieved in the language the management tool wants. For example a printer console language could be in French for the local walk up user, but the management tool wants all strings returned in English. So before retrieving a localized string the management tool checks or sets the printer's prtGeneralCurrentLocalization to English, retrieves the localized string, and tries to decode it as English. – Larry Meyer Jul 13 '17 at 13:04
0

As Lex Li already mentioned SNMP does not care about string encoding. The OCTET STRING is just a byte array. So when you have to deal with localization/ internationalization the proper solution is definitely the use of UTF-8 encoding/decoding. But keep in mind that SNMP4J and many other libraries treat byte array as ASCII string in methods like toString(). So you'll have to write your own extensions.

Andrew Komiagin
  • 6,446
  • 1
  • 13
  • 23