1%{ @file sn_get_arvr_from_tput.m
2 % @brief Computes average arrival rates at stations from throughputs
4 % @author LINE Development Team
8 % @brief Computes average arrival rates at stations from throughputs
11 % This function calculates the average arrival rate at each station
12 % in steady-state from the station throughputs and routing matrix.
16 % AN = sn_get_arvr_from_tput(sn, TN, TH)
21 % <tr><th>Name<th>Description
22 % <tr><td>sn<td>Network structure
23 % <tr><td>TN<td>Average throughputs at stations
24 % <tr><td>TH<td>Throughput handles (optional)
29 % <tr><th>Name<th>Description
30 % <tr><td>AN<td>Average arrival rates at stations
33function AN=sn_get_arvr_from_tput(sn, TN, TH)
37if ~isempty(TH) && ~isempty(TN)
40 % Build mapping from stateful
nodes to their position in rt matrix
41 % rt
is indexed by stateful
nodes, not stations
42 statefulNodes = find(sn.isstateful);
43 nStateful = length(statefulNodes);
45 % Build throughput vector
for all stateful
nodes (stations have TN, others need computation)
46 TN_stateful = zeros(nStateful, R);
48 ind = statefulNodes(sf);
49 ist = sn.nodeToStation(ind);
51 % This stateful node
is a station - use station throughput
52 TN_stateful(sf, :) = TN(ist, :);
54 % This stateful node
is not a station (e.g., Cache)
55 % Compute throughput from routing and reference station throughput
56 if sn.nodetype(ind) == NodeType.Cache
57 % For Cache
nodes, compute hit/miss
class throughputs
58 % from the reference station throughput and hit/miss probabilities
59 hitclass = sn.nodeparam{ind}.hitclass;
60 missclass = sn.nodeparam{ind}.missclass;
62 % Get actual hit/miss probabilities
if available
63 if isfield(sn.nodeparam{ind},
'actualhitprob') && ~isempty(sn.nodeparam{ind}.actualhitprob)
64 actualHitProb = sn.nodeparam{ind}.actualhitprob;
65 actualMissProb = sn.nodeparam{ind}.actualmissprob;
67 % Actual probabilities not yet computed - skip this cache
68 % Arrival rates will be computed later when probabilities are available
72 % Find the chain and reference station
for this cache
74 inchain = sn.inchain{c};
75 refstat = sn.refstat(c);
76 totalTput = sum(TN(refstat, inchain));
78 % Set throughput
for hit/miss
classes
79 for origClass = 1:length(hitclass)
80 if hitclass(origClass) > 0 && hitclass(origClass) <= R
81 TN_stateful(sf, hitclass(origClass)) = totalTput * actualHitProb(origClass);
83 if missclass(origClass) > 0 && missclass(origClass) <= R
84 TN_stateful(sf, missclass(origClass)) = totalTput * actualMissProb(origClass);
92 % Compute arrival rates
using stateful node throughputs and rt matrix
94 ind_ist = sn.stationToNode(ist);
95 if sn.nodetype(ind_ist)==NodeType.Source
98 % Find the position of
this station in the stateful node list
99 sf_ist = find(statefulNodes == ind_ist);
104 for sf_jst = 1:nStateful
107 AN(ist,k) = AN(ist,k) + TN_stateful(sf_jst,r)*sn.rt((sf_jst-1)*R+r, (sf_ist-1)*R+k);
118 ANn = sn_get_node_arvr_from_tput(sn, TN, TH, AN);
120 AN(ist,:) = ANn(sn.stationToNode(ist),:);