Search in sources :

Example 11 with FlowStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactoryTest method testFlowBodySerialize.

@Test
public void testFlowBodySerialize() throws Exception {
    MultipartReplyMessageBuilder builder;
    builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(1));
    MultipartReplyFlowCaseBuilder flowCase = new MultipartReplyFlowCaseBuilder();
    MultipartReplyFlowBuilder flow = new MultipartReplyFlowBuilder();
    flow.setFlowStats(createFlowStats());
    flowCase.setMultipartReplyFlow(flow.build());
    builder.setMultipartReplyBody(flowCase.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 108);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPFLOW.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    FlowStats flowStats = flow.getFlowStats().get(0);
    Assert.assertEquals("Wrong length", 96, serializedBuffer.readShort());
    Assert.assertEquals("Wrong Table ID", flowStats.getTableId().intValue(), serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(1);
    Assert.assertEquals("Wrong wildcards", 3678463, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong inPort", 58, serializedBuffer.readUnsignedShort());
    byte[] dlSrc = new byte[6];
    serializedBuffer.readBytes(dlSrc);
    Assert.assertEquals("Wrong dlSrc", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
    byte[] dlDst = new byte[6];
    serializedBuffer.readBytes(dlDst);
    Assert.assertEquals("Wrong dlDst", "FF:FF:FF:FF:FF:FF", ByteBufUtils.macAddressToString(dlDst));
    Assert.assertEquals("Wrong dlVlan", 18, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong dlVlanPcp", 5, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(1);
    Assert.assertEquals("Wrong dlType", 42, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong nwTos", 4, serializedBuffer.readUnsignedByte());
    Assert.assertEquals("Wrong nwProto", 7, serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(2);
    Assert.assertEquals("Wrong nwSrc", 134744072, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong nwDst", 269488144, serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong tpSrc", 6653, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong tpDst", 6633, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong duration sec", flowStats.getDurationSec().intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong duration nsec", flowStats.getDurationNsec().intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong priority", flowStats.getPriority().intValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong idle timeout", flowStats.getIdleTimeout().intValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong hard timeout", flowStats.getHardTimeout().intValue(), serializedBuffer.readShort());
    serializedBuffer.skipBytes(6);
    Assert.assertEquals("Wrong cookie", flowStats.getCookie().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong Packet count", flowStats.getPacketCount().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong Byte count", flowStats.getByteCount().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong action type", 0, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong port", 42, serializedBuffer.readUnsignedShort());
    Assert.assertEquals("Wrong maxlength", 50, serializedBuffer.readUnsignedShort());
}
Also used : FlowStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MultipartReplyFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder) MultipartReplyFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 12 with FlowStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats in project netvirt by opendaylight.

the class AclLiveStatisticsHelper method getAclDropStats.

/**
 * Gets the acl drop stats.
 *
 * @param direction the direction
 * @param aclStatsBuilder the acl stats builder
 * @param flowStatsOutput the flow stats output
 */
private static void getAclDropStats(Direction direction, AclPortStatsBuilder aclStatsBuilder, GetFlowStatisticsOutput flowStatsOutput) {
    List<FlowAndStatisticsMapList> flowAndStatisticsMapList = flowStatsOutput.getFlowAndStatisticsMapList();
    if (flowAndStatisticsMapList == null || flowAndStatisticsMapList.isEmpty()) {
        String errMsg = "Unable to retrieve drop counts as interface is not configured for statistics collection.";
        aclStatsBuilder.setError(new ErrorBuilder().setErrorMessage(errMsg).build());
        return;
    }
    BytesBuilder portEgressBytesBuilder = new BytesBuilder();
    BytesBuilder portIngressBytesBuilder = new BytesBuilder();
    PacketsBuilder portEgressPacketsBuilder = new PacketsBuilder();
    PacketsBuilder portIngressPacketsBuilder = new PacketsBuilder();
    for (FlowAndStatisticsMapList flowStats : flowAndStatisticsMapList) {
        BigInteger portEgressBytesBuilderDropCount = BigInteger.valueOf(0);
        BigInteger portEgressPacketsBuilderDropCount = BigInteger.valueOf(0);
        BigInteger portIngressBytesBuilderDropCount = BigInteger.valueOf(0);
        BigInteger portIngressPacketsBuilderDropCount = BigInteger.valueOf(0);
        switch(flowStats.getTableId()) {
            case NwConstants.INGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE:
                if (flowStats.getPriority().equals(AclConstants.CT_STATE_TRACKED_INVALID_PRIORITY)) {
                    portEgressBytesBuilder.setInvalidDropCount(flowStats.getByteCount().getValue());
                    portEgressPacketsBuilder.setInvalidDropCount(flowStats.getPacketCount().getValue());
                } else if (flowStats.getPriority().equals(AclConstants.ACL_PORT_SPECIFIC_DROP_PRIORITY)) {
                    if (portEgressBytesBuilder.getDropCount() != null) {
                        portEgressBytesBuilderDropCount = portEgressBytesBuilder.getDropCount().add(flowStats.getByteCount().getValue());
                        portEgressPacketsBuilderDropCount = portEgressPacketsBuilder.getDropCount().add(flowStats.getPacketCount().getValue());
                    } else {
                        portEgressBytesBuilderDropCount = flowStats.getByteCount().getValue();
                        portEgressPacketsBuilderDropCount = flowStats.getPacketCount().getValue();
                    }
                } else if (flowStats.getPriority().equals(AclConstants.ACE_LAST_REMOTE_ACL_PRIORITY)) {
                    if (portEgressBytesBuilder.getDropCount() != null) {
                        portEgressBytesBuilderDropCount = portEgressBytesBuilder.getDropCount().add(flowStats.getByteCount().getValue());
                        portEgressPacketsBuilderDropCount = portEgressPacketsBuilder.getDropCount().add(flowStats.getPacketCount().getValue());
                    } else {
                        portEgressBytesBuilderDropCount = flowStats.getByteCount().getValue();
                        portEgressPacketsBuilderDropCount = flowStats.getPacketCount().getValue();
                    }
                }
                // TODO: Update stats for other drops
                break;
            case NwConstants.EGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE:
                if (flowStats.getPriority().equals(AclConstants.CT_STATE_TRACKED_INVALID_PRIORITY)) {
                    portIngressBytesBuilder.setInvalidDropCount(flowStats.getByteCount().getValue());
                    portIngressPacketsBuilder.setInvalidDropCount(flowStats.getPacketCount().getValue());
                } else if (flowStats.getPriority().equals(AclConstants.ACL_PORT_SPECIFIC_DROP_PRIORITY)) {
                    if (portIngressBytesBuilder.getDropCount() != null) {
                        portIngressBytesBuilderDropCount = portIngressBytesBuilder.getDropCount().add(flowStats.getByteCount().getValue());
                        portIngressPacketsBuilderDropCount = portIngressPacketsBuilder.getDropCount().add(flowStats.getPacketCount().getValue());
                    } else {
                        portIngressBytesBuilderDropCount = flowStats.getByteCount().getValue();
                        portIngressPacketsBuilderDropCount = flowStats.getPacketCount().getValue();
                    }
                } else if (flowStats.getPriority().equals(AclConstants.ACE_LAST_REMOTE_ACL_PRIORITY)) {
                    if (portIngressBytesBuilder.getDropCount() != null) {
                        portIngressBytesBuilderDropCount = portIngressBytesBuilder.getDropCount().add(flowStats.getByteCount().getValue());
                        portIngressPacketsBuilderDropCount = portIngressPacketsBuilder.getDropCount().add(flowStats.getPacketCount().getValue());
                    } else {
                        portIngressBytesBuilderDropCount = flowStats.getByteCount().getValue();
                        portIngressPacketsBuilderDropCount = flowStats.getPacketCount().getValue();
                    }
                }
                // TODO: Update stats for other drops
                break;
            default:
                LOG.warn("Invalid table ID filtered for Acl flow stats: {}", flowStats);
                break;
        }
        portEgressBytesBuilder.setDropCount(portEgressBytesBuilderDropCount);
        portEgressPacketsBuilder.setDropCount(portEgressPacketsBuilderDropCount);
        portIngressBytesBuilder.setDropCount(portIngressBytesBuilderDropCount);
        portIngressPacketsBuilder.setDropCount(portIngressPacketsBuilderDropCount);
    }
    List<AclDropStats> lstAclDropStats = new ArrayList<>();
    if (direction == Direction.Egress || direction == Direction.Both) {
        AclDropStats aclEgressDropStats = new AclDropStatsBuilder().setDirection(Direction.Egress).setBytes(portEgressBytesBuilder.build()).setPackets(portEgressPacketsBuilder.build()).build();
        lstAclDropStats.add(aclEgressDropStats);
    }
    if (direction == Direction.Ingress || direction == Direction.Both) {
        AclDropStats aclIngressDropStats = new AclDropStatsBuilder().setDirection(Direction.Ingress).setBytes(portIngressBytesBuilder.build()).setPackets(portIngressPacketsBuilder.build()).build();
        lstAclDropStats.add(aclIngressDropStats);
    }
    aclStatsBuilder.setAclDropStats(lstAclDropStats);
}
Also used : AclDropStats(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.AclDropStats) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) PacketsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.acl.drop.stats.PacketsBuilder) AclDropStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.AclDropStatsBuilder) ErrorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.ErrorBuilder) BytesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.acl.stats.output.acl.port.stats.acl.drop.stats.BytesBuilder)

