Package net.beaconcontroller.core

Examples of net.beaconcontroller.core.IOFSwitch


        SwitchDevice switchDevice = flowscaleController
            .getSwitchDevices().get(
                HexString.toLong(datapathIdString));

        IOFSwitch sw = switchDevice.getOpenFlowSwitch();
        List<OFPhysicalPort> switchPorts = switchDevice.getPortStates();
        OFPhysicalPort updatedPort = null;

        for (OFPhysicalPort ofPort : switchPorts) {

          if (ofPort.getPortNumber() == Short
              .parseShort(sensorIdString)) {
            updatedPort = ofPort;
            break;

          }

        }

        updatedPort.setConfig(0);

        OFPortMod portMod = new OFPortMod();

        if (updateStatus.equals("down")) {
          portMod.setConfig(OFPhysicalPort.OFPortConfig.OFPPC_PORT_DOWN
              .getValue());
        } else if (updateStatus.equals("up")) {
          portMod.setConfig(0);
        }

        portMod.setMask(1);
        portMod.setPortNumber(updatedPort.getPortNumber());
        portMod.setHardwareAddress(updatedPort.getHardwareAddress());
        portMod.setType(OFType.PORT_MOD);

        sw.getOutputStream().write(portMod);
        sw.getOutputStream().flush();
        obj = new JSONObject();
        obj.put("result", "success");
        obj.put("desc", "sensor "+sensorIdString+" marked as "+updateStatus +
            " on switch "+ datapathIdString);
        response.getWriter().print(obj);
