57e1a6112539d70886bebef9f495325950e0cbbe
[csit.git] / docs / ietf / draft-vpolak-bmwg-plrsearch-01.md
1 ---
2 title: Probabilistic Loss Ratio Search for Packet Throughput (PLRsearch)
3 # abbrev: PLRsearch
4 docname: draft-vpolak-bmwg-plrsearch-01
5 date: 2019-03-11
6
7 ipr: trust200902
8 area: ops
9 wg: Benchmarking Working Group
10 kw: Internet-Draft
11 cat: info
12
13 coding: us-ascii
14 pi:    # can use array (if all yes) or hash here
15 #  - toc
16 #  - sortrefs
17 #  - symrefs
18   toc: yes
19   sortrefs:   # defaults to yes
20   symrefs: yes
21
22 author:
23       -
24         ins: M. Konstantynowicz
25         name: Maciek Konstantynowicz
26         org: Cisco Systems
27         role: editor
28         email: mkonstan@cisco.com
29       -
30         ins: V. Polak
31         name: Vratko Polak
32         org: Cisco Systems
33         role: editor
34         email: vrpolak@cisco.com
35
36 normative:
37   RFC2544:
38   RFC8174:
39
40 informative:
41   draft-vpolak-mkonstan-bmwg-mlrsearch:
42     target: https://tools.ietf.org/html/draft-vpolak-mkonstan-bmwg-mlrsearch-00
43     title: "Multiple Loss Ratio Search for Packet Throughput (MLRsearch)"
44     date: 2018-11
45
46 --- abstract
47
48 This document addresses challenges while applying methodologies
49 described in [RFC2544] to benchmarking software based NFV (Network
50 Function Virtualization) data planes over an extended period of time,
51 sometimes referred to as "soak testing". Packet throughput search
52 approach proposed by this document assumes that system under test is
53 probabilistic in nature, and not deterministic.
54
55 --- middle
56
57 # Motivation
58
59 Network providers are interested in throughput a system can sustain.
60
61 [RFC2544] assumes loss ratio is given by a deterministic function of
62 offered load. But NFV software systems are not deterministic enough.
63 This makes deterministic algorithms (such as Binary Search per [RFC2544]
64 and [draft-vpolak-mkonstan-bmwg-mlrsearch] with single trial) to return
65 results, which when repeated show relatively high standard deviation,
66 thus making it harder to tell what "the throughput" actually is.
67
68 We need another algorithm, which takes this indeterminism into account.
69
70 # Relation To RFC2544
71
72 The aim of this document is to become an extension of [RFC2544] suitable
73 for benchmarking networking setups such as software based NFV systems.
74
75 # Terms And Assumptions
76
77 ## Device Under Test
78
79 In software networking, "device" denotes a specific piece of software
80 tasked with packet processing. Such device is surrounded with other
81 software components (such as operating system kernel). It is not
82 possible to run devices without also running the other components, and
83 hardware resources are shared between both.
84
85 For purposes of testing, the whole set of hardware and software
86 components is called "system under test" (SUT). As SUT is the part of
87 the whole test setup performance of which can be measured by [RFC2544]
88 methods, this document uses SUT instead of [RFC2544] DUT.
89
90 Device under test (DUT) can be re-introduced when analysing test results
91 using whitebox techniques, but this document sticks to blackbox testing.
92
93 ## System Under Test
94
95 System under test (SUT) is a part of the whole test setup whose
96 performance is to be benchmarked. The complete methodology contains
97 other parts, whose performance is either already established, or not
98 affecting the benchmarking result.
99
100 ## SUT Configuration
101
102 Usually, system under test allows different configurations, affecting
103 its performance. The rest of this document assumes a single
104 configuration has been chosen.
105
106 ## SUT Setup
107
108 Similarly to [RFC2544], it is assumed that the system under test has
109 been updated with all the packet forwarding information it needs, before
110 the trial measurements (see below) start.
111
112 ## Network Traffic
113
114 Network traffic is a type of interaction between system under test and
115 the rest of the system (traffic generator), used to gather information
116 about the system under test performance. PLRsearch is applicable only to
117 areas where network traffic consists of packets.
118
119 ## Packet
120
121 Unit of interaction between traffic generator and the system under test.
122 Term "packet" is used also as an abstractions of Ethernet frames.
123
124 ### Packet Offered
125
126 Packet can be offered, which means it is sent from traffic generator
127 to the system under test.
128
129 Each offered packet is assumed to become received or lost in a short
130 time.
131
132 ### Packet Received
133
134 Packet can be received, which means the traffic generator verifies it
135 has been processed. Typically, when it is succesfully sent from the
136 system under test to traffic generator.
137
138 It is assumed that each received packet has been caused by an offered
139 packet, so the number of packets received cannot be larger than the
140 number of packets offered.
141
142 ### Packet Lost
143
144 Packet can be lost, which means sent but not received in a timely
145 manner.
146
147 It is assumed that each lost packet has been caused by an offered
148 packet, so the number of packets lost cannot be larger than the number
149 of packets offered.
150
151 Usually, the number of packets lost is computed as the number of packets
152 offered, minus the number of packets received.
153
154 ###  Other Packets
155
156 PLRsearch is not considering other packet behaviors known from
157 networking (duplicated, reordered, greatly delayed), assuming the test
158 specification reclassifies those behaviors to fit into the first three
159 categories.
160
161 ### Tasks As Packets
162
163 Ethernet frames are the prime example of packets, but other units are
164 possible.
165
166 For example, a task processing system can fit the description. Packet
167 offered can stand for task submitted, packet received for task processed
168 successfully, and packet lost for task aborted (or not processed
169 successfully for some other reason).
170
171 In networking context, such a task can be a route update.
172
173 ## Traffic Profile
174
175 Usually, the performance of the system under test depends on a "type" of
176 a particular packet (for example size), and "composition" if the network
177 traffic consists of a mixture of different packet types.
178
179 Also, some systems under test contain multiple "ports" packets can be
180 offered to and received from.
181
182 All such qualities together (but not including properties of trial
183 measurements) are called traffic profile.
184
185 Similarly to system under test configuration, this document assumes only
186 one traffic profile has been chosen for a particular test.
187
188 ##  Traffic Generator
189
190 Traffic generator is the part of the whole test setup, distinct from the
191 system under test, responsible both for offering packets in a highly
192 predictable manner (so the number of packets offered is known), and for
193 counting received packets in a precise enough way (to distinguish lost
194 packets from tolerably delayed packets).
195
196 Traffic generator must offer only packets compatible with the traffic
197 profile, and only count similarly compatible packets as received.
198
199 ## Offered Load
200
201 Offered load is an aggregate rate (measured in packets per second) of
202 network traffic offered to the system under test, the rate is kept
203 constant for the duration of trial measurement.
204
205 ## Trial Measurement
206
207 Trial measurement is a process of stressing (previously setup) system
208 under test by offering traffic of a particular offered load, for a
209 particular duration.
210
211 After that, the system has a short time to become idle, while the
212 traffic generator decides how many packets were lost.
213
214 After that, another trial measurement (possibly with different offered
215 load and duration) can be immediately performed. Traffic generator
216 should ignore received packets caused by packets offered in previous
217 trial measurements.
218
219 ## Trial Duration
220
221 Duration for which the traffic generator was offering packets at
222 constant offered load.
223
224 In theory, care has to be taken to ensure the offered load and trial
225 duration predict integer number of packets to offer, and that the
226 traffic generator really sends appropriate number of packets within
227 precisely enough timed duration. In practice, such consideration do not
228 change PLRsearch result in any significant way.
229
230 ## Packet Loss
231
232 Packet loss is any quantity describing a result of trial measurement.
233
234 It can be loss count, loss rate or loss ratio. Packet loss is zero (or
235 non-zero) if either of the three quantities are zero (or non-zero,
236 respecively).
237
238 ### Loss Count
239
240 Number of packets lost (or delayed too much) at a trial measurement by
241 the system under test as determined by packet generator. Measured in
242 packets.
243
244 ### Loss Rate
245
246 Loss rate is computed as loss count divided by trial duration. Measured
247 in packets per second.
248
249 ### Loss Ratio
250
251 Loss ratio is computed as loss count divided by number of packets
252 offered. Measured as a real (in practice rational) number between zero
253 or one (including).
254
255 ## Trial Order Independent System
256
257 Trial order independent system is a system under test, proven (or just
258 assumed) to produce trial measurement results that display trial order
259 independence.
260
261 That means when a pair of consequent trial measurements are performed,
262 the probability to observe a pair of specific results is the same, as
263 the probability to observe the reversed pair of results whe performing
264 the reversed pair of consequent measurements.
265
266 PLRsearch assumes the system under test is trial order independent.
267
268 In practice, most system under test are not entirely trial order
269 independent, but it is not easy to devise an algorithm taking that into
270 account.
271
272 ## Trial Measurement Result Distribution
273
274 When a trial order independent system is subjected to repeated trial
275 measurements of constant offered load and duration, Law of Large Numbers
276 implies the observed loss count frequencies will converge to a specific
277 probability distribution over possible loss counts.
278
279 This probability distribution is called trial measurement result
280 distribution, and it depends on all properties fixed when defining it.
281 That includes the system under test, its chosen configuration, the
282 chosen traffic profile, the offered load and the trial duration.
283
284 As the system is trial order independent, trial measurement result
285 distribution does not depend on results of few initial trial
286 measurements, of any offered load or (finite) duration.
287
288 ## Average Loss Ratio
289
290 Probability distribution over some (finite) set of states enables
291 computation of probability-weighted average of any quantity evaluated on
292 the states (called the expected value of the quantity).
293
294 Average loss ratio is simply the expected value of loss ratio for a
295 given trial measurement result distribution.
296
297 ## Duration Independent System
298
299 Duration independent system is a trial order independent system, whose
300 trial measurement result distribution is proven (or just assumed) to
301 display practical independence from trial duration. See definition of
302 trial duration for discussion on practical versus theoretical.
303
304 The only requirement is for average loss ratio to be independent of
305 trial duration.
306
307 In theory, that would necessitate each trial measurement result
308 distribution to be a binomial distribution. In practice, more
309 distributions are allowed.
310
311 PLRsearch assumes the system under test is duration independent, at
312 least for trial durations typically chosen for trial measurements
313 initiated by PLRsearch.
314
315 ## Load Regions
316
317 For a duration independent system, trial measurement result distribution
318 depends only on offered load.
319
320 It is convenient to name some areas of offered load space by possible
321 trial results.
322
323 ### Zero Loss Region
324
325 A particular offered load value is said to belong to zero loss region,
326 if the probability of seeing non-zero loss trial measurement result is
327 exactly zero, or at least practically indistinguishable from zero.
328
329 ### Guaranteed Loss Region
330
331 A particular offered load value is said to belong to guaranteed loss
332 region, if the probability of seeing zero loss trial measurement result
333 (for non-negligible count of packets offered) is exactly zero, or at
334 least practically indistinguishable from zero.
335
336 ### Non-Deterministic Region
337
338 A particular offered load value is said to belong to non-deterministic
339 region, if the probability of seeing zero loss trial measurement result
340 (for non-negligible count of packets offered) practically
341 distinguishable from both zero and one.
342
343 ### Normal Region Ordering
344
345 Although theoretically the three regions can be arbitrary sets, this
346 document assumes they are intervals, where zero loss region contains
347 values smaller than non-deterministic region, which in turn contains
348 values smaller than guaranteed loss region.
349
350 ## Deterministic System
351
352 A hypothetical duration independent system with normal region ordering,
353 whose non-deterministic region is extremely narrow; only present due to
354 "practical distinguishibility" and cases when the expected number of
355 packets offered is not and integer.
356
357 A duration independent system which is not deterministic is called non-
358 deterministic system.
359
360 ## Througphput
361
362 Throughput is the highest offered load provably causing zero packet loss
363 for trial measurements of duration at least 60 seconds.
364
365 For duration independent systems with normal region ordering, the
366 throughput is the highest value within the zero loss region.
367
368 ## Deterministic Search
369
370 Any algorithm that assumes each measurement is a proof of the offered
371 load belonging to zero loss region (or not) is called deterministic
372 search.
373
374 This definition includes algorithms based on "composite measurements"
375 which perform multiple trial measurements, somehow re-classifying
376 results pointing at non-deterministic region.
377
378 Binary Search is an example of deterministic search.
379
380 Single run of a deterministic search launched against a deterministic
381 system is guaranteed to find the throughput with any prescribed
382 precision (not better than non-deterministic region width).
383
384 Multiple runs of a deterministic search launched against a non-
385 deterministic system can return varied results within non-deterministic
386 region. The exact distribution of deterministic search results depends
387 on the algorithm used.
388
389 ## Probabilistic Search
390
391 Any algorithm which performs probabilistic computations based on
392 observed results of trial measurements, and which does not assume that
393 non-deterministic region is practically absent is called probabilistic
394 search.
395
396 A probabilistic search algorithm, which would assume that non-
397 deterministic region is practically absent, does not really need to
398 perform probabilistic computations, so it would become a deterministic
399 search.
400
401 While probabilistic search for estimating throughput is possible, it
402 would need a careful model for boundary between zero loss region and
403 non-deterministic region, and it would need a lot of measurements of
404 almost surely zero loss to reach good precision.
405
406 ## Loss Ratio Function
407
408 For any duration independent system, the average loss ratio depends only
409 on offered load (for a particular test setup).
410
411 Loss ratio function is the name used for the function mapping offered
412 load to average loss ratio.
413
414 This function is initially unknown.
415
416 ## Target Loss Ratio
417
418 Input parameter of PLRsearch. The average loss ratio the output of
419 PLRsearch aims to achieve.
420
421 ## Critical Load
422
423 Aggregate rate of network traffic, which would lead to average loss
424 ratio exactly matching target loss ratio (when used as the offered load
425 for infinite many trial measurement).
426
427 ## Critical Load Estimate
428
429 Any quantitative description of the possible critical load PLRsearch is
430 able to give after observing finite amount of trial measurements.
431
432 ## Fitting Function
433
434 Any function PLRsearch uses internally instead of the unknown loss ratio
435 function. Typically chosen from small set of formulas (shapes) with few
436 parameters to tweak.
437
438 ## Shape of Fitting Function
439
440 Any formula with few undetermined parameters.
441
442 ## Parameter Space
443
444 A subset of Real Coordinate Space. A point of parameter space is a
445 vector of real numbers. Fitting function is defined by shape (a formula
446 with parameters) and point of parameter space (specifying values for the
447 parameters).
448
449 # Abstract Algorithm
450
451 ## High level description
452
453 PLRsearch accepts some input arguments, then iteratively performs trial
454 measurements at varying offered loads (and durations), and returns some
455 estimates of critical load.
456
457 PLRsearch input arguments form three groups.
458
459 First group has a single argument: measurer. This is a callback
460 (function) accepting offered load and duration, and returning the
461 measured loss count.
462
463 Second group consists of load related arguments required for measurer to
464 work correctly, typically minimal and maximal load to offer. Also,
465 target loss ratio (if not hardcoded) is a required argument.
466
467 Third group consists of time related arguments. Typically the duration
468 for the first trial measurement, duration increment per subsequent trial
469 measurement and total time for search. Some PLRsearch implementation may
470 use estimation accuracy parameters as an exit condition instead of total
471 search time.
472
473 The returned quantities should describe the final (or best) estimate of
474 critical load. Implementers can chose any description that suits their
475 users, typically it is average and standard deviation, or lower and
476 upper boundary.
477
478 ## Main Ideas
479
480 The search tries to perform measurements at offered load close to the
481 critical load, because measurement results at offered loads far from the
482 critical load give less information on precise location of the critical
483 load. As virtually every trial measurement result alters the estimate of
484 the critical load, offered loads vary as they approach the critical
485 load.
486
487 PLRsearch uses Bayesian Inference, computed using numerical integration,
488 which takes long time to get reliable enough results. Therefore it takes
489 some time before the most recent measurement result starts affecting
490 subsequent offered loads and critical rate estimates.
491
492 During the search, PLRsearch spawns few processes that perform numerical
493 computations, the main process is calling the measurer to perform trial
494 measurements, without any significant delays between them. The durations
495 of the trial measurements are increasing linearly, as higher number of
496 trial measurement results take longer to process.
497
498 ## Probabilistic Notions
499
500 Before internals of PLRsearch are described, we need to define notions
501 valid for situations when loss ratio is not entirely determined by
502 offered load.
503
504 Some of the notions already incorporate assumptions the PLRsearch
505 algorithm applies.
506
507 ### Loss Count Only
508
509 It is assumed that the traffic generator detects duplicate packets on
510 receive, and reports this as an error.
511
512 No latency (or other information) is taken into account.
513
514 ### Independent Trials
515
516 PLRsearch still assumes the system under test can be subjected to trial
517 measurements. The loss count is no longer determined precisely, but it
518 is assumed that for every system under test, its configuration, traffic
519 type and trial duration, there is a probability distribution over
520 possible loss counts.
521
522 This implies trial measurements are probabilistic, but the distribution
523 is independent of possible previous trial measurements.
524
525 Independence from previous measurements is not guaranteed in the real
526 world. The previous measurements may improve performance (via long-term
527 warmup effects), or decrease performance (due to long-term resource
528 leaks).
529
530 ### Trial Durations
531
532 [RFC2544] motivates the usage of at least 60 second duration by the idea
533 of the system under test slowly running out of resources (such as memory
534 buffers).
535
536 Practical results when measuring NFV software systems show that relative
537 change of trial duration has negligible effects on average loss ratio,
538 compared to relative change in offered load.
539
540 While the standard deviation of loss ratio usually shows some effects of
541 trial duration, they are hard to model; so further assumtions in
542 PLRsearch will make it insensitive to trial duration.
543
544 ### Target Loss Ratio
545
546 Loss ratio function could be used to generalize throughput as the
547 biggest offered load which still leads to zero average loss ratio.
548 Unfortunately, most realistic loss ratio functions always predict non-
549 zero (even if negligible) average loss ratio.
550
551 On the other hand, users do not really require the average loss ratio to
552 be an exact zero. Most users are satisfied when the average loss ratio
553 is small enough.
554
555 One of PLRsearch inputs is called target loss ratio. It is the loss
556 ratio users would accept as negligible.
557
558 (TODO: Link to why we think 1e-7 is acceptable loss ratio.)
559
560 ### Critical Load
561
562 Critical load (sometimes called critical rate) is the offered load which
563 leads to average loss ratio to become exactly equal to the target loss
564 ratio.
565
566 In principle, there could be such loss ratio functions which allow more
567 than one offered load to achieve target loss ratio. To avoid that,
568 PLRsearch assumes only increasing loss ratio functions are possible.
569
570 Similarly, some loss ratio functions may never return the target loss
571 ratio. PLRsearch assumes loss ratio function is continuous, that the
572 average loss ratio approaches zero as offered load approaches zero, and
573 that the average loss ratio approaches one as offered load approaches
574 infinity.
575
576 Under these assumptions, each loss ratio function has unique critical
577 load. PLRsearch attempts to locate the critical load.
578
579 ### Load Regions
580
581 Critical region is the interval of offered load close to critical load,
582 where single measurement is not likely to distinguish whether the
583 critical load is higher or lower than the current offered load.
584
585 In typical case of small target loss ratio, rates below critical region
586 form "zero loss region", and rates above form "high loss region".
587
588 ### Finite Models
589
590 Of course, finite amount of trial measurements, each of finite duration
591 does not give enough information to pinpoint the critical load exactly.
592 Therefore the output of PLRsearch is just an estimate with some
593 precision.
594
595 Aside of the usual substitution of infinitely precise real numbers by
596 finitely precise floating point numbers, there are two other instances
597 within PLRsearch where an objects of high information are replaced by
598 objects of low information.
599
600 One is the probability distribution of loss count, which is replaced by
601 average loss ratio. The other is the loss ratio function, which is
602 replaced by a few parameters, to be described later.
603
604 ## PLRsearch Building Blocks
605
606 Here we define notions used by PLRsearch which are not applicable to
607 other search methods, nor probabilistic systems under test, in general.
608
609 ### Bayesian Inference
610
611 Having reduced the model space significantly, the task of estimating the
612 critical load becomes simple enough so that Bayesian inference can be
613 used (instead of neural networks, or other Artifical Intelligence
614 methods).
615
616 In this case, the few parameters describing the loss ration function
617 become the model space. Given a prior over the model space, and trial
618 duration results, a posterior distribution can be computed, together
619 with quantities describing the critical load estimate.
620
621 ### Iterative Search
622
623 The idea PLRsearch is to iterate trial measurements, using Bayesian
624 inference to compute both the current estimate of the critical load and
625 the next offered load to measure at.
626
627 The required numerical computations are done in parallel with the trial
628 measurements.
629
630 This means the result of measurement "n" comes as an (additional) input
631 to the computation running in parallel with measurement "n+1", and the
632 outputs of the computation are used for determining the offered load for
633 measurement "n+2".
634
635 Other schemes are possible, aimed to increase the number of measurements
636 (by decreasing their duration), which would have even higher number of
637 measurements run before a result of a measurement affects offered load.
638
639 ### Poisson Distribution
640
641 For given offered load, number of packets lost during trial measurement
642 is assumed to come from Poisson distribution, and the (unknown) Poisson
643 parameter is expressed as average loss ratio.
644
645 Side note: Binomial Distribution is a better fit compared to Poisson
646 distribution (acknowledging that the number of packets lost cannot be
647 higher than the number of packets offered), but the difference tends to
648 be relevant only in high loss region. Using Poisson distribution lowers
649 the impact of measurements in high loss region, thus helping the
650 algorithm to focus on critical region better.
651
652 ### Fitting Functions
653
654 There are great many increasing functions (as candidates for the loss
655 ratio function).
656
657 To make the space of possible functions more tractable, some other
658 simplifying assumptions are needed. As the algorithm will be examining
659 (also) loads very close to the critical load, linear approximation to
660 the loss rate function around the critical load is important. But as the
661 search algorithm needs to evaluate the function also far away from the
662 critical region, the approximate function has to be reasonably behaved
663 for every positive offered load, specifically it cannot predict non-
664 positive packet loss ratio.
665
666 Within this document, "fitting function" is the name for such a
667 reasonably behaved function, which approximates the loss ratio function
668 well in the critical region.
669
670 ### Measurement Impact
671
672 Results from trials far from the critical region are likely to affect
673 the critical rate estimate negatively, as the fitting function does not
674 need to be a good approximation there. This is true mainly for high loss
675 region, as in zero loss region even badly behaved fitting function
676 predicts loss count to be "almost zero", so seeing a measurement
677 confirming the loss has been zero indeed has small impact.
678
679 Discarding some results, or "suppressing" their impact with ad-hoc
680 methods (other than using Poisson distribution instead of binomial) is
681 not used, as such methods tend to make the overall search unstable. We
682 rely on most of measurements being done (eventually) within the critical
683 region, and overweighting far-off measurements (eventually) for well-
684 behaved fitting functions.
685
686 Speaking about new trials, each next trial will be done at offered load
687 equal to the current average of the critical load. Alternative methods
688 for selecting offered load might be used, in an attempt to speed up
689 convergence. For example by employing the aforementioned unstable ad-hoc
690 methods.
691
692 ### Fitting Function Coefficients Distribution
693
694 To accomodate systems with different behaviours, the fitting function is
695 expected to have few numeric parameters affecting its shape (mainly
696 affecting the linear approximation in the critical region).
697
698 The general search algorithm can use whatever increasing fitting
699 function, some specific functions can described later.
700
701 It is up to implementer to chose a fitting function and prior
702 distribution of its parameters. The rest of this document assumes each
703 parameter is independently and uniformly distributed over a common
704 interval. Implementers are to add non-linear transformations into their
705 fitting functions if their prior is different.
706
707 Exit condition for the search is either the standard deviation of the
708 critical load estimate becoming small enough (or similar), or overal
709 search time becoming long enough.
710
711 The algorithm should report both average and standard deviation for its
712 critical load posterior. If the reported averages follow a trend
713 (without reaching equilibrium), average and standard deviation should
714 refer to the equilibrium estimates based on the trend, not to immediate
715 posterior values.
716
717 ### Integration
718
719 The posterior distributions for fitting function parameters will not be
720 integrable in general.
721
722 The search algorithm utilises the fact that trial measurement takes some
723 time, so this time can be used for numeric integration (using suitable
724 method, such as Monte Carlo) to achieve sufficient precision.
725
726 ### Optimizations
727
728 After enough trials, the posterior distribution will be concentrated in
729 a narrow area of the parameter space. The integration method should take
730 advantage of that.
731
732 Even in the concentrated area, the likelihood can be quite small, so the
733 integration algorithm should avoid underflow errors by some means,
734 for example by tracking the logarithm of the likelihood.
735
736 # Sample Implementation Specifics: FD.io CSIT
737
738 The search receives min_rate and max_rate values, to avoid measurements
739 at offered loads not supporeted by the traffic generator.
740
741 The implemented tests cases use bidirectional traffic. The algorithm
742 stores each rate as bidirectional rate (internally, the algorithm is
743 agnostic to flows and directions, it only cares about overall counts of
744 packets sent and packets lost), but debug output from traffic generator
745 lists unidirectional values.
746
747 ## Measurement Delay
748
749 In a sample implemenation in FD.io CSIT project, there is roughly 0.5
750 second delay between trials due to restrictons imposed by packet traffic
751 generator in use (T-Rex).
752
753 As measurements results come in, posterior distribution computation
754 takes more time (per sample), although there is a considerable constant
755 part (mostly for inverting the fitting functions).
756
757 Also, the integrator needs a fair amount of samples to reach the region
758 the posterior distribution is concentrated at.
759
760 And of course, speed of the integrator depends on computing power of the
761 CPU the algorithm is able to use.
762
763 All those timing related effects are addressed by arithmetically
764 increasing trial durations with configurable coefficients (currently 5.1
765 seconds for the first trial, each subsequent trial being 0.1 second
766 longer).
767
768 ## Rounding Errors and Underflows
769
770 In order to avoid them, the current implementation tracks natural
771 logarithm (instead of the original quantity) for any quantity which is
772 never negative. Logarithm of zero is minus infinity (not supported by
773 Python), so special value "None" is used instead. Specific functions for
774 frequent operations (such as "logarithm of sum of exponentials") are
775 defined to handle None correctly.
776
777 ## Fitting Functions
778
779 Current implementation uses two fitting functions. In general, their
780 estimates for critical rate differ, which adds a simple source of
781 systematic error, on top of randomness error reported by integrator.
782 Otherwise the reported stdev of critical rate estimate is
783 unrealistically low.
784
785 Both functions are not only increasing, but also convex (meaning the
786 rate of increase is also increasing).
787
788 As Primitive Function to any positive function is an increasing
789 function, and Primitive Function to any increasing function is convex
790 function; both fitting functions were constructed as double Primitive
791 Function to a positive function (even though the intermediate increasing
792 function is easier to describe).
793
794 As not any function is integrable, some more realistic functions
795 (especially with respect to behavior at very small offered loads) are
796 not easily available.
797
798 Both fitting functions have a "central point" and a "spread", varied by
799 simply shifting and scaling (in x-axis, the offered load direction) the
800 function to be doubly integrated. Scaling in y-axis (the loss rate
801 direction) is fixed by the requirement of transfer rate staying nearly
802 constant in very high offered loads.
803
804 In both fitting functions (as they are a double Primitive Function to a
805 symmetric function), the "central point" turns out to be equal to the
806 aforementioned limiting transfer rate, so the fitting function parameter
807 is named "mrr", the same quantity our Maximum Receive Rate tests are
808 designed to measure.
809
810 Both fitting functions return logarithm of loss rate, to avoid rounding
811 errors and underflows. Parameters and offered load are not given as
812 logarithms, as they are not expected to be extreme, and the formulas are
813 simpler that way.
814
815 Both fitting functions have several mathematically equivalent formulas,
816 each can lead to an overflow or underflow in different places. Overflows
817 can be eliminated by using different exact formulas for different
818 argument ranges. Underflows can be avoided by using approximate formulas
819 in affected argument ranges, such ranges have their own formulas to
820 compute. At the end, both fitting function implementations contain
821 multiple "if" branches, discontinuities are a possibility at range
822 boundaries.
823
824 Offered load for next trial measurement is the average of critical rate
825 estimate. During each measurement, two estimates are computed, even
826 though only one (in alternating order) is used for next offered load.
827
828 ### Stretch Function
829
830 The original function (before applying logarithm) is Primitive Function
831 to Logistic Function. The name "stretch" is used for related a function
832 in context of neural networks with sigmoid activation function.
833
834 Formula for stretch function: loss rate (r) computed from offered load
835 (b), mrr parameter (m) and spread parameter (a):
836
837 r = a (Log(E^(b/a) + E^(m/a)) - Log(1 + E^(m/a)))
838
839 ### Erf Function
840
841 The original function is double Primitive Function to Gaussian Function.
842 The name "erf" comes from error function, the first primitive to
843 Gaussian.
844
845 Formula for erf function: loss rate (r) computed from offered load (b),
846 mrr parameter (m) and spread parameter (a):
847
848 r = (b + (a (E^(-((b - m)^2/a^2)) - E^(-(m^2/a^2))))/Sqrt(Pi) + (b - m) Erf((b - m)/a) - m Erf(m/a))/2
849
850 ## Prior Distributions
851
852 The numeric integrator expects all the parameters to be distributed
853 (independently and) uniformly on an interval (-1, 1).
854
855 As both "mrr" and "spread" parameters are positive and not not
856 dimensionless, a transformation is needed. Dimentionality is inherited
857 from max_rate value.
858
859 The "mrr" parameter follows a Lomax Distribution with alpha equal to
860 one, but shifted so that mrr is always greater than 1 packet per second.
861
862 The "stretch" parameter is generated simply as the "mrr" value raised to
863 a random power between zero and one; thus it follows a Reciprocal
864 Distribution.
865
866 ## Integrator
867
868 After few measurements, the posterior distribution of fitting function
869 arguments gets quite concentrated into a small area. The integrator is
870 using Monte Carlo with Importance Sampling where the biased distribution
871 is Bivariate Gaussian distribution, with deliberately larger variance.
872 If the generated sample falls outside (-1, 1) interval, another sample
873 is generated.
874
875 The the center and the covariance matrix for the biased distribution is
876 based on the first and second moments of samples seen so far (within the
877 computation), with the following additional features designed to avoid
878 hyper-focused distributions.
879
880 Each computation starts with the biased distribution inherited from the
881 previous computation (zero point and unit covariance matrix is used in
882 the first computation), but the overal weight of the data is set to the
883 weight of the first sample of the computation. Also, the center is set
884 to the first sample point. When additional samples come, their weight
885 (including the importance correction) is compared to the weight of data
886 seen so far (within the computation). If the new sample is more than one
887 e-fold more impactful, both weight values (for data so far and for the
888 new sample) are set to (geometric) average if the two weights. Finally,
889 the actual sample generator uses covariance matrix scaled up by a
890 configurable factor (8.0 by default).
891
892 This combination showed the best behavior, as the integrator usually
893 follows two phases. First phase (where inherited biased distribution or
894 single big sasmples are dominating) is mainly important for locating the
895 new area the posterior distribution is concentrated at. The second phase
896 (dominated by whole sample population) is actually relevant for the
897 critical rate estimation.
898
899 # IANA Considerations
900
901 ..
902
903 # Security Considerations
904
905 ..
906
907 # Acknowledgements
908
909 ..
910
911 --- back