Example 13 with FlowStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method setFlow.

private MultipartReplyFlowCase setFlow(final ByteBuf input) {
    MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder();
    MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();
    List<FlowStats> flowStatsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder();
        int flowRecordLength = input.readUnsignedShort();
        ByteBuf subInput = input.readSlice(flowRecordLength - EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
        flowStatsBuilder.setTableId(subInput.readUnsignedByte());
        subInput.skipBytes(PADDING_IN_FLOW_STATS_HEADER_01);
        flowStatsBuilder.setDurationSec(subInput.readUnsignedInt());
        flowStatsBuilder.setDurationNsec(subInput.readUnsignedInt());
        flowStatsBuilder.setPriority(subInput.readUnsignedShort());
        flowStatsBuilder.setIdleTimeout(subInput.readUnsignedShort());
        flowStatsBuilder.setHardTimeout(subInput.readUnsignedShort());
        flowStatsBuilder.setFlags(createFlowModFlagsFromBitmap(subInput.readUnsignedShort()));
        subInput.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
        byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        subInput.readBytes(cookie);
        flowStatsBuilder.setCookie(new BigInteger(1, cookie));
        byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        subInput.readBytes(packetCount);
        flowStatsBuilder.setPacketCount(new BigInteger(1, packetCount));
        byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        subInput.readBytes(byteCount);
        flowStatsBuilder.setByteCount(new BigInteger(1, byteCount));
        OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
        flowStatsBuilder.setMatch(matchDeserializer.deserialize(subInput));
        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
        List<Instruction> instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, subInput.readableBytes(), subInput, keyMaker, registry);
        flowStatsBuilder.setInstruction(instructions);
        flowStatsList.add(flowStatsBuilder.build());
    }
    flowBuilder.setFlowStats(flowStatsList);
    caseBuilder.setMultipartReplyFlow(flowBuilder.build());
    return caseBuilder.build();
}
Also used : ArrayList(java.util.ArrayList) MultipartReplyFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match) FlowStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats) FlowStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder) MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) CodeKeyMaker(org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker) BigInteger(java.math.BigInteger) MultipartReplyFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder)

