LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
qsys_mapg1k_perflow.m
1function result = qsys_mapg1k_perflow(MAPS, svc, K, varargin)
2% RESULT = QSYS_MAPG1K_PERFLOW(MAPS, SVC, K)
3%
4% Per-flow throughput and loss ratio of a FIFO buffer with tail drop that is
5% fed by N flows of arbitrary, mutually different statistical character.
6%
7% Flow n is described by its own MAP, so two flows may share an arrival rate
8% and still differ in the shape and autocorrelation of their interarrival
9% times. The buffer holds K packets including the one in transmission, and
10% the transmission time follows an arbitrary distribution F.
11%
12% MAPS - 1 x N cell array, MAPS{n} = {D0n, D1n}, the MAP of flow n. The
13% modulating orders M_n may differ from flow to flow.
14% SVC - service time descriptor, see QSYS_MAPG1K
15% K - buffer size in packets, K >= 1
16%
17% Options are forwarded to QSYS_MAPG1K ('tol', 'nmax').
18%
19% Returns a struct with fields:
20% throughput(n) - throughput of flow n [pkts/s]
21% lossRatio(n) - loss ratio of flow n, in [0,1]
22% lambda(n) - arrival rate of flow n [pkts/s]
23% lambdaAggregate - sum_n lambda(n)
24% throughputAggregate- sum_n throughput(n)
25% lossAggregate - aggregate loss ratio, sum_n L(n)*lambda(n)/lambda
26% p0(n), pK(n) - empty/full buffer probabilities of the n-th model
27% rho - offered load lambdaAggregate * E[S]
28%
29% Method. The exact model of N flows would need a Markov chain tracking the
30% modulating state of every flow jointly with the buffer occupancy, hence
31% prod_n M_n * (K+1) states; [1] notes this is already out of reach at N=10,
32% M_n=3, K=10 (over 4e11 transition matrix entries). Instead, one model per
33% flow is solved: flow n is kept exactly as MAP_n, while the other N-1 flows
34% are replaced by a single Poisson stream of rate lambda - lambda_n. That
35% substitution is justified by the Palm-Khinchin limiting theorem on the
36% superposition of many point processes, so it is an approximation that
37% improves as N grows, and it is applied N times, once per flow, so no flow
38% is ever the one being Poissonized when its own throughput is computed.
39% Superposing MAP_n with the Poisson background yields the MAP
40% D0 = D0n - lambdaBar_n*I, D1 = D1n + lambdaBar_n*I, ([1], eq. 5)
41% which is passed to QSYS_MAPG1K. Each solve costs O((K*M)^3) for the
42% embedded chain, so the whole sweep is O(N*(K*M)^3) against the O(M^(3N)*K^3)
43% of the exact joint model: linear rather than exponential in the flow count.
44%
45% Accuracy. [1] reports errors against simulation of the exact model below
46% about 8% for N >= 9 with K >= 20, falling to 2.1% at K=50 and 0.5% at
47% K=100, and to 1.2% at N=900. Errors are largest when flows are few, highly
48% variable, and the buffer is small.
49%
50% TEST (Table 2 of [1], K=20, rho=1, gamma service with CV=2; the nine flows
51% are defined in eq. (55)-(63)). Tables 2-9 of [1] all reproduce to within
52% 0.07 pkts/s, the precision to which they are published:
53% throughput ~ [89.8 179.6 269.4 85.2 169.3 253.4 56.9 110.8 166.6] pkts/s
54%
55% References:
56% [1] Chydzinski, A. Per-Flow Throughput of a FIFO Buffer. Applied System
57% Innovation 2026, 9, 112. Theorem 1.
58%
59% See also QSYS_MAPG1K, QSYS_MG1K_LOSS, QSYS_MAPG1.
60
61if ~iscell(MAPS)
62 line_error(mfilename, 'MAPS must be a cell array of {D0,D1} pairs.');
63end
64N = numel(MAPS);
65if N < 1
66 line_error(mfilename, 'At least one flow is required.');
67end
68
69lam = zeros(1, N);
70for n = 1:N
71 if ~iscell(MAPS{n}) || numel(MAPS{n}) < 2
72 line_error(mfilename, sprintf('MAPS{%d} must be a {D0,D1} cell.', n));
73 end
74 lam(n) = map_lambda(MAPS{n});
75end
76lamTot = sum(lam);
77
78Tn = zeros(1, N);
79Ln = zeros(1, N);
80p0 = zeros(1, N);
81pK = zeros(1, N);
82Smean = NaN;
83for n = 1:N
84 D0n = MAPS{n}{1};
85 D1n = MAPS{n}{2};
86 lamBar = lamTot - lam(n);
87 % Superposition of MAP_n with a Poisson background of rate lamBar, eq. (5)
88 Mn = size(D0n, 1);
89 D0 = D0n - lamBar*eye(Mn);
90 D1 = D1n + lamBar*eye(Mn);
91 r = qsys_mapg1k(D0, D1, svc, K, varargin{:});
92 Smean = r.meanServiceTime;
93 p0(n) = r.p0;
94 pK(n) = r.pK;
95 % Throughput of flow n, eq. (20): the aggregate departure rate (1-p0)/S
96 % less the background throughput lamBar*(1-pK), the background loss ratio
97 % being pK by PASTA since the background is Poisson.
98 Tn(n) = (1 - r.p0)/Smean + r.pK*lamBar - lamBar;
99 Ln(n) = 1 - Tn(n)/lam(n);
100end
101
102result = struct();
103result.throughput = Tn;
104result.lossRatio = Ln;
105result.lambda = lam;
106result.lambdaAggregate = lamTot;
107result.throughputAggregate = sum(Tn);
108result.lossAggregate = sum(Ln.*lam)/lamTot;
109result.p0 = p0;
110result.pK = pK;
111result.meanServiceTime = Smean;
112result.rho = lamTot*Smean;
113result.analyzer = 'qsys_mapg1k_perflow';
114end
Definition Station.m:245