Table of Contents

Concatenation

The GSM standard defines a maximum of 140 octets for a single short message and thus does not support the transmission of more than these 140 octets per message. Therefore, a receiving SMSC will usually not accept a submit operation which will result in a short message of >140 octets, unless it has implemented an automatic concatenation mechanism, which divides a long message in multiple parts of 140 octets.

Various SMPP providers support various concatenation ways. Inetlab.SMPP library supports 3 ways:

  1. message text in the field short_message and concatenation parameters in user data header

SMS Builder class uses this type of concatenation by default. Example how to submit SubmitSm PDUs:

public async Task SendConcatenatedMessageInUDH(TextMessage message)
{
    var builder = SMS.ForSubmit()
        .From(_config.ShortCode, AddressTON.NetworkSpecific, AddressNPI.Unknown)
        .To(message.PhoneNumber)
        .Text(message.Text);

    var resp = await _client.SubmitAsync(builder);
}

Example how to get concatenation parameters from PDU user data header:

public static Concatenation GetConcatenationFromUDH(SubmitSm data)
{
    ConcatenatedShortMessages8bit udh8 = data.UserData.Headers.Of<ConcatenatedShortMessages8bit>().FirstOrDefault();

    if (udh8 == null) return null;

    return new Concatenation(udh8.ReferenceNumber, udh8.Total, udh8.SequenceNumber);
}

Example how you can manually create SubmitSm instance, that contains only one message part with concatenation parameters in the user data header:

public SubmitSm CreateSumbitSmWithConcatenationInUDH(ushort referenceNumber, byte totalParts, byte partNumber, string textSegment)
{

    SubmitSm sm = new SubmitSm();
    sm.SourceAddress = new SmeAddress("1111");
    sm.DestinationAddress = new SmeAddress("79171234567");
    sm.DataCoding = DataCodings.Default;
    sm.RegisteredDelivery = 1;
    sm.UserData.ShortMessage = _client.EncodingMapper.GetMessageBytes(textSegment, sm.DataCoding);

    sm.UserData.Headers.Add(new ConcatenatedShortMessage16bit(referenceNumber, totalParts, partNumber));

    return sm;
}
  1. message text in the field short_message and concatenation parameters in SAR TLV parameters (sar_msg_ref_num, sar_total_segments, sar_segment_seqnum, more_messages_to_send)

Example how to create SubmitSm instances with SMS Builder:

var builder = SMS.ForSubmit()
    .From(_config.ShortCode, AddressTON.NetworkSpecific, AddressNPI.Unknown)
    .To(message.PhoneNumber)
    .Text(message.Text);

builder.Concatenation(ConcatenationType.SAR);

var resp = await _client.SubmitAsync(builder);

Example how to get concatenation parameters from TLV Parameters:

public static Concatenation GetConcatenationFromTLVOptions(SubmitSm data)
{
    ushort refNumber = 0;
    byte total = 0;
    byte seqNum = 0;

    var referenceNumber = data.Parameters.Of<SARReferenceNumberParamter>().FirstOrDefault();
    if (referenceNumber != null)
    {
        refNumber = referenceNumber.ReferenceNumber;
    }
    var totalSegments = data.Parameters.Of<SARTotalSegmentsParameter>().FirstOrDefault();
    if (totalSegments != null)
    {
        total = totalSegments.TotalSegments;
    }
    var sequenceNumber = data.Parameters.Of<SARSequenceNumberParameter>().FirstOrDefault();
    if (sequenceNumber != null)
    {
        seqNum = sequenceNumber.SequenceNumber;
    }

    return new Concatenation(refNumber, total, seqNum);
}
  1. message text in the TLV parameter message_payload and concatenation parameters in SAR TLV parameters

Example how to create SubmitSm instances with SMS Builder:

var builder = SMS.ForSubmit()
    .From(_config.ShortCode, AddressTON.NetworkSpecific, AddressNPI.Unknown)
    .To(message.PhoneNumber)
    .Text(message.Text);

builder.MessageInPayload();

var resp = await _client.SubmitAsync(builder);