SNMP trap is the notification. Generally, the SNMP agent sends an SNMP trap message i.e notification to the SNMP manager whenever there is an error or event. SNMP trap can be sent by the SNMP manager as well as SNMP agent. You can also send data in SNMP trap. Here we will see how to send Trap from SNMP manager to an SNMP agent which is a java program.
SNMP TRAP SENDER
SNMP trap sender Implementation steps are given bleow :
Assuming You have an SNMP manager. If you don’t have SNMP manager please click on below link to download the SNMP manager.
Install SNMP MANAGER
1)User needs to enable SNMP AGENT Service of computer or laptop. If you don’t know, how to enable it please click on the below link.
Enable SNMP Agent Service
2)Open your SNMP manager and Click on Tools which is shown below.
3)Click on Trap Sender for sending Trap message which is shown below.
4)When you click on Trap sender, Trap sender page will open but all the options are not visible there. To see all the options please minimize the Trap sender page which is shown below.
5)Fill the following information.
a)IP Address: Enter system IP address on which SNMP agent is running
b)Port: Enter port as 163
c)Optional:You can also send data in SNMP trap message. if you want to send data in trap message please click on Add and enter OID and its value which is shown below.
d)Click on Send Trap to send SNMP trap.
SNMP TRAP RECEIVER
Here java program is used as an SNMP agent which is responsible for receiving SNMP trap from the SNMP manager. Assuming you have java IDE. Implementating SNMP trap receiver using java is given bleow :
1)Download and exact the below java project to receive SNMP trap in any directory.
Java program As SNMP trap receiver (199 downloads)
2)Open your JAVA IDE, example open your Eclipse IDE.
3)Browse the extracted code in step 1. Browsing steps are shown below.
a)Click on file
b)Click oon Open Project
c)Click on Directory and choose the above project extracted folder directory.
d)click on finish.
4)Run SNMPTrapTX.java which is shown below.
COMMON DOUBTS OR PROBLEMS
1)What should I run first i.e Trap sender or receiver?
You should run the SNMP TRAP receiver first so that you can see the trap sent by the SNMP manager.
2)Trap is sending but SNMP agent is not receiving the trap?
This will only happen when the port number and SNMP agent IP address is wrong. so please enter the correct IP address and port number.
3)Port number and IP address is correct but still not receiving the trap?
If you don’t enable SNMP service on your system then also it does not work. To enable SNMP service on your system, please click on the below link.
Enable SNMP Agent Service
4)Why SNMP agent IP address is localhost?
This is because the SNMP manager and SNMP agent are running on the Same system. Instead of localhost, you can also use 127.0.0.1.
4)Can I send data in SNMP Trap?
Yes, you can send. please see step 5.c of Trap sender.
5)can I send SNMP Trap from java program i.e SNMP agent to SNMP manager?
Yes, you can send.
Please click on the below link to become master in SNMP.