@Test public void testSynthesizeTopology_asymmetricPartialOverlap() { NetworkFactory nf = new NetworkFactory(); Configuration.Builder cb = nf.configurationBuilder().setConfigurationFormat(ConfigurationFormat.CISCO_IOS); Configuration c1 = cb.build(); Configuration c2 = cb.build(); nf.interfaceBuilder() .setOwner(c1) .setAddresses(ConcreteInterfaceAddress.parse("1.2.3.4/24")) .build(); nf.interfaceBuilder() .setOwner(c2) .setAddresses(ConcreteInterfaceAddress.parse("1.2.3.17/28")) .build(); Topology t = TopologyUtil.synthesizeL3Topology( ImmutableMap.of(c1.getHostname(), c1, c2.getHostname(), c2)); assertThat(t.getEdges(), empty()); }
public static Topology synthesizeL3Topology(Map<String, Configuration> configurations) { Map<Prefix, List<Interface>> prefixInterfaces = computeInterfacesBucketByPrefix(configurations); ImmutableSortedSet.Builder<Edge> edges = ImmutableSortedSet.naturalOrder(); for (Entry<Prefix, List<Interface>> bucketEntry : prefixInterfaces.entrySet()) { Prefix p = bucketEntry.getKey(); Set<Interface> candidateInterfaces = candidateInterfacesForPrefix(prefixInterfaces, p); for (Interface iface1 : bucketEntry.getValue()) { for (Interface iface2 : candidateInterfaces) { if (!isValidLayer3Adjacency(iface1, iface2)) { continue; } if (TUNNEL_INTERFACE_TYPES.contains(iface1.getInterfaceType()) || TUNNEL_INTERFACE_TYPES.contains(iface2.getInterfaceType())) { continue; } edges.add(new Edge(iface1, iface2)); } } } return new Topology(edges.build()); }
TopologyUtil { public static Topology synthesizeL3Topology(Map<String, Configuration> configurations) { Map<Prefix, List<Interface>> prefixInterfaces = computeInterfacesBucketByPrefix(configurations); ImmutableSortedSet.Builder<Edge> edges = ImmutableSortedSet.naturalOrder(); for (Entry<Prefix, List<Interface>> bucketEntry : prefixInterfaces.entrySet()) { Prefix p = bucketEntry.getKey(); Set<Interface> candidateInterfaces = candidateInterfacesForPrefix(prefixInterfaces, p); for (Interface iface1 : bucketEntry.getValue()) { for (Interface iface2 : candidateInterfaces) { if (!isValidLayer3Adjacency(iface1, iface2)) { continue; } if (TUNNEL_INTERFACE_TYPES.contains(iface1.getInterfaceType()) || TUNNEL_INTERFACE_TYPES.contains(iface2.getInterfaceType())) { continue; } edges.add(new Edge(iface1, iface2)); } } } return new Topology(edges.build()); } }
TopologyUtil { public static Topology synthesizeL3Topology(Map<String, Configuration> configurations) { Map<Prefix, List<Interface>> prefixInterfaces = computeInterfacesBucketByPrefix(configurations); ImmutableSortedSet.Builder<Edge> edges = ImmutableSortedSet.naturalOrder(); for (Entry<Prefix, List<Interface>> bucketEntry : prefixInterfaces.entrySet()) { Prefix p = bucketEntry.getKey(); Set<Interface> candidateInterfaces = candidateInterfacesForPrefix(prefixInterfaces, p); for (Interface iface1 : bucketEntry.getValue()) { for (Interface iface2 : candidateInterfaces) { if (!isValidLayer3Adjacency(iface1, iface2)) { continue; } if (TUNNEL_INTERFACE_TYPES.contains(iface1.getInterfaceType()) || TUNNEL_INTERFACE_TYPES.contains(iface2.getInterfaceType())) { continue; } edges.add(new Edge(iface1, iface2)); } } } return new Topology(edges.build()); } private  TopologyUtil(); }
TopologyUtil { public static Topology synthesizeL3Topology(Map<String, Configuration> configurations) { Map<Prefix, List<Interface>> prefixInterfaces = computeInterfacesBucketByPrefix(configurations); ImmutableSortedSet.Builder<Edge> edges = ImmutableSortedSet.naturalOrder(); for (Entry<Prefix, List<Interface>> bucketEntry : prefixInterfaces.entrySet()) { Prefix p = bucketEntry.getKey(); Set<Interface> candidateInterfaces = candidateInterfacesForPrefix(prefixInterfaces, p); for (Interface iface1 : bucketEntry.getValue()) { for (Interface iface2 : candidateInterfaces) { if (!isValidLayer3Adjacency(iface1, iface2)) { continue; } if (TUNNEL_INTERFACE_TYPES.contains(iface1.getInterfaceType()) || TUNNEL_INTERFACE_TYPES.contains(iface2.getInterfaceType())) { continue; } edges.add(new Edge(iface1, iface2)); } } } return new Topology(edges.build()); } private  TopologyUtil(); static @Nonnull Layer1Topology cleanLayer1PhysicalTopology(
      @Nonnull Layer1Topology rawLayer1Topology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Optional<Layer1Topology> unionLayer1PhysicalTopologies(
      Optional<Layer1Topology> topology1, Optional<Layer1Topology> topology2); static @Nonnull Layer2Topology computeLayer2Topology(
      @Nonnull Layer1Topology layer1LogicalTopology,
      VxlanTopology vxlanTopology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Topology computeRawLayer3Topology(
      @Nonnull Optional<Layer1Topology> rawLayer1PhysicalTopology,
      @Nonnull Optional<Layer1Topology> layer1LogicalTopology,
      @Nonnull Optional<Layer2Topology> layer2Topology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Topology computeLayer3Topology(
      Topology rawLayer3Topology, Set<Edge> overlayEdges); static @Nullable Interface getInterface(
      @Nonnull Layer1Node layer1Node, @Nonnull Map<String, Configuration> configurations); static @Nullable Interface getInterface(
      @Nonnull Layer2Node layer2Node, @Nonnull Map<String, Configuration> configurations); static IpsecTopology computeIpsecTopology(Map<String, Configuration> configurations); static Map<String, Set<Interface>> computeNodeInterfaces(
      Map<String, Configuration> configurations); static Topology synthesizeL3Topology(Map<String, Configuration> configurations); static @Nonnull Layer1Topology computeLayer1LogicalTopology(
      Layer1Topology layer1PhysicalTopology, Map<String, Configuration> configurations); @Nonnull static TunnelTopology computeInitialTunnelTopology(
      Map<String, Configuration> configurations); @Nonnull static TunnelTopology pruneUnreachableTunnelEdges(
      TunnelTopology initialTunnelTopology,
      NetworkConfigurations configurations,
      TracerouteEngine tracerouteEngine); }
TopologyUtil { public static Topology synthesizeL3Topology(Map<String, Configuration> configurations) { Map<Prefix, List<Interface>> prefixInterfaces = computeInterfacesBucketByPrefix(configurations); ImmutableSortedSet.Builder<Edge> edges = ImmutableSortedSet.naturalOrder(); for (Entry<Prefix, List<Interface>> bucketEntry : prefixInterfaces.entrySet()) { Prefix p = bucketEntry.getKey(); Set<Interface> candidateInterfaces = candidateInterfacesForPrefix(prefixInterfaces, p); for (Interface iface1 : bucketEntry.getValue()) { for (Interface iface2 : candidateInterfaces) { if (!isValidLayer3Adjacency(iface1, iface2)) { continue; } if (TUNNEL_INTERFACE_TYPES.contains(iface1.getInterfaceType()) || TUNNEL_INTERFACE_TYPES.contains(iface2.getInterfaceType())) { continue; } edges.add(new Edge(iface1, iface2)); } } } return new Topology(edges.build()); } private  TopologyUtil(); static @Nonnull Layer1Topology cleanLayer1PhysicalTopology(
      @Nonnull Layer1Topology rawLayer1Topology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Optional<Layer1Topology> unionLayer1PhysicalTopologies(
      Optional<Layer1Topology> topology1, Optional<Layer1Topology> topology2); static @Nonnull Layer2Topology computeLayer2Topology(
      @Nonnull Layer1Topology layer1LogicalTopology,
      VxlanTopology vxlanTopology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Topology computeRawLayer3Topology(
      @Nonnull Optional<Layer1Topology> rawLayer1PhysicalTopology,
      @Nonnull Optional<Layer1Topology> layer1LogicalTopology,
      @Nonnull Optional<Layer2Topology> layer2Topology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Topology computeLayer3Topology(
      Topology rawLayer3Topology, Set<Edge> overlayEdges); static @Nullable Interface getInterface(
      @Nonnull Layer1Node layer1Node, @Nonnull Map<String, Configuration> configurations); static @Nullable Interface getInterface(
      @Nonnull Layer2Node layer2Node, @Nonnull Map<String, Configuration> configurations); static IpsecTopology computeIpsecTopology(Map<String, Configuration> configurations); static Map<String, Set<Interface>> computeNodeInterfaces(
      Map<String, Configuration> configurations); static Topology synthesizeL3Topology(Map<String, Configuration> configurations); static @Nonnull Layer1Topology computeLayer1LogicalTopology(
      Layer1Topology layer1PhysicalTopology, Map<String, Configuration> configurations); @Nonnull static TunnelTopology computeInitialTunnelTopology(
      Map<String, Configuration> configurations); @Nonnull static TunnelTopology pruneUnreachableTunnelEdges(
      TunnelTopology initialTunnelTopology,
      NetworkConfigurations configurations,
      TracerouteEngine tracerouteEngine);  }