/** * <p>Returns the set of forwarding rules of links initiated in the node and associated to the given demand (the links are then in the same layer * as the demand), that have a non-zero splitting factor</p> * @param demand The demand * @return The map associating the demand-link pair, with the associated splitting factor */ public SortedMap<Pair<Demand,Link>,Double> getForwardingRules (Demand demand) { NetworkLayer layer = demand.layer; layer.checkAttachedToNetPlanObject(netPlan); demand.checkRoutingType(RoutingType.HOP_BY_HOP_ROUTING); SortedMap<Pair<Demand,Link>,Double> res = new TreeMap<Pair<Demand,Link>,Double> (); for (Link e : getOutgoingLinks(layer)) { final Double splitFactor = demand.cacheHbH_frs.get(e); if (splitFactor != null) res.put (Pair.of(demand, e) , splitFactor); } return res; }
layer.checkAttachedToNetPlanObject(netPlan); if (!netPlan.hasSRGs()) return Pair.of(0.0, 0.0);
layer.checkAttachedToNetPlanObject(netPlan);
layer.checkAttachedToNetPlanObject(this); if (e instanceof Demand)
linkLayer.checkAttachedToNetPlanObject(this); demandLayer.checkAttachedToNetPlanObject(this); for (Entry<Demand, Link> e : mapping.getDemandMap().entrySet())
/** * <p>Creates a new {@link com.net2plan.interfaces.networkDesign.Demand Demand} in the given layer, with same end nodes as the link, and then couples the link to the new created demand.</p> * @param newDemandLayer The layer where the demand will be created (and coupled to the link) * @param routingTypeDemand Routing type * @return The created demand */ public Demand coupleToNewDemandCreated (NetworkLayer newDemandLayer , RoutingType routingTypeDemand) { checkAttachedToNetPlanObject(); netPlan.checkIsModifiable(); newDemandLayer.checkAttachedToNetPlanObject(this.netPlan); Demand newDemand = netPlan.addDemand(originNode , destinationNode , capacity , routingTypeDemand , null , newDemandLayer); try { newDemand.coupleToUpperOrSameLayerLink(this); } catch (RuntimeException e) { newDemand.remove (); throw e; } if (ErrorHandling.isDebugEnabled()) netPlan.checkCachesConsistency(); return newDemand; }
/** * <p>Returns the fraction of the total carried traffic in the given layer that has at least one backup path defined. * If a layer is not defined, the defaul layer is used.</p> * @param netPlan Current network design * @param optionalLayerParameter Network layer (optional) * @return Traffic protection degree */ public static double getTrafficProtectionDegree(NetPlan netPlan, NetworkLayer ... optionalLayerParameter) { if (optionalLayerParameter.length >= 2) throw new Net2PlanException ("None or one layer parameter can be supplied"); NetworkLayer layer = (optionalLayerParameter.length == 1)? optionalLayerParameter [0] : netPlan.getNetworkLayerDefault(); layer.checkAttachedToNetPlanObject(netPlan); double totalCarriedTraffic = 0; double totalCarriedAndProtectedTraffic = 0; for (Route route : netPlan.getRoutes(layer)) { totalCarriedTraffic += route.getCarriedTraffic(); if (route.hasBackupRoutes()) totalCarriedAndProtectedTraffic += route.getCarriedTraffic(); } return totalCarriedTraffic == 0? 0 : totalCarriedAndProtectedTraffic / totalCarriedTraffic; } }
/** * <p>Creates new links in the given layer, from the demand ingress node to each one of the demand egress nodes, and couples these newly created links to the multicast demand.</p> * @param newLinkLayer The layer where the new links will be created * @return The set of created links, already coupled to the demand */ public SortedSet<Link> coupleToNewLinksCreated (NetworkLayer newLinkLayer) { checkAttachedToNetPlanObject(); netPlan.checkIsModifiable(); newLinkLayer.checkAttachedToNetPlanObject(this.netPlan); if (this.layer.equals (newLinkLayer)) throw new Net2PlanException ("Cannot couple a link and a demand in the same layer"); if (isCoupled()) throw new Net2PlanException ("The multicast demand is already coupled"); SortedSet<Link> newLinks = new TreeSet<Link> (); try { for (Node egressNode : egressNodes) { Link newLink = netPlan.addLink(ingressNode , egressNode , carriedTraffic , netPlan.getNodePairEuclideanDistance(ingressNode , egressNode) , 200000 , null , newLinkLayer); newLinks.add (newLink); } couple (newLinks); } catch (Exception e) { for (Link link : newLinks) link.remove (); throw e; } if (ErrorHandling.isDebugEnabled()) netPlan.checkCachesConsistency(); return newLinks; }
/** * <p>Creates a new link in the given layer with same end nodes, and couples it to this demand.</p> * @param newLinkLayer Layer where the link will be created. * @return The new created link */ public Link coupleToNewLinkCreated (NetworkLayer newLinkLayer) { netPlan.checkIsModifiable(); checkAttachedToNetPlanObject(); newLinkLayer.checkAttachedToNetPlanObject(this.netPlan); if (isCoupled()) throw new Net2PlanException ("The demand is already coupled"); Link newLink = null; try { newLink = netPlan.addLink(ingressNode , egressNode , carriedTraffic , netPlan.getNodePairEuclideanDistance(ingressNode , egressNode) , 200000 , null , newLinkLayer); coupleToUpperOrSameLayerLink(newLink); } catch (Exception e) { if (newLink != null) newLink.remove (); throw e; } if (ErrorHandling.isDebugEnabled()) netPlan.checkCachesConsistency(); return newLink; }