Search in sources :

Example 1 with Environment

use of org.batfish.datamodel.pojo.Environment in project batfish by batfish.

the class Batfish method getHistory.

@Override
public FlowHistory getHistory() {
    FlowHistory flowHistory = new FlowHistory();
    if (_settings.getDiffQuestion()) {
        String flowTag = getDifferentialFlowTag();
        // String baseEnvTag = _baseTestrigSettings.getEnvName() + ":"
        // + _baseTestrigSettings.getEnvironmentSettings().getEnvName();
        String baseEnvTag = getFlowTag(_baseTestrigSettings);
        // String deltaName = _deltaTestrigSettings.getEnvName() + ":"
        // + _deltaTestrigSettings.getEnvironmentSettings().getEnvName();
        String deltaEnvTag = getFlowTag(_deltaTestrigSettings);
        pushBaseEnvironment();
        Environment baseEnv = getEnvironment();
        populateFlowHistory(flowHistory, baseEnvTag, baseEnv, flowTag);
        popEnvironment();
        pushDeltaEnvironment();
        Environment deltaEnv = getEnvironment();
        populateFlowHistory(flowHistory, deltaEnvTag, deltaEnv, flowTag);
        popEnvironment();
    } else {
        String flowTag = getFlowTag();
        // String name = testrigSettings.getEnvName() + ":"
        // + testrigSettings.getEnvironmentSettings().getEnvName();
        String envTag = flowTag;
        Environment env = getEnvironment();
        populateFlowHistory(flowHistory, envTag, env, flowTag);
    }
    _logger.debug(flowHistory.toString());
    return flowHistory;
}
Also used : FlowHistory(org.batfish.datamodel.FlowHistory) Environment(org.batfish.datamodel.pojo.Environment)

Example 2 with Environment

use of org.batfish.datamodel.pojo.Environment in project batfish by batfish.

the class CounterExample method buildFlowHistoryDiff.

/*
   * Create a trace-based counterexample demonstrating
   * the difference between two networks on a single packet.
   */
FlowHistory buildFlowHistoryDiff(String testRigName, Collection<String> sourceRouters, Encoder enc, Encoder enc2, Map<String, BoolExpr> reach, Map<String, BoolExpr> reach2) {
    FlowHistory fh = new FlowHistory();
    assert (reach2 != null);
    for (String source : sourceRouters) {
        BoolExpr sourceVar1 = reach.get(source);
        BoolExpr sourceVar2 = reach2.get(source);
        String val1 = evaluate(sourceVar1);
        String val2 = evaluate(sourceVar2);
        if (!Objects.equals(val1, val2)) {
            Tuple<Flow, FlowTrace> diff = buildFlowTrace(enc, source);
            Tuple<Flow, FlowTrace> base = buildFlowTrace(enc2, source);
            SortedSet<Edge> failedLinksDiff = buildFailedLinks(enc);
            SortedSet<Edge> failedLinksBase = buildFailedLinks(enc2);
            SortedSet<BgpAdvertisement> envRoutesDiff = buildEnvRoutingTable(enc);
            SortedSet<BgpAdvertisement> envRoutesBase = buildEnvRoutingTable(enc2);
            Environment baseEnv = new Environment("BASE", testRigName, failedLinksBase, null, null, null, null, envRoutesBase);
            Environment failedEnv = new Environment("DELTA", testRigName, failedLinksDiff, null, null, null, null, envRoutesDiff);
            fh.addFlowTrace(base.getFirst(), "BASE", baseEnv, base.getSecond());
            fh.addFlowTrace(diff.getFirst(), "DELTA", failedEnv, diff.getSecond());
        }
    }
    return fh;
}
Also used : BoolExpr(com.microsoft.z3.BoolExpr) BgpAdvertisement(org.batfish.datamodel.BgpAdvertisement) FlowHistory(org.batfish.datamodel.FlowHistory) FlowTrace(org.batfish.datamodel.FlowTrace) Environment(org.batfish.datamodel.pojo.Environment) Edge(org.batfish.datamodel.Edge) GraphEdge(org.batfish.symbolic.GraphEdge) Flow(org.batfish.datamodel.Flow)

Example 3 with Environment

use of org.batfish.datamodel.pojo.Environment in project batfish by batfish.

the class CounterExample method buildFlowHistory.

/*
   * Creates a trace-based example of what happens
   * to a packet (e.g., why it is not reachable).
   */
FlowHistory buildFlowHistory(String testrigName, Collection<String> sourceRouters, Encoder enc, Map<String, Boolean> reach) {
    FlowHistory fh = new FlowHistory();
    for (String source : sourceRouters) {
        Boolean sourceVar = reach.get(source);
        if (!sourceVar) {
            Tuple<Flow, FlowTrace> tup = buildFlowTrace(enc, source);
            SortedSet<Edge> failedLinks = buildFailedLinks(enc);
            SortedSet<BgpAdvertisement> envRoutes = buildEnvRoutingTable(enc);
            Environment baseEnv = new Environment("BASE", testrigName, failedLinks, null, null, null, null, envRoutes);
            fh.addFlowTrace(tup.getFirst(), "BASE", baseEnv, tup.getSecond());
        }
    }
    return fh;
}
Also used : BgpAdvertisement(org.batfish.datamodel.BgpAdvertisement) FlowHistory(org.batfish.datamodel.FlowHistory) FlowTrace(org.batfish.datamodel.FlowTrace) Environment(org.batfish.datamodel.pojo.Environment) Edge(org.batfish.datamodel.Edge) GraphEdge(org.batfish.symbolic.GraphEdge) Flow(org.batfish.datamodel.Flow)

Aggregations

FlowHistory (org.batfish.datamodel.FlowHistory)3 Environment (org.batfish.datamodel.pojo.Environment)3 BgpAdvertisement (org.batfish.datamodel.BgpAdvertisement)2 Edge (org.batfish.datamodel.Edge)2 Flow (org.batfish.datamodel.Flow)2 FlowTrace (org.batfish.datamodel.FlowTrace)2 GraphEdge (org.batfish.symbolic.GraphEdge)2 BoolExpr (com.microsoft.z3.BoolExpr)1