<?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; SMPP</title>
	<atom:link href="http://www.ashishpaliwal.com/blog/category/smpp/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>[SMPP] Sending long SMS through SMPP</title>
		<link>http://www.ashishpaliwal.com/blog/2009/01/smpp-sending-long-sms-through-smpp/</link>
		<comments>http://www.ashishpaliwal.com/blog/2009/01/smpp-sending-long-sms-through-smpp/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 08:40:12 +0000</pubDate>
		<dc:creator>ashish</dc:creator>
				<category><![CDATA[SMPP]]></category>
		<category><![CDATA[Long SMS]]></category>

		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=243</guid>
		<description><![CDATA[SMS is designed to send small text messages upto 140 chars. It actually depends upon the encoding. Using 7 bit encoding, you can send 160 chars, using Unicode, you can only send 70 chars. The data is carried in User Data section. This post talks about ways of sending Long message using SMPP Using SMPP [...]]]></description>
			<content:encoded><![CDATA[<p>SMS is designed to send small text messages upto 140 chars. It actually depends upon the encoding. Using 7 bit encoding, you can send 160 chars, using Unicode, you can only send 70 chars. The data is carried in User Data section.</p>
<p>This post talks about ways of sending Long message using SMPP</p>
<p>Using SMPP we can send long SMS by two means</p>
<p><strong>Using Payload option</strong></p>
<p>Submit SM PDU has a field called message_payload. Set the data in it and you can send upto 64K octets. But this option is not supported by a lot of provider. Verify with your provider, if they support the same.</p>
<p><strong>Using Message fragementation</strong></p>
<p>This format is more common and widely supported. Essentially, the long SMS is divided into smaller messages and send with a particular format, by setting UDH.</p>
<p>The key TLV options used are</p>
<p><em><strong>sar_msg_ref_num</strong></em> - The reference number for a particular concatenated short message</p>
<p><em><strong>sar_total_segments</strong></em> - Indicates the total number of short messages within the concatenated short message</p>
<p><strong><em>sar_segment_seqnum</em></strong> - Indicates the sequence number of a particular short message fragment within the concatenated short message</p>
<p>How do you set these, depends upon the SMPP library you use. Will brief the algo</p>
<p> </p>
<ul>
<li>Break the long sms into parts, so that fragement can fit into single Submit SM PDU</li>
<li>The total number of fragements shall give the value of <strong><em>sar_total_segments</em></strong></li>
<li>Generate a unique identifier value, this becomes the values of <strong><em>sar_msg_ref_num</em></strong></li>
<li>Now in a loop send the message fragements, with values in step above. <strong><em>sar_segment_seqnum</em></strong> values shall be the value of the loop count (ensure that it starts from 1)</li>
</ul>
<p>This is it <img src='http://www.ashishpaliwal.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.ashishpaliwal.com/blog/2009/01/smpp-sending-long-sms-through-smpp/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Multi Threaded Trap Receiver using SNMP4J</title>
		<link>http://www.ashishpaliwal.com/blog/2008/12/multi-threaded-trap-receiver-using-snmp4j/</link>
		<comments>http://www.ashishpaliwal.com/blog/2008/12/multi-threaded-trap-receiver-using-snmp4j/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 08:12:45 +0000</pubDate>
		<dc:creator>ashish</dc:creator>
				<category><![CDATA[SMPP]]></category>
		<category><![CDATA[SNMP]]></category>

		<guid isPermaLink="false">http://www.ashishpaliwal.com/blog/?p=231</guid>
		<description><![CDATA[The entry briefly touched upon creating a multithreaded Trap receiver using SNMP4J. This is based on example shipped with SNMP4J Pre-requisite  SNMP4J  Log4j Structure For complete source have a look at the class org.snmp4j.test. MultiThreadedTrapReceiver.java shipped with SNMP4J distribution Logical structure of the program Create Socket for accepting Traps Create a Thread pool to process [...]]]></description>
			<content:encoded><![CDATA[<p>The entry briefly touched upon creating a multithreaded Trap receiver using SNMP4J. This is based on example shipped with SNMP4J</p>
<p><strong>Pre-requisite</strong></p>
<ul>
<li><span> </span>SNMP4J</li>
<li><span> </span>Log4j</li>
</ul>
<p><strong>Structure</strong></p>
<p>For complete source have a look at the class org.snmp4j.test. MultiThreadedTrapReceiver.java shipped with SNMP4J distribution</p>
<p><em>Logical structure of the program</em></p>
<ul>
<li>Create Socket for accepting Traps</li>
<li>Create a Thread pool to process PDU’s</li>
<li>Process the Traps</li>
</ul>
<p>Let’s get into the code</p>
<p>Lets address the Listener creation steps</p>
<pre class="java5"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #993333;">void</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?sitesearch=java.sun.com&amp;q=allinurl%3Aj2se%2F1+5+0%2Fdocs%2Fapi+UnknownHostException"><span style="color: #aaaadd; font-weight: bold;">UnknownHostException</span></a>, <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/io/IOException.html"><span style="color: #aaaadd; font-weight: bold;">IOException</span></a> <span style="color: #66cc66;">&#123;</span>
&nbsp;
    threadPool = ThreadPool.<span style="color: #006600;">create</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Trap&quot;</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    dispatcher = MultiThreadedMessageDispatcher<span style="color: #66cc66;">&#40;</span>threadPool,
                                           <span style="color: #000000; font-weight: bold;">new</span> MessageDispatcherImpl<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    listenAddress = GenericAddress.<span style="color: #006600;">parse</span><span style="color: #66cc66;">&#40;</span><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">getProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;snmp4j.listenAddress&quot;</span>,
                                                <span style="color: #ff0000;">&quot;udp:0.0.0.0/162&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    TransportMapping transport;
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>listenAddress <span style="color: #000000; font-weight: bold;">instanceof</span> UdpAddress<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      transport = <span style="color: #000000; font-weight: bold;">new</span> DefaultUdpTransportMapping<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>UdpAddress<span style="color: #66cc66;">&#41;</span>listenAddress<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
      transport = <span style="color: #000000; font-weight: bold;">new</span> DefaultTcpTransportMapping<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>TcpAddress<span style="color: #66cc66;">&#41;</span>listenAddress<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    snmp = <span style="color: #000000; font-weight: bold;">new</span> Snmp<span style="color: #66cc66;">&#40;</span>dispatcher, transport<span style="color: #66cc66;">&#41;</span>;
    snmp.<span style="color: #006600;">getMessageDispatcher</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addMessageProcessingModel</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> MPv1<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    snmp.<span style="color: #006600;">getMessageDispatcher</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addMessageProcessingModel</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> MPv2c<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
    snmp.<span style="color: #006600;">getMessageDispatcher</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addMessageProcessingModel</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> MPv3<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    USM usm = <span style="color: #000000; font-weight: bold;">new</span> USM<span style="color: #66cc66;">&#40;</span>SecurityProtocols.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>,
                      <span style="color: #000000; font-weight: bold;">new</span> OctetString<span style="color: #66cc66;">&#40;</span>MPv3.<span style="color: #006600;">createLocalEngineID</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
    SecurityModels.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addSecurityModel</span><span style="color: #66cc66;">&#40;</span>usm<span style="color: #66cc66;">&#41;</span>;
    snmp.<span style="color: #006600;">listen</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span></pre>
<p>Here we see that we have created Transport mapping to Listener on port 162. Next we add all three Message processing models, so that we can process Traps received from all three versions of SNMP (V1, V2C and V3). For SNMPv3, we add a Security model.</p>
<p>That’s it done. We listen and process the traps.</p>
<p>The default implementation of processPdu() in this class, just dumps some statistics on the output.</p>
<p><strong>Customization’s</strong></p>
<p>Let’s see what all can we do with this default example</p>
<ul>
<li>Set only the SNMP version you want to support</li>
<li>Customize the Security Model for SNMP V3</li>
<li>The whole logic lies on processPDU(). You can take complete control of how to process the message and subsequent processing of the message like dumping it to database etc.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ashishpaliwal.com/blog/2008/12/multi-threaded-trap-receiver-using-snmp4j/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
