Search in sources :

Example 1 with SplittingType

use of org.mobicents.smsc.tools.smppsimulator.SmppSimulatorParameters.SplittingType in project smscgateway by RestComm.

the class SmppTestingForm method doSendSmppMessages.

private void doSendSmppMessages() {
    Random rand = new Random();
    for (int i1 = 0; i1 < this.param.getBulkMessagePerSecond() / threadCount; i1++) {
        int n = this.param.getBulkDestAddressRangeEnd() - this.param.getBulkDestAddressRangeStart() + 1;
        if (n < 1)
            n = 1;
        int j1 = rand.nextInt(n);
        Integer destAddr = this.param.getBulkDestAddressRangeStart() + j1;
        String destAddrS = destAddr.toString();
        int j2 = rand.nextInt(2);
        int j3 = rand.nextInt(3);
        EncodingType encodingType;
        if (j2 == 0)
            encodingType = EncodingType.GSM7_DCS_0;
        else
            encodingType = EncodingType.UCS2_DCS_8;
        SplittingType splittingType;
        switch(j3) {
            case 0:
                splittingType = SplittingType.DoNotSplit;
                break;
            case 1:
                splittingType = SplittingType.SplitWithParameters_DefaultSegmentLength;
                break;
            default:
                splittingType = SplittingType.SplitWithUdh_DefaultSegmentLength;
                break;
        }
        int j4 = rand.nextInt(5);
        String msg = this.param.getMessageText();
        if (j4 == 0)
            msg = bigMessage;
        msg += " " + ((Integer) messagesNum.incrementAndGet()).toString();
        this.submitMessage(encodingType, 0, msg, splittingType, param.getValidityType(), destAddrS, param.getMessagingMode(), param.getSpecifiedSegmentLength());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Random(java.util.Random) EncodingType(org.mobicents.smsc.tools.smppsimulator.SmppSimulatorParameters.EncodingType) SplittingType(org.mobicents.smsc.tools.smppsimulator.SmppSimulatorParameters.SplittingType)

Example 2 with SplittingType

use of org.mobicents.smsc.tools.smppsimulator.SmppSimulatorParameters.SplittingType in project smscgateway by RestComm.

the class SmppTestingForm method submitMessage.

private void submitMessage(EncodingType encodingType, int messageClass, String messageText, SplittingType splittingType, ValidityType validityType, String destAddr, SmppSimulatorParameters.MessagingMode messagingMode, int specifiedSegmentLength) {
    if (session0 == null)
        return;
    try {
        int dcs = 0;
        ArrayList<byte[]> msgLst = new ArrayList<byte[]>();
        int msgRef = 0;
        switch(encodingType) {
            case GSM7_DCS_0:
                dcs = 0;
                break;
            case GSM8_DCS_4:
                dcs = 4;
                break;
            case UCS2_DCS_8:
                dcs = 8;
                break;
        }
        // if (messageClass) {
        // dcs += 16;
        // }
        int messageClassVal = 0;
        if (messageClass > 0) {
            messageClassVal = messageClass;
        }
        DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(dcs);
        int maxLen = MessageUtil.getMaxSolidMessageCharsLength(dataCodingScheme);
        int maxSplLen = MessageUtil.getMaxSegmentedMessageCharsLength(dataCodingScheme);
        if (splittingType == SplittingType.SplitWithParameters_SpecifiedSegmentLength || splittingType == SplittingType.SplitWithUdh_SpecifiedSegmentLength) {
            maxLen = specifiedSegmentLength;
            maxSplLen = specifiedSegmentLength;
        }
        int segmCnt = 0;
        int esmClass = 0;
        boolean addSegmTlv = false;
        if (messageText.length() > maxLen) {
            // may be message splitting
            SplittingType st = splittingType;
            switch(st) {
                case DoNotSplit:
                    // we do not split
                    byte[] buf1 = encodeSegment(messageText, encodingType);
                    byte[] buf2;
                    if (encodingType == EncodingType.GSM8_DCS_4) {
                        // 4-bytes length
                        byte[] bf3 = new byte[7];
                        // total UDH length
                        bf3[0] = 6;
                        // UDH id
                        bf3[1] = 5;
                        // UDH length
                        bf3[2] = 4;
                        bf3[3] = 0x3E;
                        bf3[4] = (byte) 0x94;
                        bf3[5] = 0;
                        bf3[6] = 0;
                        // 0-bytes length
                        // bf3 = new byte[3];
                        // bf3[0] = 2; // total UDH length
                        // bf3[1] = 112; // UDH id
                        // bf3[2] = 0; // UDH length
                        buf2 = new byte[bf3.length + buf1.length];
                        System.arraycopy(bf3, 0, buf2, 0, bf3.length);
                        System.arraycopy(buf1, 0, buf2, bf3.length, buf1.length);
                        esmClass = 0x40;
                    } else {
                        buf2 = buf1;
                    }
                    msgLst.add(buf2);
                    ArrayList<String> r1 = this.splitStr(messageText, maxSplLen);
                    segmCnt = r1.size();
                    break;
                case SplitWithParameters_DefaultSegmentLength:
                case SplitWithParameters_SpecifiedSegmentLength:
                    msgRef = getNextMsgRef();
                    r1 = this.splitStr(messageText, maxSplLen);
                    for (String bf : r1) {
                        msgLst.add(encodeSegment(bf, encodingType));
                    }
                    segmCnt = msgLst.size();
                    addSegmTlv = true;
                    break;
                case SplitWithUdh_DefaultSegmentLength:
                case SplitWithUdh_SpecifiedSegmentLength:
                    msgRef = getNextMsgRef();
                    r1 = this.splitStr(messageText, maxSplLen);
                    byte[] bf1 = new byte[6];
                    // total UDH length
                    bf1[0] = 5;
                    // UDH id
                    bf1[1] = 0;
                    // UDH length
                    bf1[2] = 3;
                    // refNum
                    bf1[3] = (byte) msgRef;
                    // segmCnt
                    bf1[4] = (byte) r1.size();
                    int i1 = 0;
                    for (String bfStr : r1) {
                        byte[] bf = encodeSegment(bfStr, encodingType);
                        i1++;
                        // segmNum
                        bf1[5] = (byte) i1;
                        byte[] bf2 = new byte[bf1.length + bf.length];
                        System.arraycopy(bf1, 0, bf2, 0, bf1.length);
                        System.arraycopy(bf, 0, bf2, bf1.length, bf.length);
                        msgLst.add(bf2);
                    }
                    segmCnt = msgLst.size();
                    esmClass = 0x40;
                    break;
            }
        } else {
            byte[] buf = encodeSegment(messageText, encodingType);
            if (encodingType == EncodingType.GSM8_DCS_4) {
                byte[] bf1 = new byte[7];
                // total UDH length
                bf1[0] = 6;
                // UDH id
                bf1[1] = 5;
                // UDH length
                bf1[2] = 4;
                bf1[3] = 0x3e;
                bf1[4] = (byte) 0x94;
                bf1[5] = 0;
                bf1[6] = 0;
                // 0-bytes length
                // bf1 = new byte[3];
                // bf1[0] = 2; // total UDH length
                // bf1[1] = 112; // UDH id
                // bf1[2] = 0; // UDH length
                byte[] bf2 = new byte[bf1.length + buf.length];
                System.arraycopy(bf1, 0, bf2, 0, bf1.length);
                System.arraycopy(buf, 0, bf2, bf1.length, buf.length);
                msgLst.add(bf2);
                esmClass = 0x40;
            } else {
                msgLst.add(buf);
            }
            segmCnt = 1;
        }
        esmClass |= messagingMode.getCode();
        this.doSubmitMessage(dcs, msgLst, msgRef, addSegmTlv, esmClass, validityType, segmCnt, destAddr, messageClassVal);
    } catch (Exception e) {
        this.addMessage("Failure to submit message", e.toString());
        return;
    }
}
Also used : DataCodingScheme(org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme) ArrayList(java.util.ArrayList) DataCodingSchemeImpl(org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) SplittingType(org.mobicents.smsc.tools.smppsimulator.SmppSimulatorParameters.SplittingType) SmppChannelException(com.cloudhopper.smpp.type.SmppChannelException) CharacterCodingException(java.nio.charset.CharacterCodingException)

Aggregations

SplittingType (org.mobicents.smsc.tools.smppsimulator.SmppSimulatorParameters.SplittingType)2 SmppChannelException (com.cloudhopper.smpp.type.SmppChannelException)1 CharacterCodingException (java.nio.charset.CharacterCodingException)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 EncodingType (org.mobicents.smsc.tools.smppsimulator.SmppSimulatorParameters.EncodingType)1 DataCodingScheme (org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme)1 DataCodingSchemeImpl (org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl)1