Package ons

Class VirtualTopology

java.lang.Object
ons.VirtualTopology

public class VirtualTopology
extends java.lang.Object
The virtual topology is created based on a given Physical Topology and on the lightpaths specified on the XML file.
  • Field Details

  • Constructor Details

    • VirtualTopology

      public VirtualTopology​(org.w3c.dom.Element xml, PhysicalTopology pt)
      Creates a new VirtualTopology object.
      Parameters:
      xml - file that contains all simulation information
      pt - Physical Topology of the network
  • Method Details

    • createLightpath

      public long createLightpath​(LightPath lp)
      First, creates a lightpath in the Physical Topology through the createLightpathInPT function. Then, gets the lightpath's source and destination nodes, so a new LightPath object can finally be created and added to the lightPaths HashMap and to the adjMatrix TreeSet.
      Parameters:
      lp - the lightpath created by the User to test
      Returns:
      -1 if LightPath object cannot be created, or its unique identifier otherwise
    • getName

      public java.lang.String getName()
    • createLightpathInOpticalGrooming

      public long createLightpathInOpticalGrooming​(LightPath lpCreated, LightPath lpGroomable)
      Checks and creates a lightpath with optical grooming over existing lightpath (fully).
      Parameters:
      lpCreated - the lightpath created by the User to test
      lpGroomable - the lightpath will be groomable
      Returns:
      -1 if LightPath object cannot be created, or its unique identifier otherwise
    • createLightpathInOpticalGrooming

      public long createLightpathInOpticalGrooming​(java.util.ArrayList<java.lang.Integer> path, LightPath lpGroomable, int rate)
      Checks and creates a lightpath with optical grooming over existing lightpath. The lightpath created will have the same modulation format of the existing lightpath.
      Parameters:
      path - the path of the new lightpath
      lpGroomable - the lightpath will be groomable
      rate - the flow rate in Mbps
      Returns:
      -1 if LightPath object cannot be created, or its unique identifier otherwise
    • createLightpathInOpticalGrooming

      public long createLightpathInOpticalGrooming​(java.util.ArrayList<java.lang.Integer> path, LightPath lpGroomable, int rate, boolean extendRight)
      Usado na PLI! Checks and creates a lightpath with optical grooming over existing lightpath. The lightpath created will have the same modulation format of the existing lightpath.
      Parameters:
      path - the path of the new lightpath
      lpGroomable - the lightpath will be groomable
      rate - the flow rate in Mbps
      extendRight - whether the tunnel will be extended to the right or left (to right if is true, to left if is false)
      Returns:
      -1 if LightPath object cannot be created, or its unique identifier otherwise
    • removeLightPath

      public boolean removeLightPath​(long id)
      First, removes a given lightpath in the Physical Topology through the removeLightpathInPT function. Then, gets the lightpath's source and destination nodes, to remove it from the lightPaths HashMap and the adjMatrix TreeSet. If the lightpath is in optical grooming then your 'Tx' is -1 for 'PhysicalTopology' don't release the input grooming port This method should be used only by ControlPlane class
      Parameters:
      id - the unique identifier of the lightpath to be removed
      Returns:
      true if operation was successful, or false otherwise
    • deallocatedLightpath

      public boolean deallocatedLightpath​(long id)
      This method serves to deallocate one lightpath that was not used to being accepted in a request. This method should be used by the RA classes.
      Parameters:
      id - the unique identifier of the lightpath to be removed
      Returns:
      true if operation was successful, or false otherwise
    • deallocatedLightpaths

      public void deallocatedLightpaths​(LightPath[] lps)
      This method serves to deallocate lightpaths that was not used to being accepted in a request. This method should be used by the RA classes.
      Parameters:
      lps - the lightptahs set
    • reprovisionLightPath

      public boolean reprovisionLightPath​(long id, LightPath lp)
      Removes a given lightpath from the Physical Topology and then puts it back, but with a new route (set of links). The lightpath can't be in optical grooming
      Parameters:
      id - the id of old lightpath
      lp - the new lightpath
      Returns:
      true if operation was successful, or false otherwise
    • deallocatedReprovisionLightPath

      public boolean deallocatedReprovisionLightPath​(long id, LightPath OldLightpath)
      This method serves to deallocate one lightpath that was not used to being reroute in a request. This method should be used by the RA classes.
      Parameters:
      id - the unique identifier of the lightpath to be reprovisioned
      OldLightpath - the old lightpath before the reprovisioned
      Returns:
      true if operation was successful, or false otherwise
    • pushPullLightPath

      public boolean pushPullLightPath​(long id, LightPath lp)
      Implements the push pull technique.
      Parameters:
      id - the id of old lightpath
      lp - the new lightpath
      Returns:
      true if operation was successful, or false otherwise
    • freeSpecBetweenLps

      public boolean freeSpecBetweenLps​(LightPath old, LightPath lp)
    • isLightpathAvailable

      public boolean isLightpathAvailable​(int src, int dst, int bw)
      Says whether or not a given LightPath object has a determined amount of available bandwidth.
      Parameters:
      src - the lightpath's source node
      dst - the lightpath's destination node
      bw - required amount of bandwidth
      Returns:
      true if lightpath is available
    • getAvailableLightpaths

      public java.util.TreeSet<LightPath> getAvailableLightpaths​(int src, int dst, int bw)
      Retrieves a TreeSet with the Virtual Topology's available lightpaths.
      Parameters:
      src - the lightpath's source node
      dst - the lightpath's destination node
      bw - required amount of available bandwidth the lightpath must have
      Returns:
      a TreeSet with the available lightpaths
    • getAvailablePrimaryLightpaths

      public java.util.TreeSet<LightPath> getAvailablePrimaryLightpaths​(int src, int dst, int bw)
      Retrieves a TreeSet with the Virtual Topology's available lightpaths. Only the primary lightpaths. Not backups
      Parameters:
      src - the lightpath's source node
      dst - the lightpath's destination node
      bw - required amount of available bandwidth the lightpath must have
      Returns:
      a TreeSet with the available lightpaths
    • getAvailablePrimaryLightpathsProtection

      public java.util.TreeSet<LightPath> getAvailablePrimaryLightpathsProtection​(int src, int dst, int bw, java.lang.String typeProtection)
      Retrieves a TreeSet with the Virtual Topology's available lightpaths. Only the primary lightpaths. Not backups
      Parameters:
      src - the lightpath's source node
      dst - the lightpath's destination node
      bw - required amount of available bandwidth the lightpath must have
      typeProtection - type of protection
      Returns:
      a TreeSet with the available lightpaths
    • getAvailableBackupLightpathsProtection

      public java.util.TreeSet<LightPath> getAvailableBackupLightpathsProtection​(int src, int dst, int bw, java.lang.String typeProtection)
      Retrieves a TreeSet with the Virtual Topology's available lightpaths. Only the backup lightpaths. Not backups
      Parameters:
      src - the lightpath's source node
      dst - the lightpath's destination node
      bw - required amount of available bandwidth the lightpath must have
      typeProtection - type of protection
      Returns:
      a TreeSet with the available lightpaths
    • getNumberOfActiveLightPaths

      public int getNumberOfActiveLightPaths()
      Retrieves the number of active lightpaths in virtual topology.
      Returns:
      the number of active lightpaths in virtual topology
    • getLightPaths

      public java.util.Map<java.lang.Long,​LightPath> getLightPaths()
    • getNumberOfActiveLightPaths

      public int getNumberOfActiveLightPaths​(java.util.TreeSet<java.lang.Integer> srcNodes)
      Retrieves the number of active lightpaths in this source nodes.
      Parameters:
      srcNodes - the source nodes in virtual topology
      Returns:
      the number of active lightpaths in in this nodes
    • getLightpathBWAvailable

      public int getLightpathBWAvailable​(long id)
      Retrieves the available bandwidth of a given lightpath.
      Parameters:
      id - the lightpath's unique identifier
      Returns:
      amount of available bandwidth
    • getLightpathBWUsed

      public int getLightpathBWUsed​(long id)
      Retrieves the used bandwidth of a given lightpath.
      Parameters:
      id - the lightpath's unique identifier
      Returns:
      amount of used bandwidth
    • getLightpathBW

      public int getLightpathBW​(long id)
      Retrieves the bandwidth of a given lightpath.
      Parameters:
      id - the lightpath's unique identifier
      Returns:
      amount of bandwidth
    • isLightpathIdle

      public boolean isLightpathIdle​(long id)
      Says whether or not a given lightpath is idle, i.e., all its bandwidth is available.
      Parameters:
      id - the lightpath's unique identifier
      Returns:
      true if lightpath is idle, or false otherwise
    • isLightpathFull

      public boolean isLightpathFull​(long id)
      Says whether or not a given lightpath is full, i.e., all its bandwidth is allocated.
      Parameters:
      id - the lightpath's unique identifier
      Returns:
      true if lightpath is full, or false otherwise
    • getLightpath

      public LightPath getLightpath​(long id)
      Retrieves a determined LightPath object from the Virtual Topology.
      Parameters:
      id - the lightpath's unique identifier
      Returns:
      the required lightpath
    • getLightpaths

      public java.util.TreeSet<LightPath> getLightpaths​(int src, int dst)
      Retrieves the TreeSet with all LightPath objects that belong to the Virtual Topology.
      Parameters:
      src - the lightpath's source node
      dst - the lightpath's destination node
      Returns:
      the TreeSet with all of the lightpaths
    • getLightpath

      public LightPath getLightpath​(int src, int dst, int firstSlotIndex)
      Retrieves the Lightpath Object that has this source, this destination and this firstSlotIndex ** Only works in **eonsim** simulator
      Parameters:
      src - the lightpath's source node
      dst - the lightpath's destination node
      firstSlotIndex - the lightpath's first slot index
      Returns:
      the Lightpath Object
    • getLightpaths

      public java.util.ArrayList<java.util.ArrayList<LightPath>> getLightpaths​(LightPath lp)
      Retrieves the LightPaths objects that belong in this lightpath in all links.
      Parameters:
      lp - the lightpath
      Returns:
      the ArrayList object with all lightpaths belong the lp links
    • getLightpathsInLink

      public java.util.ArrayList<LightPath> getLightpathsInLink​(int link)
      Retrieves the LightPaths objects that belong in this link.
      Parameters:
      link - the id link in Physical Topology
      Returns:
      the ArrayList object with all lightpaths belong this link
    • getLightpathsInLink2

      public java.util.ArrayList<LightPath> getLightpathsInLink2​(int link)
      (Deprecated) Retrieves the LightPaths objects that belong in this link.
      Parameters:
      link - the id link in Physical Topology
      Returns:
      the ArrayList object with all lightpaths belong this link
    • getLightpathsSrc

      public java.util.ArrayList<LightPath> getLightpathsSrc​(int src)
      Retrieves the Set with all LightPath objects originated in this source.
      Parameters:
      src - the source
      Returns:
      the Set with all of the lightpaths originated in this source
    • getLightpathsSrcModulation

      public java.util.ArrayList<LightPath> getLightpathsSrcModulation​(int src, int modulation)
      Retrieves the Set with all LightPath objects originated in this source in this modulation.
      Parameters:
      src - the source
      modulation - the modulation considered
      Returns:
      the Set with all of the lightpaths originated in this source
    • getLightpathsDst

      public java.util.ArrayList<LightPath> getLightpathsDst​(int dst)
      Retrieves the Set with all LightPath objects originated in this destination.
      Parameters:
      dst - the destination
      Returns:
      the Set with all of the lightpaths originated in this source
    • getLightpathsSrc

      public java.util.ArrayList<LightPath> getLightpathsSrc​(int src, int link)
      Retrieves the Set with all LightPath objects originated in this source and in this link.
      Parameters:
      src - the source
      link - the id link in Physical Topology
      Returns:
      the Set with all of the lightpaths originated in this source and this link
    • getLightpathsSrcTx

      public java.util.ArrayList<LightPath> getLightpathsSrcTx​(int src, int tx)
      Retrieves the Set with all LightPath objects originated in this source and used this Tx.
      Parameters:
      src - the source
      tx - the id of the tx
      Returns:
      the Set with all of the lightpaths originated in this source used this Tx
    • getLightpathsLinkTx

      public java.util.ArrayList<LightPath> getLightpathsLinkTx​(int link, int tx)
      Retrieves the Set with all LightPath objects belong this link and used this Tx.
      Parameters:
      link - the link Id
      tx - the id of the tx
      Returns:
      the Set with all LightPath objects belong this link and used this Tx
    • getAdjMatrix

      public java.util.TreeSet<LightPath>[][] getAdjMatrix()
      Retrieves the adjacency matrix of the Virtual Topology.
      Returns:
      the VirtualTopology object's adjMatrix
    • hasLightpath

      public boolean hasLightpath​(int src, int dst)
      Says whether or not a lightpath exists, based only on its source and destination nodes.
      Parameters:
      src - the lightpath's source node
      dst - the lightpath's destination node
      Returns:
      true if the lightpath exists, or false otherwise
    • getHopsMinLightpath

      public int getHopsMinLightpath​(int src, int dst, int bw)
      Retrieves the number of hops of the lightpath with minimum physical hops accommodate this rate.
      Parameters:
      src - the lightpath's source node
      dst - the lightpath's destination node
      bw - the rate accommodate
      Returns:
      the hops of lightpath with minimun physical hops
    • hopCount

      public int hopCount​(LightPath lp)
      Retrieves the number of links (or hops) a given LightPath object has.
      Parameters:
      lp - the LightPath object
      Returns:
      the number of hops the lightpath has
    • getLightpathsGraph

      public WeightedGraph getLightpathsGraph​(int bw)
      Retrieves the lightpaths of a weighted graph without weights.
      Parameters:
      bw - required amount of bandwidth
      Returns:
      a weighted graph formed only by the lightpaths without weights
    • getWeightedLightpathsGraph

      public WeightedGraph getWeightedLightpathsGraph​(int bw, double w)
      Retrieves the lightpaths of a weighted graph with weights. Get the minimum lightpath physical hops
      Parameters:
      bw - required amount of bandwidth
      w - the weight by hop
      Returns:
      a weighted graph formed only by the lightpaths with weight
    • getWeightedPrimaryLightpathsGraph

      public WeightedGraph getWeightedPrimaryLightpathsGraph​(int bw, double w)
      Retrieves the lightpaths of a weighted graph with weights (only primary lightpaths). Get the minimum lightpath physical hops
      Parameters:
      bw - required amount of bandwidth
      w - the weight by hop
      Returns:
      a weighted graph formed only by the lightpaths with weight
    • getWeightedPrimaryLightpathsGraphProtection

      public WeightedGraph getWeightedPrimaryLightpathsGraphProtection​(int bw, double w, java.lang.String typeProtection)
      Retrieves the lightpaths of a weighted graph with weights (only primary lightpaths). Get the minimum lightpath physical hops
      Parameters:
      bw - required amount of bandwidth
      w - the weight by hop
      typeProtection - type of protection
      Returns:
      a weighted graph formed only by the lightpaths with weight
    • getWeightedBackupLightpathsGraphProtection

      public WeightedGraph getWeightedBackupLightpathsGraphProtection​(int bw, double w, java.lang.String typeProtection)
      Retrieves the lightpaths of a weighted graph with weights (only backup lightpaths). Get the minimum lightpath physical hops
      Parameters:
      bw - required amount of bandwidth
      w - the weight by hop
      typeProtection - type of protection
      Returns:
      a weighted graph formed only by the lightpaths with weight
    • getMinHops

      public LightPath getMinHops​(java.util.TreeSet<LightPath> availableLightpaths)
      Retrieves the lightpath with minimum physical hops.
      Parameters:
      availableLightpaths - the TreeSet with the lighhtpaths
      Returns:
      the lightpath with minimun physical hops
    • lightpathIsInOpticalGrooming

      public boolean lightpathIsInOpticalGrooming​(long id)
      Retrieves if the lightpath [already allocated] is in optical grooming
      Parameters:
      id - the id of lightpath
      Returns:
      true if the lightpath is in optical grooming, false otherwise
    • numOfLightpathsTunnel

      public int numOfLightpathsTunnel​(long id)
      Retrieves the number of lightpaths are groomed in this lightpath's tunnel.
      Parameters:
      id - the id of lightpath
      Returns:
      the number of lightpaths in this lightpath's tunnel
    • getTunnel

      public java.util.ArrayList<LightPath> getTunnel​(long id)
      Retrieves the lightpaths this tunnel.
      Parameters:
      id - the id of lightpath belonging this tunnel
      Returns:
      the the lightpaths this tunnel.
    • getTunnelSize

      public int getTunnelSize​(long id)
      Retrieves the size of this tunnel (number of slots).
      Parameters:
      id - the id of lightpath belonging this tunnel
      Returns:
      the size of this lightpath's tunnel
    • toString

      public java.lang.String toString()
      Prints all lightpaths belonging to the Virtual Topology.
      Overrides:
      toString in class java.lang.Object
      Returns:
      string containing all the elements of the adjMatrix TreeSet
    • getNextLightpathID

      public long getNextLightpathID()
    • backNextLightpathID

      public void backNextLightpathID()
    • canCreateLightpathInOpticalGrooming

      public boolean canCreateLightpathInOpticalGrooming​(java.util.ArrayList<java.lang.Integer> path, LightPath lpGroomable, int requiredSlots)
      Checks if lightpath with optical grooming over existing lightpath. The lightpath created will have the same modulation format of the existing lightpath.
      Parameters:
      path - the path of the new lightpath
      lpGroomable - the lightpath will be groomable
      requiredSlots - the number of slots as required
      Returns:
      true if it's possible create this lightpath, false otherwise
    • searchBestCandidate

      public LightPath searchBestCandidate​(java.util.ArrayList<java.lang.Integer> path, java.util.ArrayList<LightPath> lpsSource)
      Find the best lightpath candidate for optical grooming. The lightpath with more links in common
      Parameters:
      path - the path nodes
      lpsSource - the set os lightptahs in this source
      Returns:
      the best candidate lightpath
    • getLightPathWeight

      public double getLightPathWeight​(LightPath lp)
      Retrieves the weight of this lightpath's links
      Parameters:
      lp - yhe lightpath
      Returns:
      the weight of this lightpath's links
    • modulationPath

      public boolean modulationPath​(LightPath[] lps, int modulation)
      Verifies whether the modulation serves all sizes of lightpaths
      Parameters:
      lps - the lightptahs
      modulation - the modulation tests
      Returns:
      true if all candidates lightpaths serves all sizes of lightpaths, false otherwise
    • modulationPath

      public boolean modulationPath​(LightPath[] lps)
      Verifies whether the modulation' lightpaths serves all sizes of lightpaths. Only for EON Simulator
      Parameters:
      lps - the lightptahs
      Returns:
      true if all candidates lightpaths serves all sizes of lightpaths, false otherwise
    • checkCrosstalkOnOthers

      public boolean checkCrosstalkOnOthers​(LightPath[] lps)
      Verifies whether Crosstalk in the neighbors of this lightpaths serves all sizes. Only for SDM-EON Simulator
      Parameters:
      lps - the lightptahs
      Returns:
    • checkCrosstalkOnOthers

      public boolean checkCrosstalkOnOthers​(Path[] paths)
      Verifies whether Crosstalk in the neighbors of this paths serves all sizes. Only for SDM-EON Simulator
      Parameters:
      paths - the path
      Returns:
    • modulationPath

      public boolean modulationPath​(Path[] paths)
      Verifies whether the modulation' paths serves all sizes of lightpaths in each path. Only for EON Simulator
      Parameters:
      paths - the paths
      Returns:
      true if all candidates lightpaths serves all sizes of lightpaths, false otherwise
    • getPowerConsumption

      public double getPowerConsumption()
      Retrieves the current Power Consumption in this topology
      Returns:
      the Power Consumption based in number of slots used and its modulations
    • getPowerConsumption

      public double getPowerConsumption​(int link)
      Retrieves the current Power Consumption in this link
      Parameters:
      link - the id of link
      Returns:
      the Power Consumption based in number of slots used and its modulations
    • getBVOXCSetupExpenditure

      public double getBVOXCSetupExpenditure​(LightPath lp)
      Retrieves the OXC setup expendituret in this lightpath
      Parameters:
      lp - the lightpath
      Returns:
      the OXC setup expendituret in this lightpath in W
    • getPowerConsumptionWithoutOXCSetup

      public double getPowerConsumptionWithoutOXCSetup​(LightPath lp)
      Retrieves the power consumption without OXC setup in this lightpath
      Parameters:
      lp - the lightpath
      Returns:
      the power consumption without OXC setup in this lightpath in W
    • getPowerConsumption

      public double getPowerConsumption​(LightPath lp)
      Retrieves the power consumption in this lightpath
      Parameters:
      lp - the lightpath
      Returns:
      the power consumption in this lightpath in W
    • getBVOXCExpenditure

      public double getBVOXCExpenditure​(LightPath lp)
      Retrieves the BVOXCs Power Consumption of this lightpath
      Parameters:
      lp - the lightpath
      Returns:
      the BVOXCs Power Consumption of this lightpath based in number OXC used
    • SNRCheck

      public boolean SNRCheck​(LightPath lightpath)
      Checks if the lightPath's SNR is above the threshold
      Parameters:
      lightpath -
      Returns:
      true if the lightPath's SNR is above the threshold or false otherwise
    • checkSNRLightpath

      public boolean checkSNRLightpath​(LightPath lightpath)
      Checks whether lightpath meets all SNR restrictions
      Parameters:
      lightpath - LightPath Object
      Returns:
      true if lightpath meets all SNR restrictions false otherwise
    • calculateST

      public double calculateST​(LightPath lp)
      Calculates the Setup Time of this lightpath
      Parameters:
      lp - the lightpath
      Returns:
      st time in s of this lightpath
    • lengthPath

      public double lengthPath​(LightPath lightpath)
      Retrieves the lightpath size in km
      Parameters:
      lightpath - the lightpath
      Returns:
      the lightpath size in km