About SNMP Protocol
About SNMP
Simple Network Management Protocol (SNMP) is an Internet-standard protocol for collecting and organizing information about managed devices on IP networks and for modifying that information to change device behavior. Devices that typically support SNMP include switches, routers, servers, cable modems, workstations, printers, UPSs, IP video cameras, IP telephones. SNMP is widely used in network management for network monitoring. SNMP exposes management data in the form of variables on the managed systems organized in a management information base (MIB) which describe the system status and configuration. MIB-files are readable text-files. These variables can then be remotely queried (and, in some circumstances, manipulated) by managing applications. Object Identifier (OID), a string of numbers derived from a global naming tree, is used to identify an object. E.g. :'1.3.6.1.4.1.16177.1.1.9.1'.
The principle of BER (Basic Encoding Rules) is that each field has an introducer that indicates the datatype of the contents and its length. The basic pattern used to encode a value is:
identifier | length (of the contents) | contents |
The identifier declares the datatype of the contents. SNMPManagerIO supports the following type identifiers:
Type (identifier) | SNMP Byte-value | Comment/Description |
---|---|---|
BOOLEAN | 0x01 | 0xFF or 0x00 |
INTEGER | 0x02 | -2147483648..2147483647 |
BIT_STRING | 0x03 | When decoded and length is <= 32 bits, it will be converted to hex-value |
OCTET_STRING | 0x04 | sequence of arbitrary bytes |
DISPLAYSTRING | 0x04 | a special case of the octet string type where all the bytes are printable ASCII characters |
NULL | 0x05 | length and value following this type in SNMP packet: only one byte equal 0x00 |
OBJECT_IDENTIFIER | 0x06 | E.g. '1.3.6.1.4.1.16177.1.1.9.1' |
SEQUENCE | 0x30 | an ordered list of objects |
IP_ADDRESS | 0x40 | four byte 'IP version 4' address |
COUNTER32 | 0x41 | 0..4294967295 |
GAUGE32 | 0x42 | 0..4294967295 |
TIME_TICKS | 0x43 | elapsed time in hundredths of a second, decoded to a null-terminated string containing corresponding days, hours, minutes, seconds and hundreth seconds |
OPAQUE | 0x44 | wrapper for arbitrary ASN.1 types (treated as OCTET_STRING in SNMPManagerIO) |
NSAP_ADDRESS | 0x45 | (treated as OCTET_STRING in SNMPManagerIO) |
COUNTER64 | 0x46 | 0..18446744073709551615 |
UINTEGER32 | 0x47 | 0..4294967295 |
Protocol details
SNMP operates in the Application Layer, using UDP as transport layer:
IP header | UDP header | SNMP Message |
SNMP Message is a Sequence of three smaller fields: the SNMP Version (Integer), the SNMP Community String (Octet String), and the SNMP PDU. There exist 7 SNMP protocol data unit (PDU) types: GetRequest, SetRequest, GetNextRequest, GetBulkRequest, Response, Trap and InformRequest. SNMPManagerIO may send GetRequest and SetRequest, and receive Response and Trap.
+------------------------------------------------------------------------+ | SNMP Message (Sequence type) | +------+----------------+------------------------------------------------+ | Type | Length of Data | Data | +------+----------------+-------------+-----------------------+----------+ | 0x30 | Length |SNMP Version | SNMP Community String | SNMP PDU | | | | (Integer) | (Octet String) | | +------+----------------+-------------+-----------------------+----------+ |<--------------------Length-------------------->|
SNMP PDU for GetRequest v1 and v2, SetRequest v1 and v2, Response v1 and v2, Trap v2:
+------+--------+---------------------------------------------------------------------------------------------------------------------+ | PDU | Length | Data of SNMP PDU | | type | Data | | +------+--------+---------+---------+---------+---------------------------------------------------------------------------------------+ | PDU | Length | Request | Error | Error | VarBind List (Sequence) | | type | PDU | ID | Status | Index +------+--------+--------------------------------+--------------------------------+-----+ | | | | | | 0x30 | Length | Varbind 1 | Varbind 2 | ... | | | |(Integer)|(Integer)|(Integer)| | | (Sequence) | (Sequence) | ... | | | | | | | | +------+-------+-------+---------+------+-------+-------+---------+-----+ | | | | | | | | 0x30 | Len 1 | OID 1 | Value 1 | 0x30 | Len 2 | OID 2 | Value 2 | ... | +------+--------+---------+---------+---------+------+--------+------+-------+-------+---------+------+-------+-------+---------+-----+ | | |<-----Len 1----->| |<-----Len 2----->| | | |<-------------------------------Length-------------------------------->| |<----------------------------------------------Lenght PDU----------------------------------------------------------->|
SNMP PDU for Trap v1:
+----+------+------------------------------------------------------------------------------------------------------------------------------+ |PDU |Length| Data of SNMP PDU | |type| Data | | +----+------+----------+-------+-------+--------+------+---------------------------------------------------- ------------------------------+ |0xA4|Length|Enterprise| Agent |Generic|Specific|Time | VarBind List (Sequence) | | | PDU | OID |Address| Trap | Trap |Stamp +------+--------+------------------------------+------------------------------+-----+ | | | | | Type | Number | | 0x30 | Length | Varbind 1 | Varbind 2 | ... | | | | (OID) | | | | | | | (Sequence) | (Sequence) | ... | | | | | | | | | | +----+-------+-------+---------+----+-------+-------+---------+-----+ | | | | | | | | | |0x30| Len 1 | OID 1 | Value 1 |0x30| Len 2 | OID 2 | Value 2 | ... | +----+------+----------+-------+-------+--------+------+------+--------+----+-------+-------+---------+----+-------+-------+---------+-----+ | | |<-----Len 1----->| |<-----Len 2----->| | | |<-----------------------------Length------------------------------>| |<--------------------------------------------Lenght PDU----------------------------------------------------------->|
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.