<?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; Trap Receiver</title>
	<atom:link href="http://www.ashishpaliwal.com/blog/tag/trap-receiver/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 Receiver in 30 minutes using Apache MINA</title>
		<link>http://www.ashishpaliwal.com/blog/2008/10/implementing-trap-receiver-in-30-minutes-using-apache-mina/</link>
		<comments>http://www.ashishpaliwal.com/blog/2008/10/implementing-trap-receiver-in-30-minutes-using-apache-mina/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 10:24:26 +0000</pubDate>
		<dc:creator>ashish</dc:creator>
				<category><![CDATA[Apache MINA]]></category>
		<category><![CDATA[Network Programming]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Trap Receiver]]></category>

		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=157</guid>
		<description><![CDATA[Will continues to post articles about MINA, to be updated,  Subscribe in a reader Yes, we are going to implement a SNMP trap receiver in less than 30 minutes. If you have been following my post on Apache MINA, this would be a natural extension to it. In this article, we shall bring together all [...]]]></description>
			<content:encoded><![CDATA[<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>Will continues to post articles about MINA, to be updated, <a rel="alternate" type="application/rss+xml" href="http://feedproxy.google.com/AshishsTechBlog"><img style="vertical-align:middle;border:0" src="http://www.feedburner.com/fb/images/pub/feed-icon16x16.png" alt="" /></a> <a rel="alternate" type="application/rss+xml" href="http://feedproxy.google.com/AshishsTechBlog">Subscribe in a reader</a></p>
<p>Yes, we are going to implement a SNMP trap receiver in less than 30 minutes. If you have been following my post on Apache MINA, this would be a natural extension to it. In this article, we shall bring together all our components to build the system.</p>
<p> <strong>Pre-requisites:</strong></p>
<p><strong> <span style="font-weight: normal;">Please read through these articles. You can find all these posts on <a href="http://www.ashishpaliwal.com/blog/apache-mina/">Apache MINA</a></span></strong></p>
<ul type="disc">
<li>What is Apache MINA</li>
<li>Apache MINA based Server Application Architecture</li>
<li>Implementing UDP Server using Apache MINA</li>
<li>Implementing SNMP4J Decoder for Apache MINA</li>
</ul>
<p> To execute the code, you need following jars</p>
<ul type="disc">
<li>mina-core-2.0.0-M1.jar</li>
<li>slf4j-api-1.5.0.jar</li>
<li>slf4j-log4j12-1.5.0.jar</li>
<li>log4j-1.2.15.jar</li>
<li>SNMP4J.jar</li>
</ul>
<p> I am assuming that you have read my previous posts and jumping straight to the implementations. The high level architecture is explained in the post Apache MINA based Server Application Architecture</p>
<p><strong>Architecture</strong> </p>
<p><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/traprcvrarchitecture1.png"><img class="aligncenter size-full wp-image-164" title="traprcvrarchitecture1" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/traprcvrarchitecture1.png" alt="" width="500" height="238" /></a></p>
<p>Let’s understand the flow here and see what all we need to do to process a trap</p>
<ul type="disc">
<li class="MsoNormal">Receive      the trap over UDP</li>
<li class="MsoNormal">Decode      the Trap</li>
<li class="MsoNormal">Dump      the Trap</li>
</ul>
<p>Lets see how each of the these maps to the code we have already written</p>
<p><a style="text-decoration: none;" href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/traprcvrcomponents1.png"><span style="color: #000000;"><br />
 </span><img class="aligncenter size-full wp-image-160" style="text-decoration: underline;" title="traprcvrcomponents1" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/traprcvrcomponents1.png" alt="" width="500" height="248" /></a></p>
<p>It's a now simple to understand that we have reused all the components to create the Server. Let me not write too much, and jump straight to the code <span><span>J</span></span></p>
<p><strong> The Server Code</strong></p>
<p><a href="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/trapserver.png"><img class="aligncenter size-full wp-image-161" title="trapserver" src="http://www.ashishpaliwal.com/blog/wp-content/uploads/2008/10/trapserver.png" alt="" width="500" height="339" /></a></p>
<p>The only change that we did to the UDP Server code was to add a Protocol Codec. At line 36, we added our custom ProtocolCodecFiler. The SNMPCodecFactory return the instance of our SNMP4J codec. There is not much code and this construct is fairly simple, and explained very well in MINA’s documentation. From the main method, we just need to call the method initialize() and our trap receiver starts.</p>
<p> </p>
<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><br />
 <strong>References</strong></p>
<ul type="disc">
<li><a href="http://mina.apache.org/">http://mina.apache.org/</a></li>
<li><a href="http://www.snmp4j.org/">http://www.snmp4j.org/</a></li>
</ul>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6961884887741817";
/* 468x60ImageOnly */
google_ad_slot = "0221726572";
google_ad_width = 468;
google_ad_height = 60;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ashishpaliwal.com/blog/2008/10/implementing-trap-receiver-in-30-minutes-using-apache-mina/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
