Customizing the SNMP PDU in Network Simulator

 



Overview

 

When a request is made by the SNMP Manager, the network simulator creates the response SNMP PDU in a memory buffer and writes the PDU in the socket layer, where the IP and UDP headers get added before sending the packet to the SNMP Manager. The "SNMP PDU Scrambler" supports customizing the request/response SNMP PDU by exposing it to the user for customization.

 

The PDU Scrambler Interface enables you to,

For example,  a request SNMP PDU can be customized to send garbled/invalid responses to test the SNMP managers robustness in the event of receiving bad packets.

 

Enabling the PDU Scrambler Feature

 

The PDU Scrambler feature will be enabled if the option Scramble the PDU is selected in the Settings -> Runtime Settings dialog. If the network is started from commandline, the  -ps <enable/disable> is used to enable or disable the PDU scrambler feature.

 

Customizing the request  SNMP PDU

 

The method processRequestPDU(SimulatorSnmpPdu snmpPdu) in <Simulator_Home>/examples/pduscrambler/NetsimPduScrambler.java is used to customize the request PDU.

 

If the option Scramble the PDU is selected, this method will be called with the SnmpPDU object when a SNMP GET, GET NEXT, SET request is made, before sending the packet to the simulator for processing the request. You can add your code inside this method to do the required PDU processing. After the processing, this method returns the modified or scrambled PDU to the simulator.

 

The prototype of this method is given below :

 

import com.adventnet.simulator.scripting.SimScrIntf;

import com.adventnet.simulator.netsim.snmp.SimulatorSnmpPdu

 

public class NetsimPduScrambler {

 

/*Describe processRequestPDU method here*/

 

public void processRequestPDU(SimulatorSnmpPdu snmpPdu) {

 

/*add User Code here*/

 

/**

 * Here user can use the scriptIntf obj ref for working with behavior API

 * The api implementation here is equivalent to configuring jython scripts

 * to be executed before processing request condition

 */

 

/*doProcessWithScriptAPI();

setErrorStatAndIndex(1,1,snmpPdu);*/

}

 

After adding the desired code, compile the NetsimPduScrambler.java file. The compiled class file must be placed in <Simulator_Home>/conf directory.

 

Refer to Simulator SNMP PDU Javadocs for customizing the response PDU.

Refer to Script Interface Javadocs to access the script API methods.

 

Customizing the response SNMP PDU

 

The method processResponsePDU(SimulatorSnmpPdu snmpPdu) in <Simulator_Home>/examples/pduscrambler/SimulatorPDUScrambler.java is used to customize the response PDU.

 

If the option Scramble the PDU is selected, this method will be called with the SnmpPDU object when a SNMP GET, GET NEXT, SET request is made, before sending the packet to the socket layer. You can add your code inside this method to do the required PDU processing. After the processing, this method returns the modified or scrambled PDU to the simulator.

 

The prototype of this method is given below :

 

import com.adventnet.simulator.scripting.SimScrIntf;

import com.adventnet.simulator.netsim.snmp.SimulatorSnmpPdu

 

public class NetsimPduScrambler {

 

* Describe <code>processResponsePDU</code> method here

 *

     * @param snmpPdu <code>SimulatorSnmpPdu</code> value.

 * The response PDU created by the Simulator sent for scrambling

 */

public void processResponsePDU(SimulatorSnmpPdu snmpPdu) {

/**

 * add User Code here.

 */

/**

 * Here user can use the scriptIntf obj ref for working with behavior API

 * The api implementation here is equivalent to configuring jython scripts

 * to be executed after processing request condition

 */

/*doProcessWithScriptAPI();

if(snmpPdu.getIPAddress().equalsIgnoreCase("192.168.1.129") && snmpPdu.getPort() == 8001) {

setErrorStatAndIndex(1,1,snmpPdu);

}*/

}

}

 

After adding the desired code, compile the  NetsimPduScrambler.java file. The compiled class file must be placed in <Simulator_Home>/conf directory.

 

Refer to Simulator SNMP PDU Javadocs for customizing the response PDU.

Refer to Script Interface Javadocs to access the SNMP and TL1 script API methods.

Copyright © 2012, ZOHO Corp. All Rights Reserved.
Network Monitoring Software from ManageEngine