Wednesday, February 11, 2009

kannel send sms to specific port

To send sms to a specific port number ( eg: port in your j2me application ) you have to add following extra parameter to kannel send sms url


which will specify the User Data Header of the sms. For example following url will send the sms to port 6579[kannel user]&password=[kannel passwd]&to=[to phone number]&text=[message text]&udh=%06%05%04%19%B3

As you can see udh is a url-encoded string and it have a standard format as follows;

[how long the UDH is] [the format used to specify ports numbers] [the port number length] [destination port number] [source port number]

As a practical example, say I want to create a UDH to send a sms to port 2948, the UDH will be:

06 05 04 0B 84 23 F0 -> 06%05%04%0B%84%23%F0


* 06 means "hey read the following 6 bytes"
* 05 is the format for numbers, in this case hexadecimal numbers
* 04 will tell the UDH that each port is represented using 4 character
* 0B84 is the destination port in hexadecimal, 2948 (decimal representation)
* 23F0 is the source port in hexadecimal, 9200 (decimal representation) or 23F0 (hexadecimal representation).

You have to keep in mind that after adding udh to the url, sms will be transfred as a binary messaage.



  1. wonderful, you have made my day

  2. Hey laxaman nice article...But i get message as binary can i make it text format using UDH....UDH will allow sending as only BINARY format...???Please help

  3. With java You can try this:

    if (msg instanceof TextMessage) {
    TextMessage textMessage = (TextMessage) msg;
    redMsg = textMessage.getPayloadText();
    } else {
    BinaryMessage binaryMessage = (BinaryMessage) msg;
    byte data[] = binaryMessage.getPayloadData();
    redMsg = new String(data);

  4. Hi Laxman I need your help for sending binary(Picture)sms from kannel. If posible can you help me my mail id is

  5. Please I need Kannel Configration please ?

  6. Hi Laxman I need your help for sending binary(Picture)sms from kannel. If posible can you help me