title: Net::SMPP in Perl, how to send acknowledgement to SMSC from my ESME
body: <p>I am writing a Perl script that would act as a receiver &amp; transmitter using Net::SMPP. When a mobile subscriber will send a message to a short code (say 123), it would reach to my SMPP account, and my SMPP application would read the message and reply with an acknowledgement to the user, some thing like "Thankyou for sending message".
  I receive message sent by the user to my SMPP app totally fine. The problem is sending back an acknowledgement (delivery_sm_resp) to the SMSC so that it removes that message from the stream, so that next message sent by other user can be collected. I tried using the function but I cant figure out where to get the message_id from the message received from SMSC to my ESME. </p>
  
  <p>My code is.</p>
  
  <pre><code>my $transmitter = Net::SMPP-&gt;new_transmitter($host,port=&gt; $port,system_id =&gt; '123',password  =&gt; '',) or die;
  
  $receiver = Net::SMPP-&gt;new_receiver($host,system_id =&gt; '123',password =&gt; '',port =&gt; $port,)
      or die "Can't create server: $!";
  
  while (1) {
      warn "Waiting for PDU";
      $pdu = $receiver-&gt;read_pdu() or die "$$: PDU not read. Closing connection";
      print "Received #$pdu-&gt;{seq} $pdu-&gt;{cmd}:". Net::SMPP::pdu_tab-&gt;{$pdu-&gt;{cmd}}{cmd} ."\n";
      warn Dumper($pdu);
  
      print "\n\n ** Hello ** " . $pdu-&gt;{message_id} . "\n ** now printing ** " . $pdu-&gt;{sm_default_msg_id};
      $transmitter-&gt;deliver_sm_resp( message_id =&gt; $pdu-&gt;{sm_default_msg_id}, seq =&gt; $pdu-&gt;{seq});
      $resp_pdu = $transmitter-&gt;submit_sm(
          destination_addr =&gt; $pdu-&gt;{source_addr},
          short_message    =&gt; "you sent a message with text " . $pdu-&gt;{short_message}
      ) or die "Response indicated error: " . $resp_pdu-&gt;explain_status();
  
  }
  </code></pre>
  
  <p>The display of message i receive from the SMSC to my ESME is as follows. Please help me locating the message_id from it, which can be used in acknowledging the SMSC, so that it removes that message from the stream, and next message sent by other user can be entertained. Otherwise i receive the same PDU 3 times and till that timeout the next message cant be entertained.</p>
  
  <pre><code>Waiting for PDU at s.pl line 23.
  Received #2 5:deliver_sm
  $VAR1 = bless( {
               'source_addr_ton' =&gt; 1,
               'known_pdu' =&gt; 1,
               'schedule_delivery_time' =&gt; '',
               'protocol_id' =&gt; 0,
               'status' =&gt; 0,
               'short_message' =&gt; 'A',
               'dest_addr_npi' =&gt; 0,
               'source_addr' =&gt; '44702601843',
               'validity_period' =&gt; '',
               'registered_delivery' =&gt; 0,
               'dest_addr_ton' =&gt; 0,
               'seq' =&gt; 2,
               'data_coding' =&gt; 1,
               'service_type' =&gt; '',
               'replace_if_present_flag' =&gt; 0,
               'cmd' =&gt; 5,
               'priority_flag' =&gt; 0,
               'data' =&gt; '44702601843420A',
               'destination_addr' =&gt; '420',
               'esm_class' =&gt; 0,
               'sm_default_msg_id' =&gt; 0,
               'source_addr_npi' =&gt; 0,
               'reserved' =&gt; undef
             }, 'Net::SMPP::PDU' );
  </code></pre>