jss7 Doesn't send out GSM MAP message

1.9k views Asked by At

I am using this version of jSS7 via maven

<groupId>org.mobicents.protocols.ss7</groupId>
<artifactId>restcomm-ss7</artifactId>
<version>3.0.1335</version>

I can setup an SCTP link to a Cisco ITP that has E.1 lines on it however when trying to send a SRIforSM gsm map message I see no corresponding MAP pdu in wireshark. I cam only see the ASPUP messages. I'm using jSS7 as standalone.

The following is my code sanitized for conditential data

MAPClient.java

import org.mobicents.protocols.ss7.indicator.*; import org.mobicents.protocols.ss7.indicator.NumberingPlan; import org.mobicents.protocols.ss7.map.api.*; import org.mobicents.protocols.ss7.map.api.dialog.*; import org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage; import org.mobicents.protocols.ss7.map.api.primitives.*; import org.mobicents.protocols.ss7.map.api.service.lsm.*; import org.mobicents.protocols.ss7.map.api.service.sms.*; import org.mobicents.protocols.ss7.sccp.impl.parameter.DefaultEncodingScheme; import org.mobicents.protocols.ss7.sccp.impl.parameter.GlobalTitle0100Impl; import org.mobicents.protocols.ss7.sccp.impl.parameter.SccpAddressImpl; import org.mobicents.protocols.ss7.sccp.parameter.EncodingScheme; import org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle; import org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle0100; import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress; import org.mobicents.protocols.ss7.tcap.asn.ApplicationContextName; import org.mobicents.protocols.ss7.tcap.asn.comp.Problem;


public class MAPClient implements MAPDialogListener, MAPServiceLsmListener, MAPServiceSmsListener 
{
    private MAPStack mapStack;

    public MAPProvider getMapProvider() {
        return mapProvider;
    }

    private MAPProvider mapProvider;
    private MAPParameterFactory mapParameterFactory;
    private MAPApplicationContext sriMAPApplicationContext;
    private SccpAddress serviceCenterSCCPAddress;
    private AddressString serviceCenterAddress;
    private SccpAddress hlrSCCPAddress;
    private String SC_ADDRESS;
    private String HLR_GT;


    private SccpAddress getServiceCenterSccpAddress() {
        EncodingScheme encodingScheme = new DefaultEncodingScheme();
        if (this.serviceCenterSCCPAddress == null) {
            GlobalTitle0100 gt = new GlobalTitle0100Impl(SC_ADDRESS, 0, encodingScheme,
                    NumberingPlan.ISDN_TELEPHONY, NatureOfAddress.INTERNATIONAL);
            this.serviceCenterSCCPAddress = new SccpAddressImpl(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, gt, 0, 8);
        }
        return this.serviceCenterSCCPAddress;
    }

    private SccpAddress getHLRSccpAddress() {
        EncodingScheme encodingScheme = new DefaultEncodingScheme();
        if (this.hlrSCCPAddress == null) {
            GlobalTitle0100 gt = new GlobalTitle0100Impl(HLR_GT, 0, encodingScheme,
                    NumberingPlan.ISDN_TELEPHONY, NatureOfAddress.INTERNATIONAL);
            return this.hlrSCCPAddress = new SccpAddressImpl(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, gt, 0, 6);
        }
        return this.hlrSCCPAddress;
    }

    private MAPApplicationContext getSRIMAPApplicationContext() {
        if (this.sriMAPApplicationContext == null) {
            this.sriMAPApplicationContext = MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgGatewayContext,
                    MAPApplicationContextVersion.version3);
        }
        return this.sriMAPApplicationContext;
    }

    private ISDNAddressString getCalledPartyISDNAddressString(String destinationAddress) {
        return this.mapParameterFactory.createISDNAddressString(AddressNature.international_number,
                org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN, destinationAddress);
    }

    private SccpAddress msisdnToSccpAddress(String msisdn){
        EncodingScheme encodingScheme = new DefaultEncodingScheme();
        GlobalTitle globalTitle = new GlobalTitle0100Impl(msisdn, 0, encodingScheme,
                NumberingPlan.ISDN_TELEPHONY, NatureOfAddress.INTERNATIONAL);
        return new SccpAddressImpl(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, globalTitle, 0, 6);
    }

    private AddressString getServiceCenterAddressString() {
        if (this.serviceCenterAddress == null) {
            this.serviceCenterAddress = this.mapParameterFactory.createAddressString(AddressNature.international_number,
                    org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN, SC_ADDRESS);
        }
        return this.serviceCenterAddress;
    }

    private MAPDialogSms setupRoutingInfoForSMRequestIndication(String destinationAddress) throws MAPException {
        SccpAddress destinationReference = this.msisdnToSccpAddress(destinationAddress);

        MAPDialogSms mapDialogSms = this.mapProvider.getMAPServiceSms().createNewDialog(this.getSRIMAPApplicationContext(), this.getServiceCenterSccpAddress(),
                null, destinationReference, null);

        mapDialogSms.addSendRoutingInfoForSMRequest(this.getCalledPartyISDNAddressString(destinationAddress), true,
                this.getServiceCenterAddressString(), null, false, null, null, null);

        return mapDialogSms;
    }

    public void sendSRI(String msisdn) {
        // Send out SRI-SM
        MAPDialogSms mapDialogSms = null;
        try {
            mapDialogSms = this.setupRoutingInfoForSMRequestIndication(msisdn);
            mapDialogSms.send();
        } catch (MAPException e) {
            System.out.println("Error while trying to send RoutingInfoForSMRequestIndication");
            mapDialogSms.release();
        }
    }

    public void onMAPMessage(MAPMessage mapMessage) {
        System.out.println("Got MAP!");
    }

    public MAPClient(MAPStack mapStack, String serviceCentre, String hlrGlobalTitle){
        this.mapStack = mapStack;
        SC_ADDRESS = serviceCentre;
        HLR_GT = hlrGlobalTitle;
        mapProvider = this.mapStack.getMAPProvider();
        mapParameterFactory = mapProvider.getMAPParameterFactory();
        mapProvider.addMAPDialogListener(this);
        mapProvider.getMAPServiceSms().addMAPServiceListener(this);
        mapProvider.getMAPServiceSms().acivate();
        try {
            this.mapStack.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    } 
}

