与SCTP建立M3UA关联

时间:2015-04-14 08:33:07

标签: c linux fedora sctp

我想使用Lksctp linux开发一个M3UA关联我也认为可以使用openSS7 M3UA,但我不知道该怎么做。还有什么想法??? 谢谢你的帮助。

2 个答案:

答案 0 :(得分:1)

我认为最好使用Mobicents jSS7

答案 1 :(得分:1)

您可以将lk-sctp与Netty框架结合使用,而不是jdk-7(及更高版本)来实现M3UA(RFC 4666)。 Netty-4.0.25-FINAL是SCTP支持的稳定版本。

所以组合是:

  • SCTP堆栈:lk-sctp-1.0.16(通过Red Hat Enterprise Linux Server 6.5版(圣地亚哥))
  • JDK-7或以上
  • 的Netty-4.0.25-FINAL

你的应用程序就在它之上。 SCTPClientHandler的示例代码可以是:

    public class SctpClientHandler extends ChannelDuplexHandler {
@Override
    public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
            throws Exception {
        SctpChannel sctpChannel = (SctpChannel) ctx.channel();
        if (evt instanceof AssociationChangeNotification) {
            AssociationChangeNotification associationChangeNotification = (AssociationChangeNotification) evt;
            switch (associationChangeNotification.event()) {
            case CANT_START:
            //Do something
            break;
            case COMM_LOST:
           //
            case COMM_UP:


  } else if (evt instanceof PeerAddressChangeNotification) {
                PeerAddressChangeNotification peerAddressChangeNotification = (PeerAddressChangeNotification) evt;
            int associationId = sctpChannel.association().associationID();
            switch (peerAddressChangeNotification.event()) {
            case ADDR_ADDED:
}
} else if (evt instanceof SendFailedNotification) {
}

@Override
    public void channelRead(ChannelHandlerContext ctx, Object msg)
            throws Exception {
        SctpMessage sctpMessage = (SctpMessage) msg;
        // Check if this is a M3UA message
        if (sctpMessage.protocolIdentifier() == 3) {
            // Send upstream - to M3UA
            ctx.fireChannelRead(sctpMessage);
        }

    }

public void send(ByteBuf buffer, int streamId) {
        SctpMessage message = new SctpMessage(3, streamId, buffer);
        ctx.writeAndFlush(message);
    }

public void send(ByteBuf buffer, int streamId, SocketAddress remoteAddress) {
        MessageInfo msgInfo = MessageInfo.createOutgoing(remoteAddress,
                streamId);
        SctpMessage message = new SctpMessage(msgInfo, buffer);
        ctx.writeAndFlush(message);
    }

public void send(ByteBuf buffer, int streamId, boolean unOrderedFlag) {
        SctpMessage message = new SctpMessage(3, streamId, buffer);
        message.messageInfo().unordered(unOrderedFlag);
        ctx.writeAndFlush(message);

    }

public void send(ByteBuf buffer, int streamId, SocketAddress remoteAddress,
            boolean unOrderedFlag) {
        MessageInfo msgInfo = MessageInfo.createOutgoing(remoteAddress,
                streamId);
        msgInfo.unordered(unOrderedFlag);
        SctpMessage message = new SctpMessage(msgInfo, buffer);
        ctx.writeAndFlush(message);
    }
    }

SCTPServerHandler也可以像上面那样创建。

初始化Bootstrap:

bootstrap.group(worker)
            .channel(NioSctpChannel.class)
             .option(SctpChannelOption.SCTP_NODELAY,true)
              .handler(new ChannelInitializer<SctpChannel>() {
                @Override
                public void initChannel(SctpChannel ch) throws Exception {
                    ch.pipeline().addLast(
                            new SctpClientHandler());
                    ch.pipeline().addLast(new M3UAAspHandler());
                }
            });

这种组合也可以扩展很多。快乐的编码。