@Override public String toString() { if (this.nodeType.equals(NodeIDType.OPENFLOW)) { return this.nodeType + "|" + HexEncode.longToHexString((Long) this.nodeID); } else { return this.nodeType + "|" + this.nodeID.toString(); } }
/** * Getter for the node ID in string format * * @return The nodeID in string format */ @XmlElement(name = "id") public String getNodeIDString() { if (this.nodeType.equals(NodeIDType.OPENFLOW)) { return HexEncode.longToHexString((Long) this.nodeID); } else { return this.nodeID.toString(); } }
private void createFakeLLDPDataForSwitchIDChassisMapping(){ for(int i = 1; i <= fakeSwNum + fakeSwNum2; i++){ Long id = new Long(i); String chassis = HexEncode.longToHexString(new Long(i)); switches_ID2Chassis.put(id, chassis); switches_Chassis2ID.put(chassis, id); //System.out.println("Added LLDP data of chassis-to-swID mapping: chassis " + remoteChassis + " as switch ID " + HexEncode.stringToLong(remoteChassis)); } }
private void resolveProdPortsAndAddEdges(){//TODO: not yet check null for variables in this function... //System.out.println("==========================================="); //System.out.println("===== Resolve the PR ports, and add edges correspondingly ====="); //System.out.println("\tNumber of switches to resolve: " + portToRemoteChassisOnSwitches.size()); for(Map.Entry<Long, Map<Short, String>> entryS : portToRemoteChassisOnSwitches.entrySet()){ Long localSwitchID = entryS.getKey(); Map<Short, String> remotePortIDs = portToRemotePortIDOnSwitchesTmp.get(localSwitchID); //System.out.println(localSwitchID + "'s size3="+ remotePortIDs.size()); for(Map.Entry<Short, String> entryR : remotePortIDs.entrySet()){ //logger.trace("...compare with remote port of id: " + entryR.getValue()); Short localPortNum = entryR.getKey(); String remotePortID = entryR.getValue(); String remoteSwitchID = entryS.getValue().get(localPortNum); //TODO: the following line is specifically for OF which needs xx:xx:xx:xx:xx:xx:xx:xx format, can't deal with other case well remoteSwitchID = HexEncode.longToHexString(HexEncode.stringToLong(remoteSwitchID)); //Memo: no worry whether the port on/off state is updated before we call isPortUp(), the port on/off state is updated and saved before edge resolving starts (see in SwitchHandler.handleMessages(), processPortStatusMsg() is called before notifyMessageListener()) if(!isPortUp(localSwitchID, localPortNum)){ logger.trace("\t\tThe local port is DOWN, so ignore this edge (local switch {} port {}, remote switch {} port {})", localSwitchID, localPortNum, remoteSwitchID, remotePortID); break; } logger.trace("\t\tPR edge discovered: remote (ip " + remoteSwitchID + ", portID " + remotePortID +") --> local (ip " + localSwitchID + ", port " + localPortNum + ")"); addDiscoveredEdgeProdSrc(remoteSwitchID, remotePortID, localSwitchID, localPortNum); } } //System.out.println("===== end of Resolve the PR ports, and add edges correspondingly ====="); //System.out.println("================================================="); }
private void removeStatsRequestTasks(Long switchId) { log.debug("Cleaning Statistics database for switch {}", HexEncode.longToHexString(switchId)); // To be safe, let's attempt removal of both VENDOR and FLOW request. It // does not hurt pendingStatsRequests.remove(new StatsRequest(switchId, OFStatisticsType.VENDOR)); pendingStatsRequests.remove(new StatsRequest(switchId, OFStatisticsType.FLOW)); pendingStatsRequests.remove(new StatsRequest(switchId, OFStatisticsType.DESC)); pendingStatsRequests.remove(new StatsRequest(switchId, OFStatisticsType.PORT)); pendingStatsRequests.remove(new StatsRequest(switchId, OFStatisticsType.TABLE)); // Take care of the TX rate databases switchPortStatsUpdated.remove(switchId); txRates.remove(switchId); }
private void removeStatsRequestTasks(Long switchId) { log.info("Cleaning Statistics database for switch {}", HexEncode.longToHexString(switchId)); // To be safe, let's attempt removal of both VENDOR and FLOW request. It // does not hurt pendingStatsRequests.remove(new StatsRequest(switchId, OFStatisticsType.VENDOR)); pendingStatsRequests.remove(new StatsRequest(switchId, OFStatisticsType.FLOW)); pendingStatsRequests.remove(new StatsRequest(switchId, OFStatisticsType.DESC)); pendingStatsRequests.remove(new StatsRequest(switchId, OFStatisticsType.PORT)); pendingStatsRequests.remove(new StatsRequest(switchId, OFStatisticsType.TABLE)); // Take care of the TX rate databases switchPortStatsUpdated.remove(switchId); txRates.remove(switchId); }
switches_Chassis2ID.put(HexEncode.longToHexString((long)sw_i), new Long(sw_i)); Map<Short, String> localPortIDs = new HashMap<Short, String>(); for(short port_j = 1; port_j <= fakeSwPortNum; port_j++){ rc1.put(sw_i_port, HexEncode.longToHexString(sw_j + 1)); portToRemoteChassisOnSwitches.put(new Long(sw_i + 1), rc1); rc2.put(sw_j_port, HexEncode.longToHexString(sw_i + 1)); portToRemoteChassisOnSwitches.put(new Long(sw_j + 1), rc2);
switches_Chassis2ID.put(HexEncode.longToHexString((long)sw_i), new Long(sw_i)); Map<Short, String> localPortIDs = new HashMap<Short, String>(); for(short port_j = 1; port_j <= fakeSwPortNum2; port_j++){
String remoteChassis; if(swStr.indexOf(":") >= 0)//use input remoteChassisStr in hex format localChassis = HexEncode.longToHexString(HexEncode.stringToLong(swStr)); else localChassis = HexEncode.longToHexString(Long.parseLong(swStr)); if(remoteChassisStr.indexOf(":") >= 0)//use input remoteChassisStr in hex format remoteChassis = HexEncode.longToHexString(HexEncode.stringToLong(remoteChassisStr)); else remoteChassis = HexEncode.longToHexString(Long.parseLong(remoteChassisStr));
public void _ofbw(CommandInterpreter ci) { String sidString = ci.nextArgument(); Long sid = null; if (sidString == null) { ci.println("Insert the switch id (numeric value)"); return; } try { sid = Long.valueOf(sidString); } catch (NumberFormatException e) { ci.println("Invalid switch id. Has to be numeric."); } if (sid != null) { Map<Short, TxRates> thisSwitchRates = txRates.get(sid); ci.println("Bandwidth utilization (" + factoredSamples * portTickNumber + " sec average) for switch " + HexEncode.longToHexString(sid) + ":"); if (thisSwitchRates == null) { ci.println("Not available"); } else { for (Entry<Short, TxRates> entry : thisSwitchRates.entrySet()) { ci.println("Port: " + entry.getKey() + ": " + entry.getValue().getAverageTxRate() + " bps"); } } } }
public void _ofbw(CommandInterpreter ci) { String sidString = ci.nextArgument(); Long sid = null; if (sidString == null) { ci.println("Insert the switch id (numeric value)"); return; } try { sid = Long.valueOf(sidString); } catch (NumberFormatException e) { ci.println("Invalid switch id. Has to be numeric."); } if (sid != null) { Map<Short, TxRates> thisSwitchRates = txRates.get(sid); ci.println("Bandwidth utilization (" + factoredSamples * portTickNumber + " sec average) for switch " + HexEncode.longToHexString(sid) + ":"); if (thisSwitchRates == null) { ci.println("Not available"); } else { for (Entry<Short, TxRates> entry : thisSwitchRates.entrySet()) { ci.println("Port: " + entry.getKey() + ": " + entry.getValue().getAverageTxRate() + " bps"); } } } }
String remoteSwitchIDStr = HexEncode.longToHexString(HexEncode.stringToLong(remoteChassis)); myAddEdgeProdSrc(remoteSwitchIDStr, remotePortID, localSwitchID, localPortNum); return;
private RawPacket createDiscoveryPacket(NodeConnector nodeConnector) { String nodeId = HexEncode.longToHexString((Long) nodeConnector.getNode().getID());