@Override public NetPlan readFromFile(File file) { return new NetPlan(file); }
@Override public void filesDropped(File[] files) { for (File file : files) { try { if (!file.getName().toLowerCase(Locale.getDefault()).endsWith(".n2p")) return; checkNetPlanFileChooser(file.getParentFile()); NetPlan netPlan = new NetPlan(file); setNodeTableInfoFromNetPlan(netPlan); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error loading network structure"); } } } });
@Override public void filesDropped(File[] files) { try { Collection<NetPlan> netPlans = new LinkedList<NetPlan>(); for (int i = 0; i < files.length; i++) { if (i == 0) checkTrafficMatrixFileChooser(files[i].getParentFile()); netPlans.add(new NetPlan(files[i])); } loadTrafficMatrices(files, netPlans); } catch (Throwable ex) { ErrorHandling.showErrorDialog(ex.getMessage(), "Error loading matrix/matrices"); } } });
/** * Default constructor. * * @since 0.2.2 */ public SimKernel() { simCore = new SimCore(this); setNetPlan(new NetPlan ()); }
@Override public NetPlan readDemandSetFromFile(File file) { DoubleMatrix2D trafficMatrix = DoubleUtils.read2DMatrixFromFile(file); NetPlan netPlan = new NetPlan(); netPlan.setTrafficMatrix(trafficMatrix , RoutingType.SOURCE_ROUTING); return netPlan; }
/** * <p>Static factory method to get a {@link com.net2plan.interfaces.networkDesign.NetPlan NetPlan} object from a {@code .n2p} file.</p> * * @param file Input file * @return A network design */ public static NetPlan loadFromFile(File file) { try (InputStream inputStream = new FileInputStream(file)) { NetPlan np = new NetPlan(inputStream); if (ErrorHandling.isDebugEnabled()) np.checkCachesConsistency(); return np; } catch (FileNotFoundException e) { throw new Net2PlanException(e.getMessage()); } catch (IOException e) { throw new RuntimeException(e.getMessage()); } }
@Override public NetPlan readFromFile(File file) NetPlan netPlan = new NetPlan();
public static void main(String[] args) throws Exception { final NetPlan np = new NetPlan (); final Node n1 = np.addNode(0 , 0 , "name1" , null); final Node n2 = np.addNode(0 , 0 , "name2" , null); final Node n3 = np.addNode(0 , 0 , "name3" , null); final Link e12 = np.addLink(n1,n2,3,100,200000,null); final Link e23 = np.addLink(n2,n3,3,100,200000,null); final Resource r1 = np.addResource("CPU" , "nameRes1" , Optional.of(n1) , 10 , "Mbps" , null , 5 , null); final Resource r2 = np.addResource("RAM" , "nameRes2" , Optional.of(n2) , 10 , "Mbps" , null , 5 , null); final Demand d = np.addDemand(n1 , n3 , 0 , RoutingType.SOURCE_ROUTING , null); d.setServiceChainSequenceOfTraversedResourceTypes(Arrays.asList("CPU" , "RAM")); final Route r = np.addServiceChain(d , 2.0 , Arrays.asList(1.0,2.0,3.0,4.0) , Arrays.asList(r1,e12,r2,e23) , null); final NetworkLayer layer = np.getNetworkLayerDefault(); layer.setName("WDM"); JFrame frame = new JFrame("Example"); frame.getContentPane().setLayout(new FlowLayout()); frame.setPreferredSize(new Dimension (600,600)); //frame.add(new FigureLinkSequencePanel(r.getPath() , layer , r.getSeqOccupiedCapacitiesIfNotFailing() , "Route " + r.getIndex() , r.getCarriedTraffic())); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
/** * <p>Resets the state of the network to an empty {@code NetPlan}.</p> */ public void reset() { checkIsModifiable(); assignFrom(new NetPlan()); if (ErrorHandling.isDebugEnabled()) this.checkCachesConsistency(); }
NetPlan netPlan = new NetPlan(inputFile);
NetPlan netPlan = new NetPlan(); netPlan.setTrafficMatrix(trafficMatrix , RoutingType.SOURCE_ROUTING);
/** Creates an empty design with no nodes, links etc. * @return see above */ public static WNet createEmptyDesign () { final NetPlan np = new NetPlan (); np.getNetworkLayerDefault().setName("WDM"); np.addLayer("IP", "IP Layer", "", "", null, null); np.addNode(0, 0, WNetConstants.WNODE_NAMEOFANYCASTORIGINNODE , null); np.addNode(0, 0, WNetConstants.WNODE_NAMEOFANYCASTDESTINATION, null); final WNet res = new WNet (np); return res; }
/** * <p>Returns a deep copy of the current design.</p> * * @return Deep copy of the current design * @since 0.2.0 */ public NetPlan copy() { if (ErrorHandling.isDebugEnabled()) this.checkCachesConsistency(); NetPlan netPlan = new NetPlan(); if (ErrorHandling.isDebugEnabled()) netPlan.checkCachesConsistency(); netPlan.copyFrom(this); // System.out.println ("************** En el copy () *********************************************************"); if (ErrorHandling.isDebugEnabled()) netPlan.checkCachesConsistency(); return netPlan; }
NetPlan aux_netPlan = new NetPlan(inputFile); String html = runSimulation(new SimKernel(), aux_netPlan, aux_eventGenerator, customEventGeneratorParameters, aux_eventProcessor, customEventProcessorParameters, customSimulationParameters, net2planParameters).getSecond(); HTMLUtils.saveToFile(outputFile, html);
private void loadDesignFromFile(File file) { try { assert fc_netPlan != null; NetPlan netPlan = new NetPlan(file); fc_netPlan.setCurrentDirectory(file.getParentFile()); callback.setDesign(netPlan); final VisualizationState vs = callback.getVisualizationState(); Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> res = vs.suggestCanvasUpdatedVisualizationLayerInfoForNewDesign(new HashSet<>(callback.getDesign().getNetworkLayers())); vs.setCanvasLayerVisibilityAndOrder(callback.getDesign(), res.getFirst(), res.getSecond()); callback.updateVisualizationAfterNewTopology(); callback.addNetPlanChange(); } catch (Net2PlanException ex) { if (ErrorHandling.isDebugEnabled()) ErrorHandling.addErrorOrException(ex, TopologyPanel.class); ErrorHandling.showErrorDialog(ex.getMessage(), "Error loading network design"); } catch (Throwable ex) { ErrorHandling.addErrorOrException(ex, TopologyPanel.class); ErrorHandling.showErrorDialog("Error loading network design"); } }
DoubleMatrix2D thisIntervalTrafficMatrix = new NetPlan(new File (rootOfNameOfInputTrafficFiles.getString() + "_tm" + netPlanFiles.size () + ".n2p")).getMatrixNode2NodeOfferedTraffic(); NetPlan netPlanToAdd = netPlan.copy (); for (Demand d : netPlanToAdd.getDemands()) d.setOfferedTraffic(thisIntervalTrafficMatrix.get (d.getIngressNode().getIndex() , d.getEgressNode().getIndex()));
DoubleMatrix2D thisIntervalTrafficMatrix = new NetPlan(new File (rootOfNameOfInputTrafficFiles.getString() + "_tm" + netPlanFiles.size () + ".n2p")).getMatrixNode2NodeOfferedTraffic(); if (thisIntervalTrafficMatrix.rows () != N) throw new Net2PlanException ("The number of nodes in traffic matrix: " + rootOfNameOfInputTrafficFiles.getString() + "_tm" + netPlanFiles.size () + ".n2p (" + thisIntervalTrafficMatrix.rows() + ") is not correct (" + N + ")"); NetPlan netPlanToAdd = netPlan.copy ();
} else setDesign(new NetPlan());
private void createInitialTopology (NetPlan netPlan) netPlan.assignFrom(new NetPlan ()); final int num_o = aaa_numOrigins.getInt(); final int num_a = aaa_numDcs.getInt();