1%{ @file sn_get_node_tput_from_tput.m
2 % @brief Computes average throughputs at
nodes from station throughputs
4 % @author LINE Development Team
8 % @brief Computes average throughputs at
nodes from station throughputs
11 % This function calculates the average throughput at each node in steady-state
12 % from the station throughputs and node-level routing matrix.
16 % TNn = sn_get_node_tput_from_tput(sn, TN, TH)
17 % TNn = sn_get_node_tput_from_tput(sn, TN, TH, ANn)
22 % <tr><th>Name<th>Description
23 % <tr><td>sn<td>Network structure
24 % <tr><td>TN<td>Average throughputs at stations
25 % <tr><td>TH<td>Throughput handles
26 % <tr><td>ANn<td>(Optional) Average arrival rates at
nodes; computed
if missing
31 % <tr><th>Name<th>Description
32 % <tr><td>TNn<td>Average throughputs at
nodes
35function TNn=sn_get_node_tput_from_tput(sn, TN, TH, ANn)
41 ANn = sn_get_node_arvr_from_tput(sn, TN, TH);
45if ~isempty(TH) && ~isempty(TN)
48 inchain = sn.inchain{c};
49 refstat = sn.refstat(c);
51 if sn.nodetype(ind) ~= NodeType.Source
52 switch sn.nodetype(ind)
54 % For cache
nodes, use actual hit/miss ratios
if available
55 % instead of
nodevisits which don
't account for cache behavior
56 hitclass = sn.nodeparam{ind}.hitclass;
57 missclass = sn.nodeparam{ind}.missclass;
58 totalTput = sum(TN(refstat,inchain));
60 % Check if actual hit/miss probabilities are available in nodeparam
61 if isfield(sn.nodeparam{ind}, 'actualhitprob
') && ~isempty(sn.nodeparam{ind}.actualhitprob)
62 % Use actual hit/miss probabilities from solver result
63 actualHitProb = sn.nodeparam{ind}.actualhitprob;
64 actualMissProb = sn.nodeparam{ind}.actualmissprob;
66 % Find which original class this hit/miss class belongs to
67 for origClass = 1:length(hitclass)
68 if hitclass(origClass) == r
69 % This is a hit class - use hit probability
70 TNn(ind, r) = totalTput * actualHitProb(origClass);
71 elseif missclass(origClass) == r
72 % This is a miss class - use miss probability
73 TNn(ind, r) = totalTput * actualMissProb(origClass);
77 % Fallback to nodevisits-based calculation
78 if any(find(r==hitclass)) || any(find(r==missclass))
79 TNn(ind, r) = (sn.nodevisits{c}(ind,r) / sum(sn.visits{c}(sn.stationToStateful(refstat),inchain))) * totalTput;
88 % First, copy station throughputs directly to station nodes
91 ind = sn.stationToNode(ist);
92 TNn(ind,:) = TN(ist,:);
97 inchain = sn.inchain{c};
99 anystateful = find(sn.visits{c}(:,r));
100 if ~isempty(anystateful)
101 if sn.nodetype(ind) ~= NodeType.Sink && sn.nodetype(ind) ~= NodeType.Join
104 switch sn.nodetype(ind)
106 ist = sn.nodeToStation(ind);
107 TNn(ind, s) = TN(ist,s);
110 TNn(ind, s) = TNn(ind, s) + ANn(ind, r) * sn.rtnodes((ind-1)*R+r, (jnd-1)*R+s);
113 % For station nodes, throughput is already set from TN
114 % Only compute for non-station nodes (like ClassSwitch, Router)
115 % Note: nodeToStation returns NaN for non-station nodes, so use ~(>0) check
116 if ~(sn.nodeToStation(ind) > 0)
117 TNn(ind, s) = TNn(ind, s) + ANn(ind, r) * sn.rtnodes((ind-1)*R+r, (jnd-1)*R+s);
122 elseif sn.nodetype(ind) == NodeType.Join
125 if sn.nodetype(ind) ~= NodeType.Source
126 TNn(ind, s) = TNn(ind, s) + ANn(ind, r) * sn.rtnodes((ind-1)*R+r, (jnd-1)*R+s);
128 ist = sn.nodeToStation(ind);
129 TNn(ind, s) = TN(ist,s);