use of org.batfish.datamodel.answers.BdpAnswerElement in project batfish by batfish.
the class RouteReflectionTest method generateRoutesOneReflector.
/*
* See documentation of calling functions for information description of produced network
*/
private SortedMap<String, SortedMap<String, SortedSet<AbstractRoute>>> generateRoutesOneReflector(boolean edge1RouteReflectorClient, boolean edge2RouteReflectorClient) {
Ip as1PeeringIp = new Ip("10.12.11.1");
Ip edge1EbgpIfaceIp = new Ip("10.12.11.2");
Ip edge1IbgpIfaceIp = new Ip("10.1.12.1");
Ip edge1LoopbackIp = new Ip("2.0.0.1");
Ip rrEdge1IfaceIp = new Ip("10.1.12.2");
Ip rrEdge2IfaceIp = new Ip("10.1.23.2");
Ip rrLoopbackIp = new Ip("2.0.0.2");
Ip as3PeeringIp = new Ip("10.23.31.3");
Ip edge2EbgpIfaceIp = new Ip("10.23.31.2");
Ip edge2IbgpIfaceIp = new Ip("10.1.23.3");
Ip edge2LoopbackIp = new Ip("2.0.0.3");
Configuration edge1 = _cb.setHostname(EDGE1_NAME).build();
Vrf vEdge1 = _vb.setOwner(edge1).build();
_ib.setOwner(edge1).setVrf(vEdge1);
_ib.setAddress(new InterfaceAddress(edge1EbgpIfaceIp, EDGE_PREFIX_LENGTH)).build();
_ib.setAddress(new InterfaceAddress(edge1LoopbackIp, Prefix.MAX_PREFIX_LENGTH)).build();
_ib.setAddress(new InterfaceAddress(edge1IbgpIfaceIp, EDGE_PREFIX_LENGTH)).build();
StaticRoute.Builder sb = StaticRoute.builder();
vEdge1.setStaticRoutes(ImmutableSortedSet.of(sb.setNextHopIp(rrEdge1IfaceIp).setNetwork(new Prefix(rrLoopbackIp, Prefix.MAX_PREFIX_LENGTH)).build()));
BgpProcess edge1Proc = _pb.setRouterId(edge1LoopbackIp).setVrf(vEdge1).build();
RoutingPolicy edge1EbgpExportPolicy = _nullExportPolicyBuilder.setOwner(edge1).build();
_nb.setOwner(edge1).setVrf(vEdge1).setBgpProcess(edge1Proc).setClusterId(edge1LoopbackIp.asLong()).setRemoteAs(1).setLocalIp(edge1EbgpIfaceIp).setPeerAddress(as1PeeringIp).setExportPolicy(edge1EbgpExportPolicy.getName()).build();
RoutingPolicy edge1IbgpExportPolicy = _defaultExportPolicyBuilder.setOwner(edge1).build();
_nb.setRemoteAs(2).setLocalIp(edge1LoopbackIp).setPeerAddress(rrLoopbackIp).setExportPolicy(edge1IbgpExportPolicy.getName()).build();
Configuration rr = _cb.setHostname(RR_NAME).build();
Vrf vRr = _vb.setOwner(rr).build();
_ib.setOwner(rr).setVrf(vRr);
_ib.setAddress(new InterfaceAddress(rrEdge1IfaceIp, EDGE_PREFIX_LENGTH)).build();
_ib.setAddress(new InterfaceAddress(rrLoopbackIp, Prefix.MAX_PREFIX_LENGTH)).build();
_ib.setAddress(new InterfaceAddress(rrEdge2IfaceIp, EDGE_PREFIX_LENGTH)).build();
vRr.setStaticRoutes(ImmutableSortedSet.of(sb.setNextHopIp(edge1IbgpIfaceIp).setNetwork(new Prefix(edge1LoopbackIp, Prefix.MAX_PREFIX_LENGTH)).build(), sb.setNextHopIp(edge2IbgpIfaceIp).setNetwork(new Prefix(edge2LoopbackIp, Prefix.MAX_PREFIX_LENGTH)).build()));
BgpProcess rrProc = _pb.setRouterId(rrLoopbackIp).setVrf(vRr).build();
RoutingPolicy rrExportPolicy = _defaultExportPolicyBuilder.setOwner(rr).build();
_nb.setOwner(rr).setVrf(vRr).setBgpProcess(rrProc).setClusterId(rrLoopbackIp.asLong()).setRemoteAs(2).setLocalIp(rrLoopbackIp).setExportPolicy(rrExportPolicy.getName());
if (edge1RouteReflectorClient) {
_nb.setRouteReflectorClient(true);
}
_nb.setPeerAddress(edge1LoopbackIp).build();
_nb.setRouteReflectorClient(false);
if (edge2RouteReflectorClient) {
_nb.setRouteReflectorClient(true);
}
_nb.setPeerAddress(edge2LoopbackIp).build();
_nb.setRouteReflectorClient(false);
Configuration edge2 = _cb.setHostname(EDGE2_NAME).build();
Vrf vEdge2 = _vb.setOwner(edge2).build();
_ib.setOwner(edge2).setVrf(vEdge2);
_ib.setAddress(new InterfaceAddress(edge2EbgpIfaceIp, EDGE_PREFIX_LENGTH)).build();
_ib.setAddress(new InterfaceAddress(edge2LoopbackIp, Prefix.MAX_PREFIX_LENGTH)).build();
_ib.setAddress(new InterfaceAddress(edge2IbgpIfaceIp, EDGE_PREFIX_LENGTH)).build();
vEdge2.setStaticRoutes(ImmutableSortedSet.of(sb.setNextHopIp(rrEdge2IfaceIp).setNetwork(new Prefix(rrLoopbackIp, Prefix.MAX_PREFIX_LENGTH)).build()));
BgpProcess edge2Proc = _pb.setRouterId(edge2LoopbackIp).setVrf(vEdge2).build();
RoutingPolicy edge2EbgpExportPolicy = _nullExportPolicyBuilder.setOwner(edge2).build();
_nb.setOwner(edge2).setVrf(vEdge2).setBgpProcess(edge2Proc).setClusterId(edge2LoopbackIp.asLong()).setRemoteAs(3).setLocalIp(edge2EbgpIfaceIp).setPeerAddress(as3PeeringIp).setExportPolicy(edge2EbgpExportPolicy.getName()).build();
RoutingPolicy edge2IbgpExportPolicy = _defaultExportPolicyBuilder.setOwner(edge2).build();
_nb.setRemoteAs(2).setLocalIp(edge2LoopbackIp).setPeerAddress(rrLoopbackIp).setExportPolicy(edge2IbgpExportPolicy.getName()).build();
SortedMap<String, Configuration> configurations = new ImmutableSortedMap.Builder<String, Configuration>(String::compareTo).put(edge1.getName(), edge1).put(rr.getName(), rr).put(edge2.getName(), edge2).build();
BdpEngine engine = new BdpEngine(new MockBdpSettings(), new BatfishLogger(BatfishLogger.LEVELSTR_OUTPUT, false), (s, i) -> new AtomicInteger());
Topology topology = CommonUtil.synthesizeTopology(configurations);
BdpDataPlane dp = engine.computeDataPlane(false, configurations, topology, ImmutableSet.of(_ab.setAsPath(AsPath.ofSingletonAsSets(1)).setDstIp(edge1EbgpIfaceIp).setDstNode(edge1.getName()).setNetwork(AS1_PREFIX).setNextHopIp(as1PeeringIp).setOriginatorIp(as1PeeringIp).setSrcIp(as1PeeringIp).setSrcNode("as1Edge").build(), _ab.setAsPath(AsPath.ofSingletonAsSets(3)).setDstIp(edge2EbgpIfaceIp).setDstNode(edge2.getName()).setNetwork(AS3_PREFIX).setNextHopIp(as3PeeringIp).setOriginatorIp(as3PeeringIp).setSrcIp(as3PeeringIp).setSrcNode("as3Edge").build()), new BdpAnswerElement());
return engine.getRoutes(dp);
}
Aggregations