コード例 #1
0
 @Override
 public NodePortTuple getOutgoingSwitchPort(
     long src, short srcPort, long dst, short dstPort, boolean tunnelEnabled) {
   // Use this function to redirect traffic if needed.
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.getOutgoingSwitchPort(src, srcPort, dst, dstPort);
 }
コード例 #2
0
  /**
   * This function computes a new topology instance. It ignores links connected to all broadcast
   * domain ports and tunnel ports. The method returns if a new instance of topology was created or
   * not.
   */
  protected boolean createNewInstance() {
    Set<NodePortTuple> blockedPorts = new HashSet<NodePortTuple>();

    if (!linksUpdated) return false;

    Map<NodePortTuple, Set<Link>> openflowLinks;
    openflowLinks = new HashMap<NodePortTuple, Set<Link>>(switchPortLinks);

    // Remove all tunnel links.
    for (NodePortTuple npt : tunnelLinks.keySet()) {
      if (openflowLinks.get(npt) != null) openflowLinks.remove(npt);
    }

    // Remove all broadcast domain links.
    for (NodePortTuple npt : portBroadcastDomainLinks.keySet()) {
      if (openflowLinks.get(npt) != null) openflowLinks.remove(npt);
    }

    TopologyInstanceKHopMetric nt =
        new TopologyInstanceKHopMetric(
            switchPorts,
            blockedPorts,
            openflowLinks,
            portBroadcastDomainLinks.keySet(),
            tunnelLinks.keySet());
    nt.compute();
    // We set the instances with and without tunnels to be identical.
    // If needed, we may compute them differently.
    currentInstance = nt;
    currentInstanceWithoutTunnels = nt;
    return true;
  }
コード例 #3
0
 @Override
 public NodePortTuple getAllowedOutgoingBroadcastPort(
     long src, short srcPort, long dst, short dstPort, boolean tunnelEnabled) {
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.getAllowedOutgoingBroadcastPort(
       src, srcPort,
       dst, dstPort);
 }
コード例 #4
0
  @Override
  public boolean isAttachmentPointPort(long switchid, short port, boolean tunnelEnabled) {
    TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);

    // if the port is not attachment point port according to
    // topology instance, then return false
    if (ti.isAttachmentPointPort(switchid, port) == false) return false;

    // Check whether the port is a physical port. We should not learn
    // attachment points on "special" ports.
    if ((port & 0xff00) == 0xff00 && port != (short) 0xfffe) return false;

    // Make sure that the port is enabled.
    IOFSwitch sw = floodlightProvider.getSwitches().get(switchid);
    if (sw == null) return false;
    return (sw.portEnabled(port));
  }
コード例 #5
0
  /**
   * 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);
    }
  }
コード例 #6
0
 @Override
 public boolean isInSameBroadcastDomain(
     long s1, short p1, long s2, short p2, boolean tunnelEnabled) {
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.inSameBroadcastDomain(s1, p1, s2, p2);
 }
コード例 #7
0
 @Override
 public Route getRoute(long src, short srcPort, long dst, short dstPort, boolean tunnelEnabled) {
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.getRoute(src, srcPort, dst, dstPort);
 }
コード例 #8
0
 @Override
 public boolean routeExists(long src, long dst, boolean tunnelEnabled) {
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.routeExists(src, dst);
 }
コード例 #9
0
 @Override
 public boolean inSameL2Domain(long switch1, long switch2, boolean tunnelEnabled) {
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.inSameL2Domain(switch1, switch2);
 }
コード例 #10
0
 @Override
 public boolean isAllowed(long sw, short portId, boolean tunnelEnabled) {
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.isAllowed(sw, portId);
 }
コード例 #11
0
 @Override
 public boolean isBroadcastDomainPort(long sw, short port, boolean tunnelEnabled) {
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.isBroadcastDomainPort(new NodePortTuple(sw, port));
 }
コード例 #12
0
 @Override
 public boolean isConsistent(
     long oldSw, short oldPort, long newSw, short newPort, boolean tunnelEnabled) {
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.isConsistent(oldSw, oldPort, newSw, newPort);
 }
コード例 #13
0
 @Override
 public long getL2DomainId(long switchId, boolean tunnelEnabled) {
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.getL2DomainId(switchId);
 }
コード例 #14
0
 @Override
 public NodePortTuple getIncomingSwitchPort(
     long src, short srcPort, long dst, short dstPort, boolean tunnelEnabled) {
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.getIncomingSwitchPort(src, srcPort, dst, dstPort);
 }
コード例 #15
0
 public boolean isIncomingBroadcastAllowed(long sw, short portId, boolean tunnelEnabled) {
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.isIncomingBroadcastAllowedOnSwitchPort(sw, portId);
 }
コード例 #16
0
 /**
  * Get all the ports on the target switch (targetSw) on which a broadcast packet must be sent from
  * a host whose attachment point is on switch port (src, srcPort).
  */
 public Set<Short> getBroadcastPorts(
     long targetSw, long src, short srcPort, boolean tunnelEnabled) {
   TopologyInstanceKHopMetric ti = getCurrentInstance(tunnelEnabled);
   return ti.getBroadcastPorts(targetSw, src, srcPort);
 }
コード例 #17
0
 /** 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);
 }