% calculateNetMetrics
%
%>> Usage: [statMetrics] = calculateStaticNetMetrics(phys, netState)
%
%>> Abstract: This function calculates the main network performance
% metrics, both the general metrics and the wavelength conversion
% specific metrics. The wavelength conversion metrics describe the
% wavelength converters distribution on the network.
%
%>> Arguments:
% o In:
% . netState: NetState Structure. More information about netState in
% section "Structure of netState variable" from Help.
%
% . phys: Phys Structure. More information about netState in section
% "Structure of phys variable" from Help.
%
% o Out:
% . statMetrics: Static Metrics Structure. It is a structure with the next
% fields:
% -statMetrics.linkPropDelays(Mx1): Link propagation delays vector for
% a given physical topology. It is a vecor as many rows as 'M'
% physical links. Each row is a physical link 'm', containing the
% propagation delay in 'us' over a physical link from node 'x' to
% node 'y'.
% -statMetrics.lightpathDistances(Lx1): Lightpath distances vector for
% a given physical topology. It is a vecor as many rows as 'L'
% lightpaths. Each row is a 'l', containing the euclidean distance
% in Km of the lightpath from node 'i' to node 'j'. It is computed
% based on the link distances.
% -statMetrics.lightpathPropDelays(Lx1): Lightpath propagation delays
% vector for a given physical topology. It is a vecor as many rows as
% 'L' lightpaths. Each row is a lightpaths 'l', containing the total
% propagation delay in 'us' in a lightpath established from node 'i'
% to node 'j'.
% -statMetrics.NrUsedTransmittersPerNode(1xN): The number of used optical
% transmitters in each node. It is a 1-by-N nodes integer vector, where
% N is the number of nodes.
% -statMetrics.NrUsedReceiversPerNode(1xN): The number of used optical
% transmitters in each node. It is a 1-by-N nodes integer vector,
% where N is the number of nodes.
% -statMetrics.NrUsedWavelengthsPerFiber(1xM): The number of Used
% Wavelengths in each fiber link. It is a 1-by-M links integer
% vector, where M is the number of links.
% -statMetrics.NrUsedPhysHops(1xL): The number of Used Physical Hops
% in a lightpath. It is a 1-by-L lightpaths integer vector, where L
% is the number of lightpaths.
% -statMetrics.carriedTraffic(1x1): Total traffic carried by the
% network. This is the part of the traffic offered onto the network
% that is actually carried by the nerwork. The rest of the offered
% traffic not considered here will be the blocked traffic. Thus, the
% carried traffic will be lower or equal to the total offered
% traffic, that is, the sum of all the average traffic flows offered
% onto the network node pairs. This metric is computed as the sum of
% all the average traffic flows carried by the network node pairs. It
% is a real value in units of Gbps.
% -statMetrics.routedPhysTraffic(1x1): Total routed physical
% traffic. This is the total traffic routed by the links in the
% physical topology and it is computed as the sum of all the
% lightpath flows multiplied by the number of used links a lightpath.
% It is a real value in units of Gbps.
% -statMetrics.routedVirtTraffic(1x1): Total routed virtual traffic.
% This is the total traffic routed by the ightpaths in the virtual
% topology and it is computed as the sum of all the lightpath flows.
% It is a real value in units of Gbps.
% -statMetrics.linkTraffic(1xM): Vector of the traffic routed by each
% fiber link. It is a vector with 'M' number of links elemnts. It is
% a real value in units of Gbps.
% -statMetrics.averVirtualHops(1x1): Average Number of Virtual Hops in
% the network. This metric is the average number of lighpaths which a
% message has to transverse in the virtual topology to arrive to its
% destination node. It is a real value.
% -statMetrics.averPhysicalHops(1x1): Average Number of Physical Hops
% in the network. This metric is the average number of physical links
% which a message has to transverse in the physical topology to
% arrive to its destination node. It is a real value.
% -statMetrics.singleHopTraffic(1x1): The amount of traffic which is
% routed in one virtual hop. It is a real value in units of Gbps.
% -statMetrics.networkCongestion(1x1): Value of Network Congestion. It
% is the theoretical value of the network congestion computed as the
% maximum traffic flow offered onto any lightpath in the network.
% -statMetrics.totalNrOfUsedWavelengths(1x1): Total number of used
% wavelength channels in the network.
% -statMetrics.numberOfLightpaths(1x1): Total number of established
% lightpaths in the virtual topology.
% -statMetrics.maximumLinkLoadinNrLightpaths(1x1): Maximum Link Load
% in Number of Lightpaths. It is defined as the maximum number of
% lightpaths used in any link in the network. It is an integer value.
% -statMetrics.messagePropagationDelay(1x1): The propagation delay
% experienced by a message in the network.It is a real value in units
% of 'useg'.
% -statMetrics.totalNrOfUsedConverters(1x1): The total number of used
% wavelength converters in the entire network if the network nodes
% have wavelength conversion capability. It is an integer value.
% -statMetrics.NrUsedConvertersPerNode(1xN): The number of used
% wavelength converters in each node if the network nodes have
% wavelength conversion capability. It is a 1-by-N nodes integer
% vector, where "N" is the number of nodes.
% -statMetrics.NrUsedConvertersPerLP(1xL): The number of used
% wavelength converters in each lightpath if the network nodes have
% wavelength conversion capability. It is an 1-by-L nodes integer
% matrix, where "L" is the number of lightpaths.
% -statMetrics.averNrUsedConverPerLP(1x1): Average number of
% wavelength converters per lightpath. It is a real value.
%
%
function [statMetrics] = calculateStaticNetMetrics(phys, netState)
if (nargin==0), help calculateStaticNetMetrics;return, end %help calling
if (nargin~=2), error('1: Incorrect number of arguments.'),end %Number of input arguments different of 2
numberOfNodes=max(max(phys.linkTable));
numberOfLinks=size(phys.linkTable,1);
numberOfLightpaths=size(netState.lightpathRoutingMatrix ,1);
numberOfFlows=size(netState.flowTable ,1);
statMetrics = struct('linkPropDelays', [], 'lightpathDistances', [], 'lightpathPropDelays',[],...
'NrUsedTransmittersPerNode', [], 'NrUsedReceiversPerNode', [],...
'NrUsedWavelengthsPerFiber', [], 'NrUsedPhysHops', [], 'linkTraffic', [], ...
'carriedTraffic', [], 'routedPhysTraffic', [], 'routedVirtTraffic', [], ...
'averPhysicalHops', [], 'averVirtualHops', [], 'singleHopTraffic', [], ...
'networkCongestion', [], 'totalNrOfUsedWavelengths', [], 'numberOfLightpaths',[],...
'maximumLinkLoadinNrLightpaths', [], 'messagePropagationDelay', [], ...
'totalNrOfUsedConverters', [], 'NrUsedConvertersPerNode', [], ...
'NrUsedConvertersPerLP', [], 'averNrUsedConverPerLP', []);
%------------------------------------------------------------------------------------------------
%--------******** Network Performance Metrics*********------------------------------------
%-------------------------------------------------------------------------------------------
%A) DISTANCES AND DELAYS ************************
% % 1.- Euclidean distances (in Km) between the pairs of nodes
% statMetrics.distancesMatrix = calculateDistanceMatrix(phys.nodesPlaceMatrix);
%
% % 2.- Distances in Km of the Physical Links
% statMetrics.linkDistances=zeros(numberOfLinks,1);
% for m=1:numberOfLinks,
% statMetrics.linkDistances(m)=statMetrics.distancesMatrix(phys.linkTable(m,1),phys.linkTable(m,2));
% end
% 3.- Propagation Delays in 'us' of the Physical Links
% The propagation delay matrix is based on the link distance table.
propagationVelocity=0.2; %km/us
statMetrics.linkPropDelays=phys.linkLengthInKm./propagationVelocity;% distance in km, delay in us
% 4.- Distances in Km of the Lightpaths
% The aforementioned distance is the sum of all partial-euclidean
% distances in each physical hop of a lightpath
statMetrics.lightpathDistances=zeros(numberOfLightpaths,1);
for lp=1:numberOfLightpaths,
lightpathLinks=find(netState.lightpathRoutingMatrix (lp,:)>0);
statMetrics.lightpathDistances(lp)=sum(phys.linkLengthInKm(lightpathLinks));
end
% 5.- Propagation Delays in 'us' of the Lightpaths
% The propagation delay matrix is based on the lightpath distances matrix.
statMetrics.lightpathPropDelays=statMetrics.lightpathDistances./propagationVelocity;% distance in km, delay in us
%B) USED RESOURCES *****************************
% 6.- Used Transmitters Per Node & 7.- Used Receivers Per Node
statMetrics.NrUsedTransmittersPerNode=zeros(1,numberOfNodes);
statMetrics.NrUsedReceiversPerNode=zeros(1,numberOfNodes);
for i=1:numberOfNodes,
statMetrics.NrUsedTransmittersPerNode(i)= length(find(netState.lightpathTable(:,2)==i));
statMetrics.NrUsedReceiversPerNode(i)= length(find(netState.lightpathTable(:,3)==i));
end
% 8.- Used Wavelengths Per Fiber Link
statMetrics.NrUsedWavelengthsPerFiber= zeros(1,numberOfLinks);
for m=1:numberOfLinks,
statMetrics.NrUsedWavelengthsPerFiber(m)=length(find(netState.lightpathRoutingMatrix(:,m)>0));
end
% 9.- Used Physical Hops a Lightpath
statMetrics.NrUsedPhysHops=zeros(1,numberOfLightpaths);
for l=1:numberOfLightpaths,
statMetrics.NrUsedPhysHops(l)=length(find(netState.lightpathRoutingMatrix(l,:)>0));
end
%C) TRAFFICS ***********************************
% 10.- Total carried traffic by the network
carriedFlow=zeros(1,numberOfFlows);
for flowID=1:numberOfFlows,
carriedFlow(flowID) = sum(netState.flowRoutingMatrix(flowID,find(netState.lightpathTable(:,2)==netState.flowTable(flowID,2))));
end
statMetrics.carriedTraffic = sum(carriedFlow);
% 11.- Total routed traffic by the physical links
lightpathFlows=sum(netState.flowRoutingMatrix,1);% ojo: este no se muetra en dinamico (el lpflows)
statMetrics.routedPhysTraffic=sum(lightpathFlows.*statMetrics.NrUsedPhysHops);
% 12.- Total routed traffic by the lightpaths
statMetrics.routedVirtTraffic=sum(lightpathFlows);
% 13.-Link Traffic
statMetrics.linkTraffic=zeros(1,numberOfLinks);
for m=1:numberOfLinks,
lightpathIDsOfLink=find(netState.lightpathRoutingMatrix(:,m)>0);
statMetrics.linkTraffic(m)=sum(lightpathFlows(lightpathIDsOfLink));
end
%D) NET METRICS ********************************
% 14.-Average Number of Physical Hops in the network
if statMetrics.carriedTraffic==0
statMetrics.averPhysicalHops=0;
else
statMetrics.averPhysicalHops=statMetrics.routedPhysTraffic/statMetrics.carriedTraffic;
end
% 15.-Average Number of Virtual Hops in the network
if statMetrics.carriedTraffic==0
statMetrics.averVirtualHops=0;
else
statMetrics.averVirtualHops=statMetrics.routedVirtTraffic/statMetrics.carriedTraffic;
end
% 16.-Single Hop Traffic
statMetrics.singleHopTraffic=0;
for i=1:size(netState.flowRoutingMatrix,1),
ingressNode=netState.flowTable(i,2);
egressNode=netState.flowTable(i,3);
LPsFromIngressNode=find(netState.lightpathTable(:,2)==ingressNode);
LPsToEgressNode=find(netState.lightpathTable(:,3)==egressNode);
LPsFromIngressToEgress=intersect(LPsFromIngressNode, LPsToEgressNode);
if numel(LPsFromIngressToEgress)>0,
statMetrics.singleHopTraffic=statMetrics.singleHopTraffic + sum(netState.flowRoutingMatrix(i,LPsFromIngressToEgress));
end
end
% 17.-Network Congestion
statMetrics.networkCongestion=max(lightpathFlows);
% 18.-Total Number of Used Wavelength Channels in the Network
statMetrics.totalNrOfUsedWavelengths=length(find(netState.lightpathRoutingMatrix>0));
% 19.-Number of Lightpaths
statMetrics.numberOfLightpaths=numberOfLightpaths;
% 20.-Maximum Link Load in terms of Number of Used Wavelength Channels in any Fiber Link
statMetrics.maximumLinkLoadinNrLightpaths=max(statMetrics.NrUsedWavelengthsPerFiber);
% 21.-Message Propagation Delay
if statMetrics.routedVirtTraffic==0
statMetrics.messagePropagationDelay = 0;
else
statMetrics.messagePropagationDelay = lightpathFlows*statMetrics.lightpathPropDelays / statMetrics.routedVirtTraffic;
end
%E) WAVELENGTH CONVERSION METRICS **************
[statMetrics.totalNrOfUsedConverters, statMetrics.NrUsedConvertersPerNode, statMetrics.NrUsedConvertersPerLP, statMetrics.averNrUsedConverPerLP] = ...
calculateConversionMetrics(phys, netState);