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

最佳答案

可以将lk-sctp与jdk-7(及更高版本)上的Netty框架结合使用来实现M3UA(RFC 4666)。
Netty-4.0.25-FINAL是SCTP支持的稳定版本。
所以组合是:
SCTP堆栈:lk-SCTP-1.0.16(在Red Hat Enterprise Linux服务器6.5版(圣地亚哥)上)
JDK-7及以上
净值-4.0.25-最终
还有你的申请表。
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.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());
                }
            });

这种组合也有很大的规模。快乐的编码。

10-08 13:12