<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ashish's Tech Blog &#187; SMP</title>
	<atom:link href="http://www.ashishpaliwal.com/blog/tag/smp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ashishpaliwal.com/blog</link>
	<description>From Programmer, For Programmers</description>
	<lastBuildDate>Tue, 17 Aug 2010 12:04:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Implementing Trap Sender using SNMP4J</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-trap-sender-using-snmp4j/</link>
		<comments>http://www.ashishpaliwal.com/blog/2008/10/implementing-trap-sender-using-snmp4j/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 06:56:06 +0000</pubDate>
		<dc:creator>ashish</dc:creator>
				<category><![CDATA[Application Programming]]></category>
		<category><![CDATA[Network Programming]]></category>
		<category><![CDATA[Apache MINA]]></category>
		<category><![CDATA[SMP]]></category>
		<category><![CDATA[SNMP4J]]></category>
		<category><![CDATA[Trap Sender]]></category>

		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=176</guid>
		<description><![CDATA[In this post, we shall implement a Trap Sender using SNMP4J. We may choose to use Apache MINA for sending Traps or can resort to using DatagramSocket class directly. This shall be the logical flow of the implementation Get the encoded Trap Data Send the Trap  Lets look at the first component, on getting the [...]]]></description>
			<content:encoded><![CDATA[<p>In this post, we shall implement a Trap Sender using SNMP4J. We may choose to use Apache MINA for sending Traps or can resort to using DatagramSocket class directly.</p>
<p>This shall be the logical flow of the implementation</p>
<ul>
<li>Get the encoded Trap Data</li>
<li>Send the Trap </li>
</ul>
<div>Lets look at the first component, on getting the encoded Trap data</div>
<p> </p>
<div><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/trapdata.png"><img class="aligncenter size-full wp-image-178" title="trapdata" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/trapdata.png" alt="" width="500" height="224" /></a></div>
<p>The code snippet above shows a simple way of creating and encoding a Trap PDU. Essentially, we create an instance of PDU class and sets the type as Trap. This is important, else SNMP4J shall throw an exception. Thereafter, we can set the trap parameters. Here, we have hardcoded the parameters, there can be custom implementations that can take these from config files or from UI. After setting the parameters, we just call the encode function passing the Output stream and collect the byte array to be sent.</p>
<div>Sending part is even simpler     </p>
<div><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/sendtrap.png"><img class="aligncenter size-full wp-image-179" title="sendtrap" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/sendtrap.png" alt="" width="500" height="83" /></a></div>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6961884887741817";
/* 468x15LinkUnit */
google_ad_slot = "4400881690";
google_ad_width = 468;
google_ad_height = 15;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p>
<p>The send code is preety straight forward. Here we have used Datagram Socket, we can use Apache MINA UDP Client implementation to send the trap as well.</p>
<div>References</div>
<div>
<ul>
<li><a href="http://www.snmp4j.org/">http://www.snmp4j.org/</a></li>
<li><a href="http://www.ashishpaliwal.com/blog/2008/10/implementing-udp-client-using-apache-mina/">Implementing UDP Client using Apache MINA</a> </li>
</ul>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ashishpaliwal.com/blog/2008/10/implementing-trap-sender-using-snmp4j/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
