/** * The BDDP packets are forwarded out of all the ports out of an openflowdomain. Get all the * switches in the same openflow domain as the sw (disabling tunnels). Then get all the external * switch ports and send these packets out. * * @param sw * @param pi * @param cntx */ protected void doFloodBDDP(long pinSwitch, OFPacketIn pi, FloodlightContext cntx) { TopologyInstanceKHopMetric ti = getCurrentInstance(false); Set<Long> switches = ti.getSwitchesInOpenflowDomain(pinSwitch); if (switches == null) { // indicates no links are connected to the switches switches = new HashSet<Long>(); switches.add(pinSwitch); } for (long sid : switches) { IOFSwitch sw = floodlightProvider.getSwitches().get(sid); if (sw == null) continue; Collection<Short> enabledPorts = sw.getEnabledPortNumbers(); if (enabledPorts == null) continue; Set<Short> ports = new HashSet<Short>(); ports.addAll(enabledPorts); // all the ports known to topology // without tunnels. // out of these, we need to choose only those that are // broadcast port, otherwise, we should eliminate. Set<Short> portsKnownToTopo = ti.getPortsWithLinks(sid); if (portsKnownToTopo != null) { for (short p : portsKnownToTopo) { NodePortTuple npt = new NodePortTuple(sid, p); if (ti.isBroadcastDomainPort(npt) == false) { ports.remove(p); } } } // remove the incoming switch port if (pinSwitch == sid) { ports.remove(pi.getInPort()); } // we have all the switch ports to which we need to broadcast. doMultiActionPacketOut(pi.getPacketData(), sw, ports, cntx); } }
/** Get all the ports connected to the switch */ @Override public Set<Short> getPortsWithLinks(long sw, boolean tunnelEnabled) { TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled); return ti.getPortsWithLinks(sw); }