我通过maven使用此版本的jSS7
<groupId>org.mobicents.protocols.ss7</groupId>
<artifactId>restcomm-ss7</artifactId>
<version>3.0.1335</version>
我可以设置到其上有E.1行的Cisco ITP的SCTP链接,但是当尝试发送SRIforSM gsm地图消息时,我在wireshark中看不到相应的MAP pdu。我只看到ASPUP消息。我将jSS7作为独立使用。
以下是我为代码数据清理的代码
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);
}
}
答案 0 :(得分:0)
由于SS7堆栈需要仔细配置,很难说出所有阻止形成消息流的原因。
我可以说:您尚未配置任何SCCP规则/主要地址。还需要所有SS7堆栈设置适合对等堆栈设置,我无法检查它。
要了解会发生什么,我建议您检查来自SS7堆栈的日志消息,它可以告诉您根本原因。
此外,您可以使用此示例的原型(在您看到消息之后,您可以根据所需的消息流调整示例): https://github.com/RestComm/jss7/tree/master/map/load/src/main/java/org/mobicents/protocols/ss7/map/load