@Override public void run() { if (sw.getRole() == RoleState.MASTER) { log.trace("Collecting stats for {}", sw.getStringId()); OFTableStatsRequest request = sw.factory().buildTableStatsRequest() .build(); sw.sendMsg(request); } } }
private void connectInitialDevices() { for (OpenFlowSwitch sw : controller.getSwitches()) { try { listener.switchAdded(new Dpid(sw.getId())); } catch (Exception e) { LOG.warn("Failed initially adding {} : {}", sw.getStringId(), e.getMessage()); LOG.debug("Error details:", e); // disconnect to trigger switch-add later sw.disconnectSwitch(); } PortStatsCollector psc = new PortStatsCollector(sw, portStatsPollFrequency); psc.start(); collectors.put(new Dpid(sw.getId()), psc); } }
@Override public void run() { if (sw.getRole() == RoleState.MASTER) { log.trace("MidFlowsTask Collecting AdaptiveStats for {}", sw.getStringId()); // skip collecting because CalAndShortFlowsTask collects entire flow stats from a given switch sw if (callCountMidFlowsTask == ENTIRE_POLL_TIMES) { callCountMidFlowsTask = MID_POLL_TIMES; } else { midFlowsTaskInternal(); callCountMidFlowsTask += MID_POLL_TIMES; } } } }
private void connectInitialDevices() { for (OpenFlowSwitch sw: controller.getSwitches()) { try { listener.switchAdded(new Dpid(sw.getId())); } catch (Exception e) { log.warn("Failed initially adding {} : {}", sw.getStringId(), e.getMessage()); log.debug("Error details:", e); } } }
private void removeRule(FlowRule flowRule) { Dpid dpid = Dpid.dpid(flowRule.deviceId().uri()); OpenFlowSwitch sw = controller.getSwitch(dpid); if (sw == null) { return; } FlowRuleExtPayLoad flowRuleExtPayLoad = flowRule.payLoad(); if (hasPayload(flowRuleExtPayLoad)) { OFMessage msg = new ThirdPartyMessage(flowRuleExtPayLoad.payLoad()); sw.sendMsg(msg); return; } sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), Optional.empty(), Optional.of(driverService)).buildFlowDel()); if (adaptiveFlowSampling) { // Remove TypedFlowEntry to deviceFlowEntries in NewAdaptiveFlowStatsCollector NewAdaptiveFlowStatsCollector collector = afsCollectors.get(dpid); if (collector != null) { collector.removeFlows(flowRule); } } }
private void ofFlowStatsRequestAllSend() { OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest() .setMatch(sw.factory().matchWildcardAll()) .setTableId(TableId.ALL) .setOutPort(OFPort.NO_MASK) .build(); synchronized (this) { // set the request xid to check the reply in OpenFlowRuleProvider // After processing the reply of this request message, // this must be set to NO_FLOW_MISSING_XID(-1) by provider setFlowMissingXid(request.getXid()); log.debug("ofFlowStatsRequestAllSend: request={}, dpid={}", request.toString(), sw.getStringId()); sw.sendMsg(request); } }
/** * Sends port statistic request to switch. */ private void sendPortStatistic() { if (sw.getRole() != RoleState.MASTER) { return; } Long statsXid = xidAtomic.getAndIncrement(); OFPortStatsRequest statsRequest = sw.factory().buildPortStatsRequest() .setPortNo(OFPort.ANY) .setXid(statsXid) .build(); sw.sendMsg(statsRequest); }
@Override public void changePortState(DeviceId deviceId, PortNumber portNumber, boolean enable) { final Dpid dpid = dpid(deviceId.uri()); OpenFlowSwitch sw = controller.getSwitch(dpid); if (sw == null || !sw.isConnected()) { LOG.error("Failed to change portState on device {}", deviceId); return; } OFPortMod.Builder pmb = sw.factory().buildPortMod(); OFPort port = OFPort.of((int) portNumber.toLong()); pmb.setPortNo(port); if (enable) { pmb.setConfig(0x0); // port_down bit 0 } else { pmb.setConfig(0x1); // port_down bit 1 } pmb.setMask(0x1); pmb.setAdvertise(0x0); for (OFPortDesc pd : sw.getPorts()) { if (pd.getPortNo().equals(port)) { pmb.setHwAddr(pd.getHwAddr()); break; } } sw.sendMsg(Collections.singletonList(pmb.build())); }
@Override public void triggerProbe(DeviceId deviceId) { LOG.debug("Triggering probe on device {}", deviceId); final Dpid dpid = dpid(deviceId.uri()); OpenFlowSwitch sw = controller.getSwitch(dpid); if (sw == null || !sw.isConnected()) { LOG.error("Failed to probe device {} on sw={}", deviceId, sw); providerService.deviceDisconnected(deviceId); return; } else { LOG.trace("Confirmed device {} connection", deviceId); } // Prompt an update of port information. We can use any XID for this. OFFactory fact = sw.factory(); switch (fact.getVersion()) { case OF_10: sw.sendMsg(fact.buildFeaturesRequest().setXid(0).build()); break; case OF_13: sw.sendMsg(fact.buildPortDescStatsRequest().setXid(0).build()); break; default: LOG.warn("Unhandled protocol version"); } }
public synchronized void stop() { log.debug("Stopping Table Stats collection thread for {}", sw.getStringId()); task.cancel(); task = null; }
.set(AnnotationKeys.PROTOCOL, sw.factory().getVersion().toString()) .set(AnnotationKeys.CHANNEL_ID, sw.channelId()) .set(AnnotationKeys.MANAGEMENT_ADDRESS, sw.channelId().split(":")[0]) .build(); new DefaultDeviceDescription(did.uri(), sw.deviceType(), sw.manufacturerDescription(), sw.hardwareDescription(), sw.softwareDescription(), sw.serialNumber(), cId, annotations); providerService.deviceConnected(did, description);
@Override public void write(Dpid dpid, OFMessage msg) { this.getSwitch(dpid).sendMsg(msg); }
@Override public Dpid dpid() { checkPermission(PACKET_READ); return new Dpid(sw.getId()); }
private void applyRule(FlowRule flowRule) { Dpid dpid = Dpid.dpid(flowRule.deviceId().uri()); OpenFlowSwitch sw = controller.getSwitch(dpid); if (sw == null) { return; } FlowRuleExtPayLoad flowRuleExtPayLoad = flowRule.payLoad(); if (hasPayload(flowRuleExtPayLoad)) { OFMessage msg = new ThirdPartyMessage(flowRuleExtPayLoad.payLoad()); sw.sendMsg(msg); return; } sw.sendMsg(FlowModBuilder.builder(flowRule, sw.factory(), Optional.empty(), Optional.of(driverService)).buildFlowAdd()); if (adaptiveFlowSampling) { // Add TypedFlowEntry to deviceFlowEntries in NewAdaptiveFlowStatsCollector NewAdaptiveFlowStatsCollector collector = afsCollectors.get(dpid); if (collector != null) { collector.addWithFlowRule(flowRule); } } }
private void ofFlowStatsRequestFlowSend(FlowEntry fe) { Match match = FlowModBuilder.builder(fe, sw.factory(), Optional.empty(), Optional.of(driverService)).buildMatch(); OFFlowStatsRequest request = sw.factory().buildFlowStatsRequest() .setMatch(match) .setTableId(tableId) log.debug("ofFlowStatsRequestFlowSend: previous FlowStatsRequestAll does not be processed yet," + " set no flow missing xid anyway, for {}", sw.getStringId()); setFlowMissingXid(NO_FLOW_MISSING_XID); sw.sendMsg(request);
public synchronized void stop() { log.debug("Stopping Stats collection thread for {}", sw.getStringId()); task.cancel(); task = null; }
private OFPacketOut packetOut(OpenFlowSwitch sw, byte[] eth, OFPort out) { OFPacketOut.Builder builder = sw.factory().buildPacketOut(); OFAction act = sw.factory().actions() .buildOutput() .setPort(out) .build(); return builder .setBufferId(OFBufferId.NO_BUFFER) .setInPort(OFPort.CONTROLLER) .setActions(Collections.singletonList(act)) .setData(eth) .build(); }
@Override public void run() { if (sw.getRole() == RoleState.MASTER) { log.trace("LongFlowsTask Collecting AdaptiveStats for {}", sw.getStringId()); // skip collecting because CalAndShortFlowsTask collects entire flow stats from a given switch sw if (callCountLongFlowsTask == ENTIRE_POLL_TIMES) { callCountLongFlowsTask = LONG_POLL_TIMES; } else { longFlowsTaskInternal(); callCountLongFlowsTask += LONG_POLL_TIMES; } } } }
@Override public void send() { checkPermission(PACKET_WRITE); if (block() && isBuilt.get()) { sw.sendMsg(pktout); } }