Search in sources :

Example 41 with FlowSegmentCookie

use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.

the class InMemoryPathComputerBaseTest method createTestTopologyForAffinityTesting.

// A - B - C - D    and A-B-C-D is used in flow affinity group
// |   |   |   |
// E   F   \   |
// |   |     \ |
// G - H - - - Z
void createTestTopologyForAffinityTesting() {
    final Switch nodeA = createSwitch("00:0A");
    final Switch nodeB = createSwitch("00:0B");
    final Switch nodeC = createSwitch("00:0C");
    final Switch nodeD = createSwitch("00:0D");
    final Switch nodeE = createSwitch("00:0E");
    final Switch nodeF = createSwitch("00:0F");
    final Switch nodeG = createSwitch("00:01");
    final Switch nodeH = createSwitch("00:02");
    final Switch nodeZ = createSwitch("00:03");
    IslStatus status = IslStatus.ACTIVE;
    int cost = 100;
    long bw = 1000;
    long latency = 1000;
    createBiIsl(nodeA, nodeB, status, status, cost, bw, 1, latency);
    createBiIsl(nodeB, nodeC, status, status, cost, bw, 2, latency);
    createBiIsl(nodeC, nodeD, status, status, cost, bw, 3, latency);
    createBiIsl(nodeA, nodeE, status, status, cost, bw, 4, latency);
    createBiIsl(nodeE, nodeG, status, status, cost, bw, 5, latency);
    createBiIsl(nodeG, nodeH, status, status, cost, bw, 6, latency);
    createBiIsl(nodeB, nodeF, status, status, cost, bw, 7, latency);
    createBiIsl(nodeF, nodeH, status, status, cost, bw, 8, latency);
    createBiIsl(nodeH, nodeZ, status, status, cost, bw, 9, latency);
    createBiIsl(nodeC, nodeZ, status, status, cost, bw, 10, latency);
    createBiIsl(nodeD, nodeZ, status, status, cost, bw, 11, latency);
    int bandwidth = 10;
    Flow flow = Flow.builder().flowId(TEST_FLOW_ID).srcSwitch(nodeA).srcPort(15).destSwitch(nodeD).destPort(16).affinityGroupId(TEST_FLOW_ID).bandwidth(bandwidth).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).build();
    FlowPath forwardPath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeA).destSwitch(nodeD).bandwidth(bandwidth).cookie(new FlowSegmentCookie(1L).toBuilder().direction(FlowPathDirection.FORWARD).build()).build();
    flow.setForwardPath(forwardPath);
    addPathSegment(forwardPath, nodeA, nodeB, 1, 1);
    addPathSegment(forwardPath, nodeB, nodeC, 2, 2);
    addPathSegment(forwardPath, nodeC, nodeD, 3, 3);
    FlowPath reversePath = FlowPath.builder().pathId(new PathId(UUID.randomUUID().toString())).srcSwitch(nodeD).destSwitch(nodeA).bandwidth(bandwidth).cookie(new FlowSegmentCookie(1L).toBuilder().direction(FlowPathDirection.REVERSE).build()).build();
    flow.setReversePath(reversePath);
    addPathSegment(reversePath, nodeD, nodeC, 3, 3);
    addPathSegment(reversePath, nodeC, nodeB, 2, 2);
    addPathSegment(reversePath, nodeB, nodeA, 1, 1);
    flowRepository.add(flow);
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) IslStatus(org.openkilda.model.IslStatus) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow)

Example 42 with FlowSegmentCookie

use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.

the class TestFlowBuilder method build.

/**
 * Build a UnidirectionalFlow with set properties.
 */
public Flow build() {
    Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(srcPort).srcVlan(srcVlan).destSwitch(destSwitch).destPort(destPort).destVlan(destVlan).bandwidth(bandwidth).ignoreBandwidth(ignoreBandwidth).encapsulationType(FlowEncapsulationType.TRANSIT_VLAN).pathComputationStrategy(pathComputationStrategy).maxLatency(maxLatency).maxLatencyTier2(maxLatencyTier2).build();
    FlowPath forwardPath = buildFlowPath(flow, srcSwitch, destSwitch, new FlowSegmentCookie(FlowPathDirection.FORWARD, unmaskedCookie));
    FlowPath reversePath = buildFlowPath(flow, destSwitch, srcSwitch, new FlowSegmentCookie(FlowPathDirection.REVERSE, unmaskedCookie));
    flow.setForwardPath(forwardPath);
    flow.setReversePath(reversePath);
    return flow;
}
Also used : FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow)

Example 43 with FlowSegmentCookie

use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.

the class FlowOperationsServiceTest method createFlow.

