@Override public List<AjtColumnInfo<Demand>> getNonBasicUserDefinedColumnsVisibleOrNot() { final List<AjtColumnInfo<Demand>> res = new LinkedList<> (); res.add(new AjtColumnInfo<Demand>(this , Node.class, null , "A", "Ingress node", null , d->d.getIngressNode() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Demand>(this , Node.class, null , "B", "Egress node", null , d->d.getEgressNode() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Demand>(this , Demand.class, null , "Bidirectional pair", "If the demand is bidirectional, provides its bidirectional pair", null , d->d.getBidirectionalPair() , AGTYPE.NOAGGREGATION, null)); res.add(new AjtColumnInfo<Demand>(this , Link.class, null , "Link coupled", "The link that this demand is coupled to (in this or other layer)", null , d->d.getCoupledLink() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Demand>(this , Double.class, null , "Offered traffic (" + getTableNetworkLayer().getLinkCapacityUnits() + ")", "Offered traffic by the demand", (d,val)->d.setOfferedTraffic((Double) val), d->d.getOfferedTraffic() , AGTYPE.SUMDOUBLE , null)); res.add(new AjtColumnInfo<Demand>(this , Double.class, null , "Carried traffic (" + getTableNetworkLayer().getLinkCapacityUnits() + ")", "Carried traffic by the demand", null , d->d.getCarriedTraffic() , AGTYPE.SUMDOUBLE , null)); res.add(new AjtColumnInfo<Demand>(this , Double.class, null , "% Lost traffic", "Percentage of the lost traffic by the demand", null, d->d.getOfferedTraffic() == 0? 0 : d.getBlockedTraffic() / d.getOfferedTraffic() , AGTYPE.NOAGGREGATION , d->d.getBlockedTraffic() > 0? Color.RED : Color.GREEN)); res.add(new AjtColumnInfo<Demand>(this , String.class, null , "QoS type", "A used-defined string identifying the type of traffic of the demand", (d,val)-> d.setQoSType((String)val) , d->d.getQosType(), AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Demand>(this , Boolean.class, null , "Source routing?", "", (d,val)->d.setRoutingType((Boolean) val? RoutingType.SOURCE_ROUTING : RoutingType.HOP_BY_HOP_ROUTING), d->d.isSourceRouting() , AGTYPE.COUNTTRUE , null)); res.add(new AjtColumnInfo<Demand>(this , Boolean.class, null , "Is service chain?", "", null, d->d.isServiceChainRequest() , AGTYPE.COUNTTRUE , null)); res.add(new AjtColumnInfo<Demand>(this , String.class, null , "Resource types", "The sequence of resource types that has to be traversed by the routes of the demand, if it is a service chain", null, d->d.isSourceRouting()? d.getServiceChainSequenceOfTraversedResourceTypes().stream().collect(Collectors.joining(",")) : "" , AGTYPE.COUNTTRUE , null)); res.add(new AjtColumnInfo<Demand>(this , String.class, null , "Routing cycles", "Indicates whether there are routing cycles: loopless (no cycle in some route), open cycles (traffic reaches egress node after some cycles in some route), closed cycles (traffic does not reach the egress node in some route)", null, d->d.getRoutingCycleType().name() , AGTYPE.NOAGGREGATION , d->d.getRoutingCycleType() == RoutingCycleType.LOOPLESS? null : Color.ORANGE)); res.add(new AjtColumnInfo<Demand>(this , String.class, null , "Bifurcated?", "Indicates whether the demand is satisfied by more than one path from origin to destination", null, d->!d.isSourceRouting() ? "-" : (d.isBifurcated()) ? String.format("Yes (%d)", d.getRoutes().size()) : "No" , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Demand>(this , Integer.class, null , "# routes", "Number of associated routes", null, d->!d.isSourceRouting() ? 0 : d.getRoutes().size() , AGTYPE.SUMINT, null)); res.add(new AjtColumnInfo<Demand>(this , Double.class, null , "Worst e2e lat (ms)", "Current worst case end-to-end propagation time in miliseconds (accumulating any lower layer propagation times if any)", null, d->d.getWorstCasePropagationTimeInMs() , AGTYPE.NOAGGREGATION , d->{ final double maxMs = d.getMaximumAcceptableE2EWorstCaseLatencyInMs(); return maxMs <= 0? null : (d.getWorstCasePropagationTimeInMs() > maxMs? Color.RED : null); })); res.add(new AjtColumnInfo<Demand>(this , Double.class, null , "Worst e2e length (km)", "Current worst case end-to-end propagation length in km (accumulating any lower layer propagation lengths if any)", null, d->d.getWorstCaseLengthInKm() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Demand>(this , Double.class, null , "Limit e2e lat (ms)", "Maximum end-to-end propagation time in miliseconds (accumulating any lower layer propagation times if any)", (d,val)-> d.setMaximumAcceptableE2EWorstCaseLatencyInMs((Double)val) , d->d.getMaximumAcceptableE2EWorstCaseLatencyInMs() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Demand>(this , Double.class, null , "CAGR(%)" , "Compound annual growth factor for this demand", (d,val)->d.setOfferedTrafficPerPeriodGrowthFactor((Double) val), d->d.getOfferedTrafficPerPeriodGrowthFactor() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<Demand>(this , Integer.class, null , "#Monit points" , "Number of samples of the offered traffic stored, coming from a monitoring or forecasting traffic process", null , d->d.getMonitoredOrForecastedOfferedTraffic().getSize() , AGTYPE.NOAGGREGATION , null)); return res; }
@Override public String toString() { return "Generate fast fluctuation of offered traffic of demand " + demand.getId () ; } }
/** * Constructor to generate a new {@code LightpathAdd} object. * @param demand Demand * @param lineRateGbps Line rate in Gbps */ public LightpathAdd(Demand demand, double lineRateGbps) { this.demand = demand; this.primaryRSA = null; this.lineRateGbps = lineRateGbps; this.backupRSA = null; this.ingressNode = demand.getIngressNode(); this.egressNode = demand.getEgressNode(); this.layer = demand.getLayer(); }
/** * Creates a demand in the opposite direction as this, and with the same attributes, and associate both as bidirectional pairs. * If this demand is already bidirectional, makes nothing and returns null * @return the newly created demand */ public Demand createBidirectionalPair () { checkAttachedToNetPlanObject(); if (this.isBidirectional()) return null; final Demand d = netPlan.addDemand(this.ingressNode, this.egressNode, this.getOfferedTraffic() , this.routingType , this.attributes, this.layer); this.bidirectionalPair = d; d.bidirectionalPair = this; return d; }
SortedSet<Link> getIntraLayerUpPropagationIncludingMe () { final SortedSet<Link> res = new TreeSet<> (); res.add(this); for (Demand d : Sets.union(this.cacheHbH_frs.keySet() , cache_traversingRoutes.keySet().stream().map(r->r.getDemand()).collect(Collectors.toSet()))) if (d.isCoupledInSameLayer()) { final Link upCoupledLink = d.getCoupledLink(); if (!res.contains(upCoupledLink)) { final SortedSet<Link> upperLinks = upCoupledLink.getIntraLayerUpPropagationIncludingMe(); res.addAll(upperLinks); } } return res; }
e.remove(); for (Demand e : new ArrayList<> (this.getDemands(thisLayer))) if (nodesThis_thisAndOther.contains(e.getIngressNode()) && nodesThis_thisAndOther.contains(e.getEgressNode())) e.remove(); for (MulticastDemand e : new ArrayList<> (this.getMulticastDemands(thisLayer))) if (nodesThis_thisAndOther.contains(e.getIngressNode()) && nodesThis_thisAndOther.containsAll(e.getEgressNodes())) if (this.getDemandFromId(otherDemand.getId()) != null) throw new RuntimeException(); final Node this_ae = (Node)thatToThisTranslation.get(otherDemand.getIngressNode()); final Node this_be = (Node)thatToThisTranslation.get(otherDemand.getEgressNode()); final Demand thisDemand = this.addDemand(this_ae, this_be, 0, otherDemand.getRoutingType() , null, thisLayer); thatToThisTranslation.put(otherDemand,thisDemand); thisDemand.setOfferedTraffic(otherDemand.getOfferedTraffic()); thisDemand.setRoutingType(otherDemand.getRoutingType()); thisDemand.setIntendedRecoveryType(otherDemand.getIntendedRecoveryType()); thisDemand.setAttributeMap(otherDemand.getAttributes()); // previous attributes are not removed, just new added or existing updated for (String tag : otherDemand.getTags()) thisDemand.addTag(tag); if (thisDemand.isSourceRouting()) thisDemand.setServiceChainSequenceOfTraversedResourceTypes(otherDemand.getServiceChainSequenceOfTraversedResourceTypes()); for (Route other : otherDemand.getRoutes()) for (Route backupOther : otherDemand.getRoutesAreBackup()) thisDemand.removeAllForwardingRules(); final SortedMap<Pair<Demand,Link>,Double> otherFrs = otherDemand.getForwardingRules(); final List<Demand> frDemands = new ArrayList<> (otherFrs.size()); final List<Link> frLinks = new ArrayList<> (otherFrs.size());
final NetPlan np = d.getNetPlan(); final NetworkLayer layer = d.getLayer(); final List<Triple<String,String,String>> res = new ArrayList <> (); final RoutingCycleType cycleType = d.getRoutingCycleType(); final boolean isLoopless = cycleType.equals(RoutingCycleType.LOOPLESS); res.add(Triple.of("Demand index/id" , "Demand " + d.getIndex() + " (id " + d.getId() + ")", "demand" + d.getId())); res.add(Triple.of("Layer" , "" + getLayerName(layer) , "layer" + layer.getId())); res.add(Triple.of("Offered traffic" , "" + df.format(d.getOfferedTraffic()) , "")); res.add(Triple.of("Carried traffic" , "" + df.format(d.getCarriedTraffic()) , "")); res.add(Triple.of("Lost traffic" , "" + df.format(d.getBlockedTraffic()) , "")); res.add(Triple.of("Is coupled?" , "" + d.isCoupled() , "")); if (d.isCoupled()) final Link coupledLink = d.getCoupledLink(); res.add(Triple.of("- Upper layer coupled to", getLayerName(coupledLink.getLayer()) , "")); res.add(Triple.of("- Coupled to", "Link " + coupledLink.getIndex() + " (id " + coupledLink.getId() + ")" , "link" + coupledLink.getId())); res.add(Triple.of("Is service chain?" , "" + d.isServiceChainRequest(), "")); if (d.isServiceChainRequest()) res.add(Triple.of("- Seq. resource types" , StringUtils.join(d.getServiceChainSequenceOfTraversedResourceTypes(),","), "")); res.add(Triple.of("Has loops?" , isLoopless? "No" : cycleType.equals(RoutingCycleType.CLOSED_CYCLES)? "Yes (closed loops)" : "Yes (open loops)", "")); if(d.getRoutingType() == Constants.RoutingType.SOURCE_ROUTING) res.add(Triple.of("Num. routes (total/backup)" , "" + d.getRoutes().size() + "/" + d.getRoutesAreBackup().size(), "")); for (Route r : d.getRoutes()) res.add(Triple.of("Route index/id" , "Route " + r.getIndex() + " (id " + r.getId() + ")" + (r.isBackupRoute()? " [backup]" : ""), "route" + r.getId())); double latency_ms = (d.getWorstCasePropagationTimeInMs() == Double.MAX_VALUE) ? Double.POSITIVE_INFINITY : d.getWorstCasePropagationTimeInMs(); res.add(Triple.of("Worst case e2e latency (ms)" , df.format(latency_ms), ""));
this.ipLayer = netPlan.addLayer("IP" , "IP layer" , "Gbps" , "Gbps" , null , null); for (Demand wdmDemand : netPlan.getDemands(wdmLayer)) netPlan.addDemand(wdmDemand.getIngressNode(), wdmDemand.getEgressNode() , wdmDemand.getOfferedTraffic() , RoutingType.HOP_BY_HOP_ROUTING , wdmDemand.getAttributes() , ipLayer); for (Demand ipDemand : netPlan.getDemands(ipLayer)) final Pair<Node,Node> nodePair = Pair.of(ipDemand.getIngressNode() , ipDemand.getEgressNode()); boolean atLeastOnePathOrPathPair = false; List<Integer> pathListThisDemand = new LinkedList<Integer> (); ipDemand.setRoutingType(RoutingType.SOURCE_ROUTING); if (best_pathIndex == -1) { ipDemandIndexesNotToTry.add(ipDemand.getIndex()); continue; } totalCost += cost_p.get(best_pathIndex); final Demand newWDMDemand = netPlan.addDemand(best_rsa.ingressNode , best_rsa.egressNode , lineRate_p.get(best_pathIndex) , RoutingType.SOURCE_ROUTING , null , wdmLayer); newWDMDemand.setIntendedRecoveryType(recoveryTypeNewLps); final Route lp = WDMUtils.addLightpath(newWDMDemand , best_rsa , lineRate_p.get(best_pathIndex)); final Link ipLink = newWDMDemand.coupleToNewLinkCreated(ipLayer); final double ipTrafficToCarry = Math.min(lineRate_p.get(best_pathIndex) , ipDemand.getBlockedTraffic()); netPlan.addRoute(ipDemand , ipTrafficToCarry , ipTrafficToCarry , Arrays.asList(ipLink), null); WDMUtils.allocateResources(best_rsa , frequencySlot2FiberOccupancy_se , null);
final List<AjtRcMenu> res = new ArrayList<> (); res.add(new AjtRcMenu("Add demand", e->createLinkDemandGUI(NetworkElementType.DEMAND, getTableNetworkLayer () , callback), (a,b)->true, null)); res.add(new AjtRcMenu("Remove selected demands", e->getSelectedElements().forEach(dd->((Demand)dd).remove()) , (a,b)->b>0, null)); res.add(new AjtRcMenu("Set QoS type to selected demands", e-> getSelectedElements().forEach(dd->dd.setQoSType(qos)); getSelectedElements().forEach(dd->dd.setRoutingType(routingType)); getSelectedElements().forEach(dd->((Demand)dd).setMaximumAcceptableE2EWorstCaseLatencyInMs(newLimit)); callback.getWhatIfAnalysisPane().whatIfDemandOfferedTrafficModified(changedDemands, Collections.nCopies(changedDemands.size(), newOfferedTraffic)); else changedDemands.forEach(d->d.setOfferedTraffic(newOfferedTraffic)); callback.getWhatIfAnalysisPane().whatIfDemandOfferedTrafficModified(changedDemands, changedDemands.stream().map(d-> new Double ((d.getOfferedTraffic () * neScalingFactor))).collect(Collectors.toList())); else changedDemands.forEach(d->d.setOfferedTraffic(d.getOfferedTraffic() * neScalingFactor)); } catch (Throwable ex) { ex.printStackTrace(); throw new Net2PlanException (ex.getMessage()); } if (!selectedDemand.getRoutes().isEmpty()) throw new Net2PlanException("It is not possible to set the resource types traversed to demands with routes"); selectedDemand.setServiceChainSequenceOfTraversedResourceTypes(newTraversedResourcesTypes); if (!d.isCoupled()) d.coupleToNewLinkCreated(np.getNetworkLayerFromId(layerId)); break;
for (Demand demand : demands.getDemands()) netPlan.addDemand(demand.getIngressNode(), demand.getEgressNode(), demand.getOfferedTraffic(), RoutingType.SOURCE_ROUTING , demand.getAttributes(), layer);
for (Demand d : npcopy.getDemands()) final int numChannels = (int) Math.round (d.getOfferedTraffic() / tcfa_circuitCapacity_Gbps.getDouble ()); for (int cont = 0 ; cont < numChannels ; cont ++) netPlan.addDemand(netPlan.getNodeFromId (d.getIngressNode().getId ()), netPlan.getNodeFromId (d.getEgressNode().getId ()), tcfa_circuitCapacity_Gbps.getDouble () , RoutingType.SOURCE_ROUTING , d.getAttributes()); this.routeList_d = new int [D][]; for (Demand d : netPlan.getDemands ()) routeList_d [d.getIndex ()] = getIndexes (d.getRoutes ()); this.traversedLinks_r = new int [R][]; for (Route r : netPlan.getRoutes ()) traversedLinks_r [r.getIndex ()] = getIndexes (r.getSeqLinks()); for (Demand d : netPlan.getDemands ()) if (d.getRoutes().isEmpty()) throw new Net2PlanException ("A demand has no assigned routes"); this.A_er = netPlan.getMatrixLink2RouteAssignment(); this.A_se = DoubleFactory2D.dense.make(1 + nSRGs , Efm , 1.0); // 1 if link OK, 0 if fails this.Abid_dd = DoubleFactory2D.sparse.make(D,D); for (Entry<Demand,Demand> entry : opposite_d.entrySet()) { Abid_dd.set(entry.getKey().getIndex (), entry.getValue().getIndex (), 1.0); Abid_dd.set(entry.getValue().getIndex (), entry.getKey().getIndex (), 1.0); } this.Abid_rr = DoubleFactory2D.sparse.make(R,R); for (Entry<Route,Route> entry : opposite_r.entrySet()) { Abid_rr.set(entry.getKey().getIndex (), entry.getValue().getIndex (), 1.0); Abid_rr.set(entry.getValue().getIndex (), entry.getKey().getIndex (), 1.0); } this.Abid_ee = DoubleFactory2D.sparse.make(Efm,Efm); for (Link e : netPlan.getLinks ()) { Abid_ee.set(e.getIndex (), oppositeLink(e).getIndex (), 1.0); Abid_ee.set(oppositeLink(e).getIndex (), e.getIndex (), 1.0); } for (Demand d : netPlan.getDemands ()) if (Math.abs(best_xr.viewSelection(routeList_d [d.getIndex ()]).zSum() - 1) > 1E-3) throw new RuntimeException ("Bad"); if (Math.abs(best_x2r.viewSelection(routeList_d [d.getIndex ()]).zSum() - 1) > 1E-3) throw new RuntimeException ("Bad"); Route primaryRoute = null; Route backupRoute = null; for (Route r : d.getRoutes ()) if (Math.abs(best_xr.get(r.getIndex ()) - 1) <= 1e-3) { primaryRoute = r; primaryRoute.setCarriedTraffic(tcfa_circuitCapacity_Gbps.getDouble () , tcfa_circuitCapacity_Gbps.getDouble ()); break; } for (Route r : d.getRoutes ()) if (Math.abs(best_x2r.get(r.getIndex ()) - 1) <= 1e-3) { backupRoute = r; backupRoute.setCarriedTraffic(0 , tcfa_circuitCapacity_Gbps.getDouble ()); break; } primaryRoute.addBackupRoute(backupRoute);
double[] T_d = new double [D]; for (Demand d : netPlan.getDemands()) for (Route r : d.getRoutes()) final double weightFactor = d.getCarriedTraffic() == 0? 0 : r.getCarriedTraffic() / d.getCarriedTraffic(); T_d_prop [d.getIndex()] += weightFactor * T_r_prop [r.getIndex()]; T_d_tx [d.getIndex()] += weightFactor * T_r_tx [r.getIndex()]; T_d_buf [d.getIndex()] += weightFactor * T_r_buf [r.getIndex()]; T_d [d.getIndex()] += weightFactor * T_r [r.getIndex()]; out.append(String.format("<tr><td>%d</td><td>%d</td><td>%d (%s)</td><td>%d (%s)</td><td>%s</td><td>%.3g</td><td>%.3g</td><td>%.3g</td><td>%.3g</td><td>%s</td></tr>", r.getIndex () , d.getIndex(), r.getIngressNode().getIndex() , r.getIngressNode().getName(), r.getEgressNode().getIndex() , r.getEgressNode().getName(), r.getSeqLinks(), T_r_prop[rIndex], T_r_tx[rIndex], T_r_buf[rIndex], T_r[rIndex], r.getAttributes())); for (Demand d : netPlan.getDemands()) final int dIndex = d.getIndex(); out.append(String.format("<tr><td>%d</td><td>%d (%s)</td><td>%d (%s)</td><td>%.3g</td><td>%.3g</td><td>%.3g</td><td>%.3g</td><td>%s</td></tr>", dIndex, d.getIngressNode().getIndex() , d.getIngressNode().getName(), d.getEgressNode().getIndex() , d.getEgressNode().getName(), T_d_prop[dIndex] , T_d_tx[dIndex] , T_d_buf[dIndex] , T_d[dIndex] , d.getAttributes()));
for (Demand pickedDemand : pickedDemands) final boolean isDemandLayerVisibleInTheCanvas = vs.isLayerVisibleInCanvas(pickedDemand.getLayer()); final GUINode gnOrigin = vs.getCanvasAssociatedGUINode(pickedDemand.getIngressNode(), pickedDemand.getLayer()); final GUINode gnDestination = vs.getCanvasAssociatedGUINode(pickedDemand.getEgressNode(), pickedDemand.getLayer()); thisLayerPropagation = pickedDemand.getLinksNoDownPropagationPotentiallyCarryingTraffic(); final SortedSet<Link> linksPrimary = thisLayerPropagation.getFirst(); final SortedSet<Link> linksBackup = thisLayerPropagation.getSecond(); thisLayerPropagation = pickedDemand.getLinksNoDownPropagationPotentiallyCarryingTraffic(); final Pair<SortedSet<Demand>, SortedSet<Pair<MulticastDemand, Node>>> downLayerInfoPrimary = DrawUtils.getDownCoupling(thisLayerPropagation.getFirst()); final Pair<SortedSet<Demand>, SortedSet<Pair<MulticastDemand, Node>>> downLayerInfoBackup = DrawUtils.getDownCoupling(thisLayerPropagation.getSecond()); DrawUtils.drawDownPropagationInterLayerLinks(vs, linksPrimaryAndBackup, VisualizationConstants.DEFAULT_REGGUILINK_EDGECOLOR_BACKUPANDPRIMARY); if (vs.isShowInCanvasUpperLayerPropagation() && (vs.getNetPlan().getNumberOfLayers() > 1) && pickedDemand.isCoupled()) final InterLayerPropagationGraph ipg = new InterLayerPropagationGraph(null, new TreeSet<> (Arrays.asList(pickedDemand.getCoupledLink())), null, true); DrawUtils.drawCollateralLinks(vs, ipg.getLinksInGraph(), VisualizationConstants.DEFAULT_REGGUILINK_EDGECOLOR_PICKED); DrawUtils.drawDownPropagationInterLayerLinks(vs, ipg.getLinksInGraph(), VisualizationConstants.DEFAULT_REGGUILINK_EDGECOLOR_PICKED);
private Pair<Map<Demand,Demand>,Map<Route,Route>> initializeNetPlanLinksBidirDemandsAndRoutes (NetPlan np) { /* Remove lower half demands from np */ np.removeAllRoutes(); for (Node n1 : np.getNodes()) for (Node n2 : np.getNodes()) if (n1.getIndex () > n2.getIndex ()) for (Demand d : np.getNodePairDemands(n1, n2,false)) d.remove (); np.addRoutesFromCandidatePathList(netPlan.computeUnicastCandidatePathList(null , tcfa_maxNumberPathsPerDemand.getInt(), tcfa_maxPathLengthInKm.getDouble(), tcfa_maxPathNumberOfHops.getInt(), -1, -1, -1, -1 , null)); /* Add symmetric demands and routes */ Map<Demand,Demand> opposite_d = new HashMap<Demand,Demand> (); Map<Route,Route> opposite_r = new HashMap<Route,Route> (); for (Demand d : new HashSet<Demand> (np.getDemands())) { final Demand opDemand = np.addDemand(d.getEgressNode(), d.getIngressNode(), d.getOfferedTraffic(), RoutingType.SOURCE_ROUTING , null); opposite_d.put(d,opDemand); opposite_d.put(opDemand,d); for (Route r : new HashSet<Route> (d.getRoutes ())) { final Route oppRoute = np.addRoute(opDemand, r.getCarriedTraffic(), r.getOccupiedCapacity() , oppositeSeqLinks (r.getSeqLinks()), null); opposite_r.put(r,oppRoute); opposite_r.put(oppRoute,r); } } return Pair.of(opposite_d,opposite_r); }
if (n1 != n2) final Demand d1 = netPlan.addDemand(n1, n2, 0.0, RoutingType.SOURCE_ROUTING , null); d1.setAttribute("type" , "1"); demandType.set(d1.getIndex (), 1); final Demand d2 = netPlan.addDemand(n1, n2, 0.0, RoutingType.SOURCE_ROUTING , null); d2.setAttribute("type" , "2"); demandType.set(d2.getIndex (), 2); arrayIndexesOfDemand1.add (d1.getIndex ()); arrayIndexesOfDemand2.add (d2.getIndex ()); final double thisDemand_hd = h_d.get(d.getIndex ()); d.setOfferedTraffic(thisDemand_hd); d.getRoutes().iterator().next().setCarriedTraffic(thisDemand_hd , thisDemand_hd); if (demandType.get(r.getDemand().getIndex ()) == 1) traf1 += r.getCarriedTraffic(); else traf2 += r.getCarriedTraffic(); if (traf1 > u_1.get (e.getIndex ()) + PRECISIONFACTOR) throw new RuntimeException ("Bad"); if (traf2 > u_2.get (e.getIndex ()) + PRECISIONFACTOR) throw new RuntimeException ("Bad"); for (Demand d : netPlan.getDemands()) final double thisDemand_hd = h_d.get(d.getIndex ()); if (d.getRoutes ().size() != 1) throw new RuntimeException ("Bad"); if (Math.abs (d.getCarriedTraffic() - d.getOfferedTraffic()) > 1e-3) throw new RuntimeException ("Bad"); if (demandType.get(d.getIndex ()) == 1) netUtil += cc_control_weightFairness_1.getDouble () * ((cc_control_fairnessFactor_1.getDouble () == 1)? Math.log(thisDemand_hd) : 1/(1-cc_control_fairnessFactor_1.getDouble ()) * Math.pow(thisDemand_hd, 1-cc_control_fairnessFactor_1.getDouble ())); else
private List<Triple<String,String,String>> getForwardingRuleInfoTables (Pair<Demand,Link> fr) { final DecimalFormat df = new DecimalFormat("###.##"); final Demand d = fr.getFirst(); final Link e = fr.getSecond(); final NetworkLayer layer = d.getLayer(); final NetPlan np = e.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); final String trafUnits = np.getDemandTrafficUnitsName(layer); final String capUnits = np.getLinkCapacityUnitsName(layer); res.add(Triple.of("Demand index/id" , "Demand " + d.getIndex() + " (id " + d.getId() + ")", "demand" + d.getId())); res.add(Triple.of("Link index/id" , "Link " + e.getIndex() + " (id " + e.getId() + ")", "link" + e.getId())); res.add(Triple.of("Splitting factor", "" + df.format(np.getForwardingRuleSplittingFactor(d,e)) , "")); res.add(Triple.of("Carried traffic", "" + df.format(np.getForwardingRuleCarriedTraffic(d,e)) + " " + trafUnits , "")); return res; } private List<Triple<String,String,String>> getRouteInfoTables (Route r)
for (Demand demand : np.getDemands(np.getNetworkLayerFromId(selectedLayerId))) if (demand.isCoupled()) continue; long ingressNodeId = demand.getIngressNode().getId(); long egressNodeId = demand.getEgressNode().getId(); String ingressNodeName = demand.getIngressNode().getName(); String egressNodeName = demand.getEgressNode().getName(); demandSelector.addItem(StringLabeller.unmodifiableOf(demand.getId(), "d" + demand.getId() + " [n" + ingressNodeId + " (" + ingressNodeName + ") -> n" + egressNodeId + " (" + egressNodeName + ")]")); final Demand demand = np.getDemandFromId(demandId); final Link link = getSelectedElements().first(); demand.coupleToUpperOrSameLayerLink(link); break;
private List<Triple<String,String,String>> getRouteInfoTables (Route r) { final DecimalFormat df = new DecimalFormat("###.##"); final NetPlan np = r.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); res.add(Triple.of("Route index/id" , "Route " + r.getIndex() + " (id " + r.getId() + ")", "route" + r.getId())); res.add(Triple.of("Layer" , "" + getLayerName(r.getLayer()) , "layer" + r.getLayer().getId())); res.add(Triple.of("Route demand index/id" , "" + r.getDemand().getIndex() + " (id " + r.getDemand().getId() + ")" , "demand" + r.getDemand().getId())); res.add(Triple.of("Demand offered traffic" , "" + df.format(r.getDemand().getOfferedTraffic()) + " " + np.getDemandTrafficUnitsName(r.getLayer()) , "")); res.add(Triple.of("Demand carried traffic" , "" + df.format(r.getDemand().getCarriedTraffic()) + " " + np.getDemandTrafficUnitsName(r.getLayer()) , "")); res.add(Triple.of("Route carried traffic" , "" + df.format(r.getCarriedTraffic()) + " " + np.getDemandTrafficUnitsName(r.getLayer()), "")); res.add(Triple.of("Is up?" , "" + np.isUp(r.getPath()), "")); res.add(Triple.of("Worst link utilization" , "" + df.format(r.getSeqLinks().stream().mapToDouble(e->e.getUtilization()).max().orElse(0)), "")); if (r.isServiceChain()) res.add(Triple.of("Worst resource utilization" , "" + df.format(r.getSeqResourcesTraversed().stream().mapToDouble(e->e.getUtilization()).max().orElse(0)), "")); res.add(Triple.of("Is service chain?" , "" + r.getDemand().isServiceChainRequest(), "")); res.add(Triple.of("Route length (km)" , "" + df.format(r.getLengthInKm()) + " km", "")); res.add(Triple.of("Route length (ms)" , "" + df.format(r.getPropagationDelayInMiliseconds()) + " ms", "")); res.add(Triple.of("Is backup route?" , "" + r.isBackupRoute(), "")); for (Route pr : r.getRoutesIAmBackup()) res.add(Triple.of("-- Primary route" , "Route " + pr.getIndex() , "route" + pr.getId())); res.add(Triple.of("Has backup routes?" , "" + r.hasBackupRoutes(), "")); for (Route br : r.getBackupRoutes()) res.add(Triple.of("-- Backup route" , "Route " + br.getIndex() , "route" + br.getId())); return res; } private List<Triple<String,String,String>> getMulticastTreeInfoTables (MulticastTree t)
private void drawDemand(Graphics2D g2d) { final FontMetrics fontMetrics = g2d.getFontMetrics(); final int regularInterlineSpacePixels = fontMetrics.getHeight(); final Demand demand = forwardingRule.getFirst(); final Node demandIngress = demand.getIngressNode(); final Node demandEgress = demand.getEgressNode(); final DrawNode ingressNode = new DrawNode(demandIngress, demand.getLayer(), maxIconSize); final DrawNode egressNode = new DrawNode(demandEgress, demand.getLayer(), maxIconSize); textRow = addIconJump(iconRow); textRow = addLineJump(textRow); textRow = addLineJump(textRow); iconRow = addLineJump(textRow); int topCoordinateLineNodes = maxIconSize + (generalMessage.size() * regularInterlineSpacePixels) + (maxNumberOfTagsPerNodeNorResource * regularInterlineSpacePixels) * iconRow; Point initialDnTopLeftPosition = new Point(maxIconSize, topCoordinateLineNodes); int xSeparationDnCenters = maxIconSize * 3; g2d.setFont(headerFont); g2d.drawString("Demand " + demand.getIndex(), maxIconSize, maxIconSize + (regularInterlineSpacePixels * (textRow))); g2d.setFont(plainFont); DrawNode.addNodeToGraphics(g2d, ingressNode, initialDnTopLeftPosition, fontMetrics, regularInterlineSpacePixels, null); DrawNode.addNodeToGraphics(g2d, egressNode, new Point(initialDnTopLeftPosition.x + xSeparationDnCenters, initialDnTopLeftPosition.y), fontMetrics, regularInterlineSpacePixels, null); drawnNodes.add(ingressNode); drawnNodes.add(egressNode); final DrawLine demandDL = new DrawLine(ingressNode, egressNode, ingressNode.posEast(), egressNode.posWest()); DrawLine.addLineToGraphics(g2d, demandDL, fontMetrics, regularInterlineSpacePixels, lineStroke); }
Demand demand = netPlan.getDemandFromId(demandId); double h_d = demand.getOfferedTraffic(); double r_d = demand.getCarriedTraffic(); txt_carriedTraffic.setText(Double.toString(Math.max(0, h_d - r_d))); txt_occupiedCapacity.setText(Double.toString(Math.max(0, h_d - r_d))); seqLinks_pnl.removeAll(); Node ingressNode = demand.getIngressNode(); String ingressNodeName = ingressNode.getName(); Node ingressNode = demand.getIngressNode(); Node egressNode = demand.getEgressNode(); long ingressNodeId = ingressNode.getId(); long egressNodeId = egressNode.getId(); if (!egressNodeName.isEmpty()) demandLabel += " (" + egressNodeName + ")"; double h_d = demand.getOfferedTraffic(); double r_d = demand.getCarriedTraffic();