Example 14 with FlowStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactory method setFlow.

private MultipartReplyFlowCase setFlow(ByteBuf input) {
    MultipartReplyFlowCaseBuilder caseBuilder = new MultipartReplyFlowCaseBuilder();
    MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();
    List<FlowStats> flowStatsList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder();
        final int length = input.readUnsignedShort();
        flowStatsBuilder.setTableId(input.readUnsignedByte());
        input.skipBytes(PADDING_IN_FLOW_STATS_HEADER);
        OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
        flowStatsBuilder.setMatchV10(matchDeserializer.deserialize(input));
        flowStatsBuilder.setDurationSec(input.readUnsignedInt());
        flowStatsBuilder.setDurationNsec(input.readUnsignedInt());
        flowStatsBuilder.setPriority(input.readUnsignedShort());
        flowStatsBuilder.setIdleTimeout(input.readUnsignedShort());
        flowStatsBuilder.setHardTimeout(input.readUnsignedShort());
        input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
        byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(cookie);
        flowStatsBuilder.setCookie(new BigInteger(1, cookie));
        byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(packetCount);
        flowStatsBuilder.setPacketCount(new BigInteger(1, packetCount));
        byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        input.readBytes(byteCount);
        flowStatsBuilder.setByteCount(new BigInteger(1, byteCount));
        CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID);
        List<Action> actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, length - LENGTH_OF_FLOW_STATS, input, keyMaker, registry);
        flowStatsBuilder.setAction(actions);
        flowStatsList.add(flowStatsBuilder.build());
    }
    flowBuilder.setFlowStats(flowStatsList);
    caseBuilder.setMultipartReplyFlow(flowBuilder.build());
    return caseBuilder.build();
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) ArrayList(java.util.ArrayList) MultipartReplyFlowCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder) FlowStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats) FlowStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder) MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) CodeKeyMaker(org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker) BigInteger(java.math.BigInteger) MultipartReplyFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10)