private Flow createFlow(String flowId, Switch srcSwitch, int srcPort, Switch dstSwitch, int dstPort, PathId forwardPartId, PathId reversePathId, Switch transitSwitch) {
    Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(dstSwitch).destPort(dstPort).status(FlowStatus.UP).build();
    FlowPath forwardPath = FlowPath.builder().pathId(forwardPartId).srcSwitch(srcSwitch).destSwitch(dstSwitch).cookie(new FlowSegmentCookie(FlowPathDirection.FORWARD, UNMASKED_COOKIE)).build();
    FlowPath reversePath = FlowPath.builder().pathId(reversePathId).srcSwitch(dstSwitch).destSwitch(srcSwitch).cookie(new FlowSegmentCookie(FlowPathDirection.REVERSE, UNMASKED_COOKIE)).build();
    if (!srcSwitch.getSwitchId().equals(dstSwitch.getSwitchId())) {
        if (transitSwitch == null) {
            // direct paths between src and dst switches
            forwardPath.setSegments(newArrayList(createPathSegment(forwardPath.getPathId(), srcSwitch, srcPort, dstSwitch, dstPort)));
            reversePath.setSegments(newArrayList(createPathSegment(reversePath.getPathId(), dstSwitch, dstPort, srcSwitch, srcPort)));
        } else {
            // src switch ==> transit switch ==> dst switch
            forwardPath.setSegments(newArrayList(createPathSegment(forwardPath.getPathId(), srcSwitch, srcPort, transitSwitch, srcPort), createPathSegment(forwardPath.getPathId(), transitSwitch, dstPort, dstSwitch, dstPort)));
            reversePath.setSegments(newArrayList(createPathSegment(reversePath.getPathId(), dstSwitch, dstPort, transitSwitch, dstPort), createPathSegment(reversePath.getPathId(), transitSwitch, srcPort, srcSwitch, srcPort)));
        }
    }
    flow.setForwardPath(forwardPath);
    flow.setReversePath(reversePath);
    flowRepository.add(flow);
    return flow;
}
Also used : FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow)

Example 44 with FlowSegmentCookie

use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.

the class LinkOperationsServiceTest method createFlow.

private Flow createFlow(String flowId, SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort) {
    Switch srcSwitch = createSwitchIfNotExist(srcSwitchId);
    Switch dstSwitch = createSwitchIfNotExist(dstSwitchId);
    Flow flow = Flow.builder().flowId(flowId).srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(dstSwitch).destPort(dstPort).status(FlowStatus.UP).build();
    FlowPath forwardPath = FlowPath.builder().pathId(new PathId("forward_path_id")).srcSwitch(srcSwitch).destSwitch(dstSwitch).cookie(new FlowSegmentCookie(1L)).build();
    FlowPath reversePath = FlowPath.builder().pathId(new PathId("reverse_path_id")).srcSwitch(dstSwitch).destSwitch(srcSwitch).cookie(new FlowSegmentCookie(1L)).build();
    forwardPath.setSegments(newArrayList(createPathSegment(forwardPath.getPathId(), srcSwitch, srcPort, dstSwitch, dstPort)));
    reversePath.setSegments(newArrayList(createPathSegment(reversePath.getPathId(), dstSwitch, dstPort, srcSwitch, srcPort)));
    flow.setForwardPath(forwardPath);
    flow.setReversePath(reversePath);
    flowRepository.add(flow);
    return flow;
}
Also used : PathId(org.openkilda.model.PathId) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) Switch(org.openkilda.model.Switch) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow)

Example 45 with FlowSegmentCookie

use of org.openkilda.model.cookie.FlowSegmentCookie in project open-kilda by telstra.

the class SingleTableServer42IngressRuleGenerator method buildServer42IngressCommand.

private FlowSpeakerData buildServer42IngressCommand(Switch sw, FlowEndpoint ingressEndpoint) {
    int priority = isVlanIdSet(ingressEndpoint.getOuterVlanId()) ? SERVER_42_INGRESS_SINGLE_VLAN_FLOW_PRIORITY : SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY;
    FlowSegmentCookie cookie = new FlowSegmentCookie(flowPath.getCookie().getValue()).toBuilder().type(CookieType.SERVER_42_FLOW_RTT_INGRESS).build();
    FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(ingressEndpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.INPUT).priority(priority).match(buildMatch(ingressEndpoint)).instructions(buildIngressInstructions(sw, ingressEndpoint.getOuterVlanId()));
    if (sw.getFeatures().contains(SwitchFeature.RESET_COUNTS_FLAG)) {
        builder.flags(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS));
    }
    return builder.build();
}
Also used : FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) FlowEndpoint(org.openkilda.model.FlowEndpoint)

Aggregations

FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)59 Flow (org.openkilda.model.Flow)33 FlowPath (org.openkilda.model.FlowPath)31 PathId (org.openkilda.model.PathId)23 MeterId (org.openkilda.model.MeterId)19 Test (org.junit.Test)15 PathSegment (org.openkilda.model.PathSegment)15 Switch (org.openkilda.model.Switch)15 ArrayList (java.util.ArrayList)8 SwitchId (org.openkilda.model.SwitchId)8 FlowEntry (org.openkilda.messaging.info.rule.FlowEntry)6 UUID (java.util.UUID)5 FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)5 IngressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory)5 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)5 DeleteRulesCriteria (org.openkilda.messaging.command.switches.DeleteRulesCriteria)4 MirrorConfig (org.openkilda.model.MirrorConfig)4 YFlow (org.openkilda.model.YFlow)4 Before (org.junit.Before)3 EgressFlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory)3