Search in sources :

Example 1 with SmtReachabilityAnswerElement

use of org.batfish.symbolic.answers.SmtReachabilityAnswerElement in project batfish by batfish.

the class PropertyChecker method checkReachability.

/*
   * Check if a collection of routers will be reachable to
   * one or more destinations.
   */
public AnswerElement checkReachability(HeaderLocationQuestion q) {
    return checkProperty(q, (enc, srcRouters, destPorts) -> {
        PropertyAdder pa = new PropertyAdder(enc.getMainSlice());
        return pa.instrumentReachability(destPorts);
    }, (vp) -> {
        if (vp.getResult().isVerified()) {
            return new SmtReachabilityAnswerElement(vp.getResult(), new FlowHistory());
        } else {
            FlowHistory fh;
            CounterExample ce = new CounterExample(vp.getModel());
            String testrigName = _batfish.getTestrigName();
            if (q.getDiffType() != null) {
                fh = ce.buildFlowHistoryDiff(testrigName, vp.getSrcRouters(), vp.getEnc(), vp.getEncDiff(), vp.getProp(), vp.getPropDiff());
            } else {
                Map<String, Boolean> reachVals = vp.getProp().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> ce.isTrue(entry.getValue()) ^ q.getNegate()));
                fh = ce.buildFlowHistory(testrigName, vp.getSrcRouters(), vp.getEnc(), reachVals);
            }
            return new SmtReachabilityAnswerElement(vp.getResult(), fh);
        }
    });
}
Also used : HeaderSpace(org.batfish.datamodel.HeaderSpace) PatternUtils(org.batfish.symbolic.utils.PatternUtils) SmtOneAnswerElement(org.batfish.symbolic.answers.SmtOneAnswerElement) SortedSet(java.util.SortedSet) FlowHistory(org.batfish.datamodel.FlowHistory) Flow(org.batfish.datamodel.Flow) HeaderQuestion(org.batfish.datamodel.questions.smt.HeaderQuestion) EnvironmentType(org.batfish.datamodel.questions.smt.EnvironmentType) Map(java.util.Map) NetworkSlice(org.batfish.symbolic.abstraction.NetworkSlice) SmtDeterminismAnswerElement(org.batfish.symbolic.answers.SmtDeterminismAnswerElement) EnumMap(java.util.EnumMap) Collection(java.util.Collection) Set(java.util.Set) SmtReachabilityAnswerElement(org.batfish.symbolic.answers.SmtReachabilityAnswerElement) Graph(org.batfish.symbolic.Graph) PathRegexes(org.batfish.symbolic.utils.PathRegexes) Collectors(java.util.stream.Collectors) IBatfish(org.batfish.common.plugin.IBatfish) Settings(org.batfish.config.Settings) Model(com.microsoft.z3.Model) List(java.util.List) Stream(java.util.stream.Stream) Entry(java.util.Map.Entry) TriFunction(org.batfish.symbolic.utils.TriFunction) Optional(java.util.Optional) AnswerElement(org.batfish.datamodel.answers.AnswerElement) Pattern(java.util.regex.Pattern) SortedMap(java.util.SortedMap) IpWildcard(org.batfish.datamodel.IpWildcard) Ip(org.batfish.datamodel.Ip) Iterables(com.google.common.collect.Iterables) CommunityVar(org.batfish.symbolic.CommunityVar) Context(com.microsoft.z3.Context) HashMap(java.util.HashMap) BatfishException(org.batfish.common.BatfishException) Function(java.util.function.Function) Supplier(java.util.function.Supplier) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Abstraction(org.batfish.symbolic.abstraction.Abstraction) BoolExpr(com.microsoft.z3.BoolExpr) Configuration(org.batfish.datamodel.Configuration) ArithExpr(com.microsoft.z3.ArithExpr) Nullable(javax.annotation.Nullable) SmtManyAnswerElement(org.batfish.symbolic.answers.SmtManyAnswerElement) StaticRoute(org.batfish.datamodel.StaticRoute) BitVecExpr(com.microsoft.z3.BitVecExpr) Tuple(org.batfish.symbolic.utils.Tuple) GraphEdge(org.batfish.symbolic.GraphEdge) TreeMap(java.util.TreeMap) Expr(com.microsoft.z3.Expr) Protocol(org.batfish.symbolic.Protocol) HeaderLocationQuestion(org.batfish.datamodel.questions.smt.HeaderLocationQuestion) Table2(org.batfish.symbolic.collections.Table2) Collections(java.util.Collections) Prefix(org.batfish.datamodel.Prefix) DestinationClasses(org.batfish.symbolic.abstraction.DestinationClasses) FlowHistory(org.batfish.datamodel.FlowHistory) SmtReachabilityAnswerElement(org.batfish.symbolic.answers.SmtReachabilityAnswerElement) Map(java.util.Map) EnumMap(java.util.EnumMap) SortedMap(java.util.SortedMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Aggregations

Iterables (com.google.common.collect.Iterables)1 ArithExpr (com.microsoft.z3.ArithExpr)1 BitVecExpr (com.microsoft.z3.BitVecExpr)1 BoolExpr (com.microsoft.z3.BoolExpr)1 Context (com.microsoft.z3.Context)1 Expr (com.microsoft.z3.Expr)1 Model (com.microsoft.z3.Model)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 Set (java.util.Set)1 SortedMap (java.util.SortedMap)1 SortedSet (java.util.SortedSet)1