Editing SNMP MIB Implementation

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 24: Line 24:
  
 
==Convert MIB to Binary File==
 
==Convert MIB to Binary File==
* mib2bin tool is modified from [http://net-snmp.sourceforge.net/ net-snmp] to convert ASN.1 format file to four files, because the microchip '''mib2bib''' converter only supports upto 255 OIDs.
+
* mib2bin tool is modified from [http://net-snmp.sourceforge.net/ net-snmp] to convert ASN.1 format file to three files, because the microchip '''mib2bib''' converter only supports upto 255 OIDs.
 
                                 MIB compiler tools: '''mib2bin'''
 
                                 MIB compiler tools: '''mib2bin'''
 
   [http://www.modtronix.com/products/sbc44ec/00870a.pdf foo.mib] (ANS.1 format)  -----------------------------------> foo.bin + foo_trap.bin + foo.h + foo_data.h
 
   [http://www.modtronix.com/products/sbc44ec/00870a.pdf foo.mib] (ANS.1 format)  -----------------------------------> foo.bin + foo_trap.bin + foo.h + foo_data.h
Line 31: Line 31:
 
   '''mib2bin <MIBfile>...
 
   '''mib2bin <MIBfile>...
 
* where MIBfile file is ASN.1 format file. MIBfile = <name>.<type>
 
* where MIBfile file is ASN.1 format file. MIBfile = <name>.<type>
** '''<name>.bin''' is the binary file storing information of OID tree. This file can be placed on an SD media card to be read by the FAT32 file system.
+
** '''<name>.bin''' is the binary file storing information of OID tree. This file can be placed on an SD media card to be read by the FAT16 file system.
** '''<name>_trap.bin''' is the binary file storing information of TRAP of MIB. This file can be placed on an SD media card to be read by the FAT32 file system.
+
** '''<name>_trap.bin''' is the binary file storing information of TRAP of MIB. This file can be placed on an SD media card to be read by the FAT16 file system.
** '''<name>_data.h''' is C header file storing information of OID tree.  This file is generated by converting mchip.bin file to the C header file. It's only used when a system don't have system file and place on program memory.
+
** '''<name>_data.h''' is C header file storing information of OID tree.  This file is generated by converting mchip.bin file to the C header file.  
 +
It's only used when a system don't have system file and place on program memory.
 
** '''<name>.h''' is C header file storing ID that's reference to function service of OID.
 
** '''<name>.h''' is C header file storing ID that's reference to function service of OID.
 
* Note:  
 
* Note:  
 
** Subfolder '''mibs''' containing the basics MIB files (e.g.: RFC1155-SMI, RFC1213-MIB, RFC-1215, SNMPv2-MIB ... for us MIB file), must be present under the directory of execution.
 
** Subfolder '''mibs''' containing the basics MIB files (e.g.: RFC1155-SMI, RFC1213-MIB, RFC-1215, SNMPv2-MIB ... for us MIB file), must be present under the directory of execution.
** If the four files exist, mib2bin tool will overwrite the files.
+
** If the three files exist, mib2bin tool will overwrite the files.
  
 
===Binary File Format <name>.bin===
 
===Binary File Format <name>.bin===
Line 54: Line 55:
 
* The microchip format only supports OIDs upto 255. The following is an workaround to store OID greater than 255.
 
* The microchip format only supports OIDs upto 255. The following is an workaround to store OID greater than 255.
 
* Format of OID:
 
* Format of OID:
  An OID is a series of (one or more) octets (e.g. 04 01 82 99 5D). Bit 8 of each octet indicates whether it is the last octet in the series:  
+
      An OID is a series of (one or more) octets. Bit 8 of each octet indicates whether it is the last in the series: bit 8 of the last octet is zero;
   If bit 8 of is zero, it is the last octet (e.g. 04, 01, 5D), otherwise, bit 8 is set to one (e.g. 82, 99).
+
   bit 8 of each preceding octet is one. Bits 7 to 1 of the octets in the series collectively encode the OID. Conceptually, these groups of bits are
 +
  concatenated to form an unsigned binary number whose most significant bit is bit 7 of the first octet and whose least significant bit is bit 1 of
 +
  the last octet. The OID shall be encoded in the fewest possible octets, that is, the leading octet of the OID shall not have the value 0x80.
 
    
 
    
  Bits 7 to 1 of the octets are used to encode the OID. Conceptually, these bits are concatenated to form an unsigned binary number whose most
 
  significant bit (bit 7) of the first octet and the least significant bit (bit 1) of the last octet. The OID shall be encoded in the fewest
 
  possible octets, that is, the leading octet of the OID shall not have the value 0x80.
 
 
* Example:
 
* Example:
 
     The OID              encode of OID in binary file (hex)
 
     The OID              encode of OID in binary file (hex)
       4                       BYTE(0x04)
+
       4                         BYTE(0x04)
       1                       BYTE(0x01)
+
       1                         BYTE(0x01)
     36061                      BYTE(0x80 + 0x02) BYTE(0x80 + 0x19) BYTE(0x5D)
+
     36061                      BYTE(0x80+ 0x02) BYTE(0x80 + 0x19) BYTE(0x5D)
 
     The OID = 36061 is decoded by 0x02*0x80*0x80 + 0x19*0x80 + 0x5D
 
     The OID = 36061 is decoded by 0x02*0x80*0x80 + 0x19*0x80 + 0x5D
  
Line 152: Line 152:
 
===Binary File Format <name>_trap.bin===
 
===Binary File Format <name>_trap.bin===
 
* The binary file store TRAP information. It is generated by mib2bin tool. Agents will read binary file to get information of TRAP when something bad occurs.
 
* The binary file store TRAP information. It is generated by mib2bin tool. Agents will read binary file to get information of TRAP when something bad occurs.
* In the binary file, An enterprise OID is stored first, followed by its first specific trap number and IDs of first specific trap (those IDs matche with IDs of leaf in <name>.bin; IDs are reference to OIDs of data bindings that be included in this trap) to last specific trap number and IDs of last specific trap. Next, the structure of next this enterprise OID is stored. This structure is repeated until all enterprise OID in MIB file is stored.
+
* In the binary file, A enterprise OID is stored first, followed by its first specific trap number and ID (this ID is match with ID of leaf in <name>.bin) data bindings to be included in this trap to last specific trap number and ID data bindings to be included it. Next, the structure of next this enterprise is stored. This structure is repeated until all enterprise in MIB file is stored.
 
* The format of enterprise in <name>_trap.bin
 
* The format of enterprise in <name>_trap.bin
 
   <enterprise_oid><sibling_enterprise><enterprise_index>[specific_trap_number][sibling_specific_trap][number_varbinds][id_varbind]...
 
   <enterprise_oid><sibling_enterprise><enterprise_index>[specific_trap_number][sibling_specific_trap][number_varbinds][id_varbind]...
Line 377: Line 377:
 
* Varbind List is a Sequence of Varbinds.
 
* Varbind List is a Sequence of Varbinds.
 
** Varbind is a Sequence of two fields, an OID and the value of OID.
 
** Varbind is a Sequence of two fields, an OID and the value of OID.
*** OID is an Object Identifier that points to a particular parameter in the SNMP agent. The first two object identifier components in the object identifier value being encoded, using the formula: <font color=red>(X*40) + Y</font>; where X is the value of the first object identifier component and Y is the value of the second object identifier component. The first two object identifier components recognizes that only three values are allocated from the root node, and at most 39 subsequent values from nodes reached by X = 0 and X = 1.
+
*** OID is an Object Identifier that points to a particular parameter in the SNMP agent.
 
*** Value is the value of OID.
 
*** Value is the value of OID.
 
   +--------------------+-----------------------------------------------------------------+
 
   +--------------------+-----------------------------------------------------------------+
Line 442: Line 442:
 
* Time stamp is the time elapsed between the last initialization of the network entity and the generation of the trap.
 
* Time stamp is the time elapsed between the last initialization of the network entity and the generation of the trap.
 
* Varbind List is a Sequence of Varbinds to be included in the trap.
 
* Varbind List is a Sequence of Varbinds to be included in the trap.
** Varbind is a Sequence of two fields, an OID and the value of OID. The OIDs for these variable bindings are often specific to the trap and therefore "underneath" the specific OID for the trap. But this isn't a requirement, and it's often useful to send bindings that aren't defined as part of the trap.  
+
** Varbind is a Sequence of two fields, an OID and the value of OID.
 
*** OID is an Object Identifier that points to a particular parameter in the SNMP agent.
 
*** OID is an Object Identifier that points to a particular parameter in the SNMP agent.
 
*** Value is the value of OID
 
*** Value is the value of OID
 
 
===Example SNMP Message===
 
===Example SNMP Message===
 
====GetRequest PDU====
 
====GetRequest PDU====
Line 553: Line 552:
 
   |        |          |        |            |          |      | 0x01                                                        |Length: 1          |
 
   |        |          |        |            |          |      | 0x01                                                        |Length: 1          |
 
   +---------+-----------+--------+------------+-----------+-------+-------------------------------------------------------------+-------------------+
 
   +---------+-----------+--------+------------+-----------+-------+-------------------------------------------------------------+-------------------+
==[http://docstore.mik.ua/orelly/networking_2ndEd/snmp/ch02_06.htm= SNMP operations]==
 
* NMS uses GetRequest command to retrieve the value of objects from agents. Objects that is defined by object identifier in MIB file. It is possible for an NMS to get more than one object at a time. The agent receives the request and processes it. After that, it sends GetResponse back to NMS with current value of objects.
 
* NMS uses GetNextRequest command to discover available objects and the value of these objects from agents. The GetNextRequest command traverses a subtree in lexicographic order. Based on the OIDs in GetNextRequest PDU, it's easy for an agent to start at the root of its SMI object tree and work its way down until it finds the OID it is looking for. After the agent found avaible objects, it sends GetResponse back to NMS with current value of objects.
 
* NMS uses SetRequest command to change the value of objects from agents. After the agent processes SetRequest, it send GetResponse back to NMS with new value of objects (value of objects that get from SetRequest).
 
* The agent sends Trap to NMS when agent's something bad operation conditions. No repspone is sent from the NMS to the agent when NMS receives Trap.
 
* Example SNMP operations with net-snmp:
 
  '''GetRequest command:'''
 
  >> snmpget -v 1 -c public 192.168.1.128 1.3.6.1.4.1.36061.1.1
 
  This command will send GetRequest to the agent (IP address of agent is 192.186.1.128). The SNMP is SNMPv1 (the option ''-v 1'') with community
 
  string is public (the option ''-c public''). In above demo MIB file, 1.3.6.1.4.1.36061.1.1 is OID reference to devID object.
 
  The effect of this command will get the value of agent's devID .
 
  '''GetNextRequest command:'''
 
  >> snmpgetnext -v 1 -c public 192.168.1.128 1.3.6.1.4.1.36061.1
 
  This command will send GetNextRequest to the agent (IP address of agent is 192.186.1.128). The SNMP is SNMPv1 (the option ''-v 1'') with community
 
  string is public (the option ''-c public''). In above demo MIB file, 1.3.6.1.4.1.36061.1 is OID.
 
  The effect of this command will get the value of agent's devID.
 
  '''SetRequest command:'''
 
  >> snmpset -v 1 -c public 192.168.1.128 1.3.6.1.4.1.36061.1.1 s "Hello"
 
  This command will send SetRequest to the agent (IP address of agent is 192.186.1.128). The SNMP is SNMPv1 (the option ''-v 1'') with community
 
  string is public (the option ''-c public''). In above demo MIB file, 1.3.6.1.4.1.36061.1.1 is OID reference to devID object.
 
  The effect of this command will set the value of agent's devID to "Hello".
 
  '''Receiving Traps'''
 
  To receive Traps, snmptrapd.conf file must be configured and snmptrapd must be running.
 
  The easiest way to configure this is by adding this line to snmptrapd.conf file:
 
      disableAuthorization yes
 
  The following command will receive and view trap
 
  >>snmptrapd -f -Le
 

Please note that all contributions to OpenCircuits may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see OpenCircuits:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)