View Full Code Here


     
      flowActions.add(actionOutput);
      oFFlowMod.setActions(flowActions);
      }
     
      IOFSwitch sw = ibeaconProvider.getSwitches().get(
          HexString.toLong(cliArguments.get("switch")));
      try {
        System.out.println(oFFlowMod);
        sw.getOutputStream().write(oFFlowMod);
        sw.getOutputStream().flush();
        return "flow added";
       
      } catch (IOException ioe) {
        ioe.printStackTrace();
        return "An error occured with the insertion , check logs";
View Full Code Here

      SwitchDevice switchDevice = flowscaleController
          .getSwitchDevices().get(
              HexString.toLong(datapathIdString));

      IOFSwitch sw = switchDevice.getOpenFlowSwitch();
      List<OFPhysicalPort> switchPorts = switchDevice.getPortStates();
      OFPhysicalPort updatedPort = null;

      for (OFPhysicalPort ofPort : switchPorts) {

        if (ofPort.getPortNumber() == port) {
          updatedPort = ofPort;
          break;

        }

      }

      updatedPort.setConfig(0);

      OFPortMod portMod = new OFPortMod();

     
        portMod.setConfig(OFPhysicalPort.OFPortConfig.OFPPC_PORT_DOWN
            .getValue());
   

      portMod.setMask(1);
      portMod.setPortNumber(updatedPort.getPortNumber());
      portMod.setHardwareAddress(updatedPort.getHardwareAddress());
      portMod.setType(OFType.PORT_MOD);

      sw.getOutputStream().write(portMod);
      sw.getOutputStream().flush();
      ci.print("done");

    } catch (Exception e) {
      ci.print(e.toString());
 
View Full Code Here

* @throws TimeoutException
*/
  public List<OFStatistics> getFlowStatisticsForLoader()
      throws NoSwitchException, IOException, InterruptedException,
      ExecutionException, TimeoutException {
    IOFSwitch iofSwitch = this.openFlowSwitch;
    Future<List<OFStatistics>> future;
    OFStatisticsRequest req = new OFStatisticsRequest();
    OFFlowStatisticsRequest fsr = new OFFlowStatisticsRequest();
    OFMatch match = new OFMatch();
    match.setWildcards(0xffffffff);
    fsr.setMatch(match);
    fsr.setOutPort(OFPort.OFPP_NONE.getValue());
    fsr.setTableId((byte) 0xff);
    req.setStatisticType(OFStatisticsType.FLOW);
    req.setStatistics(Collections.singletonList((OFStatistics) fsr));
    req.setLengthU(req.getLengthU() + fsr.getLength());

    if (iofSwitch == null) {
      throw new NoSwitchException();

    }

    future = iofSwitch.getStatistics(req);
    List<OFStatistics> futureValues = null;

    futureValues = future.get(10, TimeUnit.SECONDS);
    return futureValues;

View Full Code Here

  private  List<OFStatistics> getPortStatistics() throws NoSwitchException, IOException, InterruptedException, ExecutionException, TimeoutException {

   

    Future<List<OFStatistics>> future;
    IOFSwitch iofSwitch = this.openFlowSwitch;
    if(iofSwitch == null){
      throw new NoSwitchException(HexString.toHexString(this.datapathId));
    }
    OFStatisticsRequest req = new OFStatisticsRequest();
    OFPortStatisticsRequest fsr = new OFPortStatisticsRequest();
    fsr.setPortNumber(OFPort.OFPP_NONE.getValue());
    req.setStatisticType(OFStatisticsType.PORT);
    req.setStatistics(Collections.singletonList((OFStatistics) fsr));
    req.setLengthU(fsr.getLength() + req.getLength());
    List<OFStatistics> values = null;
 

        future = iofSwitch.getStatistics(req);
       
         values = future.get(10, TimeUnit.SECONDS);
   
      return values;
      
View Full Code Here

  private List<OFStatistics> getTableStatistics() throws IOException, InterruptedException, ExecutionException, TimeoutException, NoSwitchException {

   

    Future<List<OFStatistics>> futureTable;
    IOFSwitch iofSwitch = this.openFlowSwitch;
    if(iofSwitch == null){
      throw new NoSwitchException(HexString.toHexString(this.datapathId));
    }
    OFStatisticsRequest reqTable = new OFStatisticsRequest();

    reqTable.setStatisticType(OFStatisticsType.TABLE);
    reqTable.setLengthU(reqTable.getLengthU());

 
   
        futureTable = iofSwitch.getStatistics(reqTable);
        List<OFStatistics> values = null;
       
        values = futureTable.get(10, TimeUnit.SECONDS);
        return values;
View Full Code Here

  private List<OFStatistics>getFlowStatistics() throws IOException, InterruptedException, ExecutionException, TimeoutException, NoSwitchException {

   

    Future<List<OFStatistics>> future;
    IOFSwitch iofSwitch = this.openFlowSwitch;
    if(iofSwitch == null){
      throw new NoSwitchException(HexString.toHexString(this.datapathId));
    }
    OFStatisticsRequest req = new OFStatisticsRequest();
    OFFlowStatisticsRequest fsr = new OFFlowStatisticsRequest();
    OFMatch match = new OFMatch();
    match.setWildcards(0xffffffff);
    fsr.setMatch(match);
    fsr.setOutPort(OFPort.OFPP_NONE.getValue());
    fsr.setTableId((byte) 0xff);
    req.setStatisticType(OFStatisticsType.FLOW);
    req.setStatistics(Collections.singletonList((OFStatistics) fsr));
    req.setLengthU(req.getLengthU() + fsr.getLength());

 
      future = iofSwitch.getStatistics(req);
      List<OFStatistics> futureValues = null;

      futureValues = future.get(10, TimeUnit.SECONDS);
     
      return futureValues;
View Full Code Here

  private List<OFStatistics> getAggregateStatistics() throws NoSwitchException , IOException, InterruptedException, ExecutionException, TimeoutException {

 

    Future<List<OFStatistics>> future;
    IOFSwitch iofSwitch = this.openFlowSwitch;
    if(iofSwitch == null){
     
    }

    OFStatisticsRequest req = new OFStatisticsRequest();
    OFAggregateStatisticsRequest fsr = new OFAggregateStatisticsRequest();

    req.setStatisticType(OFStatisticsType.AGGREGATE);
    req.setStatistics(Collections.singletonList((OFStatistics) fsr));
    req.setLengthU(fsr.getLength() + req.getLength());

   
      future = iofSwitch.getStatistics(req);
      List<OFStatistics> values = null;
      values = future.get(10, TimeUnit.SECONDS);
      return values;
     
  }
View Full Code Here

    FlowscaleController.logger.trace("in ruleset pushing rules now: ");

    FlowscaleController.logger.trace("group rules are {} ", groupRules);
    // handle output switch first

    IOFSwitch outputSwitch = flowscaleController.getIBeaconProvider()
        .getSwitches().get(outputSwitchDatapathId);

    OFFlowMod flowModRule = new OFFlowMod();
    flowModRule.setType(OFType.FLOW_MOD);
    flowModRule.setCommand(OFFlowMod.OFPFC_ADD);
    flowModRule.setHardTimeout((short) 0);
    flowModRule.setIdleTimeout((short) 0);
    flowModRule.setBufferId(-1);

    int count = 0;

    int actionOutputLength;

    if (this.dropPortGroup) {
      actionOutputLength = 0;
    } else {
      actionOutputLength = OFActionOutput.MINIMUM_LENGTH;
    }

    for (OFRule rule : this.groupRules) {
      count++;

      flowModRule.setMatch(rule.getMatch());
      if (!this.dropPortGroup) {
        // add mirroring capabitlites

        HashMap<Short, Short> switchMirrors = flowscaleController
            .getSwitchFlowMirrorPortsHashMap().get(
                outputSwitch.getId());

        if (switchMirrors != null) {
          FlowscaleController.logger.debug("Mirror hashmap {}",
              switchMirrors.toString());
          OFActionOutput actionPort = null;
          try {
            FlowscaleController.logger.debug("Mirror actions = {}",
                rule.getActions());
            if (rule.getActions() != null) {

              actionPort = ((OFActionOutput) rule.getActions()
                  .get(0));

              FlowscaleController.logger.debug(
                  "Action port for Mirror is {}",
                  actionPort.getPort());
            }
            Short mirrorPortValue = switchMirrors.get(actionPort
                .getPort());
            if (mirrorPortValue != null) {
              FlowscaleController.logger
                  .debug("mirror {} for switch {} set ",
                      actionPort.getPort()
                          + ","
                          + mirrorPortValue
                              .toString(),
                      HexString.toHexString(outputSwitch
                          .getId()));
              rule.setMirrorPort(mirrorPortValue);
            }

          } catch (NumberFormatException nfe) {
            FlowscaleController.logger.error(
                "OFAction {} is not directed to a switch port",
                flowModRule.getActions().get(0).toString());
          }

        }

        // after checking mirrors set actions
        flowModRule.setActions(rule.getActions());
      }
      flowModRule.setLength(U16.t(OFFlowMod.MINIMUM_LENGTH
          + actionOutputLength));
      flowModRule.setPriority(rule.getPriority());

      try {
        FlowscaleController.logger.debug("{}", flowModRule);
        outputSwitch.getOutputStream().write(flowModRule);
        if (count >= flowscaleController.getMaximumFlowsToPush()) {
          count = 0;

          outputSwitch.getOutputStream().flush();

          Thread.sleep(5000);

        }
      } catch (InterruptedException interruptedException) {
        FlowscaleController.logger.error("{}", interruptedException);
      } catch (IOException e) {
        // TODO Auto-generated catch block
        FlowscaleController.logger.error("{}", e);
      }

    }

    try {

      outputSwitch.getOutputStream().flush();

    } catch (Exception e) {
      FlowscaleController.logger.error("{}", e);
    }
View Full Code Here

   * @param updateValue
   */
  public void editGroup(String updateType, String updateValue) {

    String[] updateValues = updateValue.split(",");
    IOFSwitch sw = flowscaleController.getIBeaconProvider().getSwitches()
        .get(this.inputSwitchDatapathId);
    int i = 0;

    if (updateType.equals("values")) {

View Full Code Here

TOP

Related Classes of net.beaconcontroller.core.IOFSwitch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.