Ejemplo n.º 1
0
 @Override
 public NodePortTuple getOutgoingSwitchPort(
     long src, short srcPort, long dst, short dstPort, boolean tunnelEnabled) {
   // Use this function to redirect traffic if needed.
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.getOutgoingSwitchPort(src, srcPort, dst, dstPort);
 }
Ejemplo n.º 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);
    }

    TopologyInstance nt =
        new TopologyInstance(
            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;
  }
Ejemplo n.º 3
0
 @Override
 public NodePortTuple getAllowedOutgoingBroadcastPort(
     long src, short srcPort, long dst, short dstPort, boolean tunnelEnabled) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.getAllowedOutgoingBroadcastPort(
       src, srcPort,
       dst, dstPort);
 }
Ejemplo n.º 4
0
  @Override
  public boolean isAttachmentPointPort(long switchid, short port, boolean tunnelEnabled) {
    TopologyInstance 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));
  }
Ejemplo n.º 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) {

    TopologyInstance 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);
    }
  }
  /**
   * Computes the per-cluster spanning trees as well an overall spanning tree for the whole
   * topology.
   */
  public void compute() {
    // call the parent method to compute the per-cluster spanning trees.
    super.compute();

    //    	// identify OpenFlow clusters
    //    	identifyOpenflowClusters();

    // add links to the general overall cluster.
    addLinks();

    // compute spanning general tree for the whole topology.
    calculateShortestPathTree();

    // compute the ports included in the spanning tree.
    calculateBroadcastNodePorts();

    //    	// TESTING
    //    	System.out.println("TEST STP    : " + topologyBroadcastNodePorts.size() + " : " +
    // topologyBroadcastNodePorts);
  }
Ejemplo n.º 7
0
 @Override
 public long getL2DomainId(long switchId, boolean tunnelEnabled) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.getL2DomainId(switchId);
 }
Ejemplo n.º 8
0
 @Override
 public boolean isInSameBroadcastDomain(
     long s1, short p1, long s2, short p2, boolean tunnelEnabled) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.inSameBroadcastDomain(s1, p1, s2, p2);
 }
Ejemplo n.º 9
0
 @Override
 public boolean routeExists(long src, long dst, boolean tunnelEnabled) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.routeExists(src, dst);
 }
Ejemplo n.º 10
0
 /**
  * Overloaded method done to the condition that there are several possible destinations. The
  * chosen destination will be the lowest cost.
  *
  * @param src
  * @param dsts
  * @param cookie
  * @return
  */
 public Route getRoute(long src, List<Long> dsts) {
   TopologyInstance ti = getCurrentInstance(true);
   return ti.getRoute(src, dsts);
 }
Ejemplo n.º 11
0
 @Override
 public boolean isAllowed(long sw, short portId, boolean tunnelEnabled) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.isAllowed(sw, portId);
 }
Ejemplo n.º 12
0
 @Override
 public Route getRoute(long src, short srcPort, long dst, short dstPort, boolean tunnelEnabled) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.getRoute(src, srcPort, dst, dstPort);
 }
Ejemplo n.º 13
0
 @Override
 public boolean isConsistent(
     long oldSw, short oldPort, long newSw, short newPort, boolean tunnelEnabled) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.isConsistent(oldSw, oldPort, newSw, newPort);
 }
Ejemplo n.º 14
0
 @Override
 public boolean inSameL2Domain(long switch1, long switch2, boolean tunnelEnabled) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.inSameL2Domain(switch1, switch2);
 }
Ejemplo n.º 15
0
 @Override
 public boolean isBroadcastDomainPort(long sw, short port, boolean tunnelEnabled) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.isBroadcastDomainPort(new NodePortTuple(sw, port));
 }
Ejemplo n.º 16
0
 public boolean isIncomingBroadcastAllowed(long sw, short portId, boolean tunnelEnabled) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.isIncomingBroadcastAllowedOnSwitchPort(sw, portId);
 }
Ejemplo n.º 17
0
 @Override
 public NodePortTuple getIncomingSwitchPort(
     long src, short srcPort, long dst, short dstPort, boolean tunnelEnabled) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.getIncomingSwitchPort(src, srcPort, dst, dstPort);
 }
Ejemplo n.º 18
0
 /** Get all the ports connected to the switch */
 @Override
 public Set<Short> getPortsWithLinks(long sw, boolean tunnelEnabled) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.getPortsWithLinks(sw);
 }
Ejemplo n.º 19
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) {
   TopologyInstance ti = getCurrentInstance(tunnelEnabled);
   return ti.getBroadcastPorts(targetSw, src, srcPort);
 }