/** * <p>Returns the sum of the traffic carried by the {@link com.net2plan.interfaces.networkDesign.MulticastTree MulticastTree} traversing the link.</p> * @return The carried traffic (in traffic units) */ public double getMulticastCarriedTraffic() { double accum = 0; for (MulticastTree t : cache_traversingTrees) accum += t.getCarriedTraffic(); return accum; }
void checkCachesConsistency () { super.checkCachesConsistency (); double check_arriedTraffic = 0; for (MulticastTree t : cache_multicastTrees) { if (!t.demand.equals (this)) throw new RuntimeException ("Bad"); check_arriedTraffic += t.getCarriedTraffic(); } if (carriedTraffic != check_arriedTraffic) throw new RuntimeException ("Bad"); if (coupledUpperLayerLinks != null) for (Link e : coupledUpperLayerLinks.values ()) if (!e.coupledLowerLayerMulticastDemand.equals (this)) throw new RuntimeException ("Bad"); if (!layer.multicastDemands.contains(this)) throw new RuntimeException ("Bad"); }
@Override void checkCachesConsistency () { super.checkCachesConsistency (); if (!layer.multicastTrees.contains(this)) throw new RuntimeException ("Bad"); if (!demand.cache_multicastTrees.contains(this)) throw new RuntimeException ("Bad"); if (linkSet == null) throw new RuntimeException ("Multicast tree " + this + ", linkSet == null"); if (initialSetLinksWhenWasCreated == null) throw new RuntimeException ("Multicast Tree " + this + ", initialSetLinksWhenWasCreated == null"); netPlan.checkInThisNetPlanAndLayer(linkSet , layer); for (Link link : linkSet) if (!link.cache_traversingTrees.contains(this)) throw new RuntimeException ("Bad"); for (Node node : cache_traversedNodes) if (!node.cache_nodeAssociatedulticastTrees.contains(this)) throw new RuntimeException ("Bad"); boolean shouldBeUp = true; for (Link e : linkSet) if (!e.isUp) { shouldBeUp = false; break; } if (shouldBeUp) for (Node n : cache_traversedNodes) if (!n.isUp) { shouldBeUp = false; break; } if (!shouldBeUp != this.isDown()) throw new RuntimeException("Bad"); if (shouldBeUp) { if (getCarriedTraffic() != carriedTrafficIfNotFailing) throw new RuntimeException ("Bad"); } else { if (getCarriedTraffic() != 0) throw new RuntimeException ("Bad"); } }
/** Returns a map with an entry for each traversed link, and associated to it the demand's traffic carried in that link. * If selected by the user, the carried traffic is given as a fraction respect to the demand offered traffic * @param normalizedToOfferedTraffic see above * @return see above */ public SortedMap<Link, Double> getTraversedLinksAndCarriedTraffic(final boolean normalizedToOfferedTraffic) { final SortedMap<Link, Double> res = new TreeMap<>(); final double normalizationFactor = (normalizedToOfferedTraffic ? (offeredTraffic <= Configuration.precisionFactor ? 1.0 : 1 / offeredTraffic) : 1.0); for (MulticastTree r : getMulticastTrees()) for (Link e : r.getLinkSet()) { final Double currentVal = res.get(e); final double newValue = (currentVal == null ? 0 : currentVal) + (r.getCarriedTraffic() * normalizationFactor); res.put(e, newValue); } return res; }
/** * <p>Returns a vector with the carried traffic per multicast tree, at the given layer. i-th vector corresponds to i-th index of the element. If no layer is provided, the defaulf layer is assumed.</p> * * @param optionalLayerParameter network layer (optional) * @return The vector with the carried traffic per multicast tree */ public DoubleMatrix1D getVectorMulticastTreeCarriedTraffic(NetworkLayer... optionalLayerParameter) { NetworkLayer layer = checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); DoubleMatrix1D res = DoubleFactory1D.dense.make(layer.multicastTrees.size()); for (MulticastTree e : layer.multicastTrees) res.set(e.index, e.getCarriedTraffic()); return res; }
/** * <p>Returns the multicast demand-link incidence matrix (<i>D</i>x<i>E</i> in which an element <i>δ<sub>de</sub></i> is equal to the amount of traffic of * each multicast demand carried in each link). Rows * and columns are in increasing order of demand and link identifiers, respectively. If no layer is provided, the default layer is assumed</p> * <p><b>Important</b>: Routing type must be {@link com.net2plan.utils.Constants.RoutingType#HOP_BY_HOP_ROUTING HOP_BY_HOP_ROUTING}.</p> * * @param optionalLayerParameter Network layer (optional) * @return Splitting ratio matrix */ public DoubleMatrix2D getMatrixMulticastDemand2LinkTrafficCarried(NetworkLayer... optionalLayerParameter) { NetworkLayer layer = checkInThisNetPlanOptionalLayerParameter(optionalLayerParameter); DoubleMatrix2D x_de = DoubleFactory2D.sparse.make(layer.multicastDemands.size(), layer.links.size()); for (MulticastTree t : layer.multicastTrees) for (Link e : t.linkSet) x_de.set(t.demand.index, e.index, x_de.get(t.demand.index, e.index) + t.getCarriedTraffic()); return x_de; }
void updateLinkTrafficAndOccupation () { /* Add the info of the demands with traversing routes */ this.cache_totalCarriedTraffic = 0; this.cache_totalOccupiedCapacity = 0; for (Entry<Route,Integer> travRouteInfo : cache_traversingRoutes.entrySet()) { final Route r = travRouteInfo.getKey(); final double carriedTraffic = r.getCarriedTraffic(); final double occupiedCapacity = r.getOccupiedCapacity(this); this.cache_totalCarriedTraffic += carriedTraffic; this.cache_totalOccupiedCapacity += occupiedCapacity; } /* Add the info of the demands with forwarding rules */ for (Entry<Demand,Pair<Double,Double>> entryInfo : this.cacheHbH_normCarriedOccupiedPerTraversingDemandCurrentState.entrySet()) { final Demand demand = entryInfo.getKey(); final double occupiedCapacityAndCarriedTraffic = entryInfo.getValue().getSecond(); this.cache_totalCarriedTraffic += occupiedCapacityAndCarriedTraffic; this.cache_totalOccupiedCapacity += occupiedCapacityAndCarriedTraffic; } for (MulticastTree t : cache_traversingTrees) { final MulticastDemand demand = t.getMulticastDemand(); final double occupiedCapacity = t.getOccupiedLinkCapacity(); final double carriedTraffic = t.getCarriedTraffic(); this.cache_totalCarriedTraffic += carriedTraffic; this.cache_totalOccupiedCapacity += occupiedCapacity; } }
String str_seqLinks = CollectionUtils.join(tree.linkSet, " , "); String treeInformation = String.format("mt%d (id %d), multicast demand: md%d (id %d), carried traffic: %.3g, occupied capacity: %.3g, links: %s, nodes: %s, attributes: %s", tree.index, tree.id, tree.demand.index, tree.demand.id, tree.getCarriedTraffic(), tree.getOccupiedLinkCapacity(), str_seqLinks, str_seqNodes, tree.attributes.isEmpty() ? "none" : tree.attributes); netPlanInformation.append(treeInformation); netPlanInformation.append(NEWLINE);
if (Math.abs(cache_totalOccupiedCapacity) > 1e-3) throw new RuntimeException ("Bad"); for (Route r : cache_traversingRoutes.keySet()) if ((r.getCarriedTraffic() != 0) || (r.getOccupiedCapacity(this) != 0)) throw new RuntimeException ("Bad"); for (MulticastTree r : cache_traversingTrees) if ((r.getCarriedTraffic() != 0) || (r.getOccupiedLinkCapacity() != 0)) throw new RuntimeException ("Bad"); if (this.cache_traversingTrees.contains(tree)) check_totalCarriedTraffic += tree.getCarriedTraffic(); check_totalOccupiedCapacity += tree.getOccupiedLinkCapacity(); final String qos = tree.getMulticastDemand().getQosType();
@Override public List<AjtColumnInfo<MulticastTree>> getNonBasicUserDefinedColumnsVisibleOrNot() { final List<AjtColumnInfo<MulticastTree>> res = new LinkedList<> (); res.add(new AjtColumnInfo<MulticastTree>(this , Node.class, null , "A", "Ingress node", null , d->d.getIngressNode() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<MulticastTree>(this , String.class, null , "Bs", "Egress nodes", null , d->d.getMulticastDemand().getEgressNodes().stream().map(n->n.getName().equals("")? "Node " + n.getIndex() : n.getName()).collect(Collectors.joining(",")) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<MulticastTree>(this , String.class, null , "Bs (reached)", "Reached egress nodes", null , d->d.getEgressNodesReached().stream().map(n->n.getName().equals("")? "Node " + n.getIndex() : n.getName()).collect(Collectors.joining(",")) , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<MulticastTree>(this , Integer.class, null , "# Bs not reached", "Number of non-reached egress nodes", null , d->d.getMulticastDemand().getEgressNodes().size() - d.getEgressNodesReached().size() , AGTYPE.SUMINT , d-> d.getMulticastDemand().getEgressNodes().size() - d.getEgressNodesReached().size() > 0? Color.RED : null)); res.add(new AjtColumnInfo<MulticastTree>(this , MulticastDemand.class, null , "Demand", "Associated multicast demand", null , d->d.getMulticastDemand() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<MulticastTree>(this , Double.class, null , "Carried traffic (" + getTableNetworkLayer().getDemandTrafficUnits() + ")", "Carried traffic by the multicast tree", null , d->d.getCarriedTraffic() , AGTYPE.SUMDOUBLE , null)); res.add(new AjtColumnInfo<MulticastTree>(this , Double.class, null , "Occupied capacity (" + getTableNetworkLayer().getLinkCapacityUnits() + ")", "Occupied capacity in the traversed links", null, d->d.getOccupiedLinkCapacity() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<MulticastTree>(this , Collection.class, null , "Traversed links", "Traversed links in the non-failure state", null, d->d.getLinkSet() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<MulticastTree>(this , Double.class, null , "Total tree length (km)", "Sum of the lengths of all the tree links (accumulating any lower layer propagation lengths if any)", null, d->d.getTreeTotalLengthInKm() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<MulticastTree>(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), from the origin node, to destination nodes reached", null, d->d.getTreeMaximumPropagationDelayInMs() , AGTYPE.NOAGGREGATION , d->{ final double m = d.getMulticastDemand().getMaximumAcceptableE2EWorstCaseLatencyInMs(); if (m >= 0) return null; return d.getTreeMaximumPropagationDelayInMs () > m? Color.RED : null; })); res.add(new AjtColumnInfo<MulticastTree>(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.getTreeMaximumPathLengthInKm() , AGTYPE.NOAGGREGATION , null)); res.add(new AjtColumnInfo<MulticastTree>(this , Double.class, null , "Worst e2e length (hops)", "Current worst case end-to-end propagation length in number of traversed links", null, d->d.getTreeMaximumPathLengthInHops() , AGTYPE.NOAGGREGATION , null)); return res; }
private List<Triple<String,String,String>> getMulticastTreeInfoTables (MulticastTree t) { final DecimalFormat df = new DecimalFormat("###.##"); final NetPlan np = t.getNetPlan(); final List<Triple<String,String,String>> res = new ArrayList <> (); res.add(Triple.of("Tree index/id" , "Tree " + t.getIndex() + " (id " + t.getId() + ")", "multicastTre" + t.getId())); res.add(Triple.of("Layer" , "" + getLayerName(t.getLayer()) , "layer" + t.getLayer().getId())); res.add(Triple.of("Tree demand" , "Multicast demand " + t.getMulticastDemand().getIndex() + " (id " + t.getMulticastDemand().getId() + ")" , "multicastDemand" + t.getMulticastDemand().getId())); res.add(Triple.of("M. Demand offered traffic" , "" + df.format(t.getMulticastDemand().getOfferedTraffic()) + " " + np.getDemandTrafficUnitsName(t.getLayer()) , "")); res.add(Triple.of("M. Demand carried traffic" , "" + df.format(t.getMulticastDemand().getCarriedTraffic()) + " " + np.getDemandTrafficUnitsName(t.getLayer()) , "")); res.add(Triple.of("Tree carried traffic" , "" + df.format(t.getCarriedTraffic()) + " " + np.getDemandTrafficUnitsName(t.getLayer()), "")); res.add(Triple.of("Is up?" , "" + !t.isDown(), "")); res.add(Triple.of("Worst link utilization" , "" + df.format(t.getLinkSet().stream().mapToDouble(e->e.getUtilization()).max().orElse(0)), "")); res.add(Triple.of("E2E num. hops (av / max)" , "" + df.format(t.getTreeAveragePathLengthInHops()) + " / " + df.format(t.getTreeMaximumPathLengthInHops()) , "")); res.add(Triple.of("E2E length in km (av / max)" , "" + df.format(t.getTreeAveragePathLengthInHops()) + " / " + df.format(t.getTreeMaximumPathLengthInKm()) + " km", "")); res.add(Triple.of("E2E length in ms (av / max)" , "" + df.format(t.getTreeAveragePropagationDelayInMs()) + " / " + df.format(t.getTreeMaximumPropagationDelayInMs()) + " ms", "")); return res; } private List<Triple<String,String,String>> getDemandInfoTables (Demand d)
if (tree.getCarriedTraffic() != 0) throw new RuntimeException("Bad"); tree.layer.cache_multicastTreesDown.remove(tree); } else if (tree.getCarriedTraffic() != tree.carriedTrafficIfNotFailing) throw new RuntimeException("Bad"); tree.layer.cache_multicastTreesDown.add(tree);
final String qosType = demand.getQosType(); final double occupiedCapacity = t.getOccupiedLinkCapacity(); final double carriedTraffic = t.getCarriedTraffic(); Pair<Double,Double> thisQosTypeInfoSoFar = res.get(qosType); if (thisQosTypeInfoSoFar == null) { thisQosTypeInfoSoFar = Pair.of(0.0, 0.0); res.put(qosType, thisQosTypeInfoSoFar); }
demand.carriedTraffic = 0; for (MulticastTree t : demand.cache_multicastTrees) demand.carriedTraffic += t.getCarriedTraffic(); if (demand.coupledUpperLayerLinks != null) for (Link e : demand.coupledUpperLayerLinks.values())
final FigureMulticastTreePanel fig = new FigureMulticastTreePanel(callback , t , "Multicast tree " + t.getIndex() , t.getCarriedTraffic()); this.add(fig , BorderLayout.WEST); this.add(createPanelInfo(getMulticastTreeInfoTables(t), t) , BorderLayout.CENTER);