Main.java

import org.mobicents.protocols.api.IpChannelType;
import org.mobicents.protocols.api.Management;
import org.mobicents.protocols.sctp.ManagementImpl;
import org.mobicents.protocols.ss7.m3ua.*;
import org.mobicents.protocols.ss7.m3ua.impl.M3UAManagementImpl;
import org.mobicents.protocols.ss7.m3ua.parameter.RoutingContext;
import org.mobicents.protocols.ss7.m3ua.parameter.TrafficModeType;
import org.mobicents.protocols.ss7.map.MAPStackImpl;
import org.mobicents.protocols.ss7.map.api.MAPStack;
import org.mobicents.protocols.ss7.mtp.Mtp3UserPart;
import org.mobicents.protocols.ss7.sccp.SccpStack;
import org.mobicents.protocols.ss7.sccp.impl.SccpStackImpl;


import java.util.HashMap;
import java.util.Map;


public class Main {
    public static String local_ip = "XXXXXXXXX";
    public static int local_port = 2020;
    public static String signaling_gateway = "XXXXXXXXXX";
    public static int signaling_port = 2000;
    public static String gt1 = "XXXXXXXXXXX";
    public static String gt2 = "XXXXXXXXXXX";
    public static String target_gt = "XXXXXXXXXXX";
    public static int server_spc = XXXXXXX;
    public static int local_spc = 160;
    public static int ss7_mask_one = 16383;

    public static  void main(String[] args) throws Exception{
        Management sctpManagement;
        sctpManagement = new ManagementImpl("Client");
        sctpManagement.setSingleThread(true);
        sctpManagement.setPersistDir("/root/");
        sctpManagement.start();
        sctpManagement.addAssociation(local_ip, local_port, signaling_gateway, signaling_port, "ss7cli",
                IpChannelType.getInstance("SCTP"), null);
        M3UAManagementImpl m3uaManagement = null;
        m3uaManagement = new M3UAManagementImpl("Client", null);
        m3uaManagement.setTransportManagement(sctpManagement);
        m3uaManagement.start();

        //setup ASP
        org.mobicents.protocols.ss7.m3ua.impl.parameter.ParameterFactoryImpl parameterFactory =
                new org.mobicents.protocols.ss7.m3ua.impl.parameter.ParameterFactoryImpl();
        RoutingContext routingContext = parameterFactory.createRoutingContext(new long[] {100l});
        TrafficModeType trafficModeType = parameterFactory.createTrafficModeType(TrafficModeType.Loadshare);
        m3uaManagement.createAs("AS1", Functionality.AS, ExchangeType.SE, IPSPType.CLIENT, routingContext, trafficModeType, 0, null);
        m3uaManagement.createAspFactory("ASP1", "ss7cli");
        m3uaManagement.assignAspToAs("AS1", "ASP1");
        m3uaManagement.addRoute(server_spc, -1, -1, "AS1");
        m3uaManagement.startAsp("ASP1");

        //setup SCCP
        SccpStack sccpStack;
        sccpStack = new SccpStackImpl("MapLoadClientSccpStack");
        Map<Integer, Mtp3UserPart> mtp3map = new HashMap<Integer, Mtp3UserPart>();
        mtp3map.put(1, m3uaManagement);
        sccpStack.setMtp3UserParts(mtp3map);
        sccpStack.start();
        //initialize SCCP with remote and local SPCs
        sccpStack.getSccpResource().addRemoteSpc(1, server_spc, 0, 0);
        sccpStack.getSccpResource().addRemoteSsn(1, server_spc, 5, 0, false);
        sccpStack.getRouter().addMtp3ServiceAccessPoint(1, 1, local_spc, 3, 1);
        sccpStack.getRouter().addMtp3Destination(1, 1, server_spc, server_spc, 0, 255, 255);

        MAPStack mapStack = new MAPStackImpl("MAPClient", sccpStack.getSccpProvider(), 5);
        MAPClient mapClient = new MAPClient(mapStack, gt1, gt2);

        //send test map request
        mapClient.sendSRI(target_gt);
    }
}
1

There are 1 answers

0
Sergey Vetyutnev On

It is difficult to say exaclty of all reasons that prevent form your messageflow because of SS7 stack demands carefull configuring.

What I can say: you have not configured any SCCP rules / primary addresses. Also it is needed that all SS7 stacks setting fit to the peer stack settings, I can not check it.

To see what happens I can recommend you to check log messages from SS7 stack, it can advice you the root reason.

Also you can take for a prototype this example (and after you can see the messagefow you can adapt the example for your desired messageflow) : https://github.com/RestComm/jss7/tree/master/map/load/src/main/java/org/mobicents/protocols/ss7/map/load