Example 15 with FlowStats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats in project openflowplugin by opendaylight.

the class MultipartReplyFlowTest method testMultipartReplyFlowBody.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyFlowBody() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 01 00 01 00 00 00 00 " + // first flow stat
    "00 48 08 00 " + // length, tableId, padding
    "00 00 00 09 " + // durationSec
    "00 00 00 07 " + // durationNsec
    "00 0C 00 0E 00 0F 00 1F " + // priority, idleTimeout, hardTimeout, flags
    "00 00 00 00 " + // pad_02
    "FF 01 01 01 01 01 01 01 " + // cookie
    "EF 01 01 01 01 01 01 01 " + // packetCount
    "7F 01 01 01 01 01 01 01 " + // byteCount
    "00 01 00 04 00 00 00 00 " + // empty match
    "00 01 00 08 06 00 00 00 " + // 
    "00 01 00 08 06 00 00 00 " + // second flow stat
    "00 48 08 00 " + // length, tableId, padding
    "00 00 00 09 " + // durationSec
    "00 00 00 07 " + // durationNsec
    "00 0C 00 0E 00 0F 00 00 " + // priority, idleTimeout, hardTimeout, flags
    "00 00 00 00 " + // pad_02
    "FF 01 01 01 01 01 01 01 " + // cookie
    "EF 01 01 01 01 01 01 01 " + // packetCount
    "7F 01 01 01 01 01 01 01 " + // byteCount
    "00 01 00 04 00 00 00 00 " + // empty match
    "00 01 00 08 06 00 00 00 " + // 
    "00 01 00 08 06 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyFlow message = messageCase.getMultipartReplyFlow();
    Assert.assertEquals("Wrong flow stats size", 2, message.getFlowStats().size());
    FlowStats flowStats1 = message.getFlowStats().get(0);
    Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue());
    Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue());
    Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue());
    Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue());
    Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());
    Assert.assertEquals("Wrong flags", new FlowModFlags(true, true, true, true, true), flowStats1.getFlags());
    Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getCookie());
    Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[] { (byte) 0xEF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getPacketCount());
    Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[] { (byte) 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getByteCount());
    Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());
    flowStats1 = message.getFlowStats().get(1);
    Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue());
    Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue());
    Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue());
    Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue());
    Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());
    Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowStats1.getFlags());
    Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getCookie());
    Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[] { (byte) 0xEF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getPacketCount());
    Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[] { (byte) 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getByteCount());
    Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());
}
Also used : FlowStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags) MultipartReplyFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow) BigInteger(java.math.BigInteger) MultipartReplyFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

FlowStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats)11 ArrayList (java.util.ArrayList)6 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)6 ByteBuf (io.netty.buffer.ByteBuf)5 Test (org.junit.Test)5 MultipartReplyFlowCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase)5 MultipartReplyFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow)5 FlowStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStatsBuilder)5 BigInteger (java.math.BigInteger)4 FlowRegistryKey (org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey)3 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)3 MultipartReplyFlowCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCaseBuilder)3 MultipartReplyFlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlowBuilder)3 MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)2 CodeKeyMaker (org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker)2 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)2 FlowId (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId)2 FlowsStatisticsUpdate (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowsStatisticsUpdate)2 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)2 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)2