// Adding switches and hosts to the network public void AddSwitchesAndHostsToGraph() { for (Switch switch_ : switches.values()) { AddNodeToGraph(switch_.getInetAddress(), true); } for (Host host_ : hosts.values()) { AddNodeToGraph(host_.getIpv4().toString(), false); } }
// Adding Links to Classes and Graph public void AddLinksToClassesAndGraph() { String edgeInfo; Switch srcSwitch; Switch destSwitch; String srcIP = ""; String destIP = ""; for (Link link_ : links.values()) { edgeInfo = "(" + link_.getDirection() + ") SrcPort: " + link_.getSrc_port() + " => DestPort: " + link_.getDst_port(); srcSwitch = switches.get(link_.getSrc_switch()); destSwitch = switches.get(link_.getDst_switch()); destIP = srcSwitch.getInetAddress(); srcIP = destSwitch.getInetAddress(); if (link_.getDirection().equals("bidirectional")) { srcSwitch.getEdges().put(destIP, new OFEdge(destIP, link_.getDst_switch(), true)); AddEdgeToGraph(srcIP, destIP, edgeInfo, true, true); destSwitch.getEdges().put(srcIP, new OFEdge(srcIP, link_.getSrc_switch(), true)); AddEdgeToGraph(srcIP, destIP, edgeInfo, true, true); } else { srcSwitch.getEdges().put(destIP, new OFEdge(destIP, link_.getDst_switch(), true)); AddEdgeToGraph(srcIP, destIP, edgeInfo, true, true); } } String swID; for (Host host_ : hosts.values()) { for (int j = 0; j < host_.getAttachmentPoint().size(); j++) { swID = host_.getAttachmentPoint().get(j).getSwitchDPID(); destSwitch = switches.get(swID); edgeInfo = "DestPort: " + host_.getAttachmentPoint().get(j).getPort(); destSwitch.getEdges().put(host_.getIpv4(), new OFEdge(host_.getIpv4(), "", false)); host_ .getEdges() .put(destSwitch.getInetAddress(), new OFEdge(destSwitch.getInetAddress(), swID, true)); AddEdgeToGraph(host_.getIpv4(), destSwitch.getInetAddress(), edgeInfo, false, true); } } }