1
//! Implementation of the Tor Vegas congestion control algorithm.
2
//!
3
//! This is used by the circuit reactor in order to decide when to send data and SENDMEs.
4
//!
5
//! Spec: prop324 section 3.3 (TOR_VEGAS)
6

            
7
use super::{
8
    CongestionControlAlgorithm, CongestionSignals, CongestionWindow, State,
9
    params::{Algorithm, VegasParams},
10
    rtt::RoundtripTimeEstimator,
11
};
12
use crate::Result;
13

            
14
use tor_error::{error_report, internal};
15

            
16
/// Bandwidth-Delay Product (BDP) estimator.
17
///
18
/// Spec: prop324 section 3.1 (BDP_ESTIMATION).
19
#[derive(Clone, Debug, Default)]
20
pub(crate) struct BdpEstimator {
21
    /// The BDP value of this estimator.
22
    bdp: u32,
23
}
24

            
25
impl BdpEstimator {
26
    /// Return the current BDP value.
27
166
    fn get(&self) -> u32 {
28
166
        self.bdp
29
166
    }
30

            
31
    /// Update the estimator with the given congestion window, RTT estimator and any condition
32
    /// signals that we are currently experiencing.
33
    ///
34
    /// C-tor: congestion_control_update_circuit_bdp() in congestion_control_common.c
35
156
    fn update(
36
156
        &mut self,
37
156
        cwnd: &CongestionWindow,
38
156
        rtt: &RoundtripTimeEstimator,
39
156
        signals: &CongestionSignals,
40
156
    ) {
41
        // Stalled clock means our RTT value is invalid so set the BDP to the cwnd.
42
156
        if rtt.clock_stalled() {
43
            self.bdp = if signals.channel_blocked {
44
                // Set the BDP to the cwnd minus the outbound queue size, capping it to the minimum
45
                // cwnd.
46
                cwnd.get()
47
                    .saturating_sub(signals.channel_outbound_size)
48
                    .max(cwnd.min())
49
            } else {
50
                cwnd.get()
51
            };
52
156
        } else {
53
156
            // Congestion window based BDP will respond to changes in RTT only, and is relative to
54
156
            // cwnd growth. It is useful for correcting for BDP overestimation, but if BDP is
55
156
            // higher than the current cwnd, it will underestimate it.
56
156
            //
57
156
            // To clarify this is equivalent to: cwnd * min_rtt / ewma_rtt.
58
156
            let min_rtt_usec = rtt.min_rtt_usec().unwrap_or(u32::MAX);
59
156
            let ewma_rtt_usec = rtt.ewma_rtt_usec().unwrap_or(u32::MAX);
60
156
            self.bdp = cwnd
61
156
                .get()
62
156
                .saturating_mul(min_rtt_usec)
63
156
                .saturating_div(ewma_rtt_usec);
64
156
        }
65
156
    }
66
}
67

            
68
/// Congestion control Vegas algorithm.
69
///
70
/// TCP Vegas control algorithm estimates the queue lengths at relays by subtracting the current
71
/// BDP estimate from the current congestion window.
72
///
73
/// This object implements CongestionControlAlgorithm trait used by the ['CongestionControl'].
74
///
75
/// Spec: prop324 section 3.3 (TOR_VEGAS)
76
/// C-tor: Split between congestion_control_vegas.c and the congestion_control_t struct.
77
#[derive(Clone, Debug)]
78
pub(crate) struct Vegas {
79
    /// Congestion control parameters.
80
    params: VegasParams,
81
    /// Bandwidth delay product.
82
    /// C-tor: "bdp"
83
    bdp: BdpEstimator,
84
    /// Congestion window.
85
    /// C-tor: "cwnd", "cwnd_inc_pct_ss", "cwnd_inc", "cwnd_min", "cwnd_inc_rate", "cwnd_full",
86
    cwnd: CongestionWindow,
87
    /// Number of cells expected before we send a SENDME resulting in more data.
88
    num_cell_until_sendme: u32,
89
    /// The number of SENDME until we will acknowledge a congestion event again.
90
    /// C-tor: "next_cc_event"
91
    num_sendme_until_cwnd_update: u32,
92
    /// Counts down until we process a cwnd worth of SENDME acks. Used to track full cwnd status.
93
    /// C-tor: "next_cwnd_event"
94
    num_sendme_per_cwnd: u32,
95
    /// Number of cells in-flight (sent but awaiting SENDME ack).
96
    /// C-tor: "inflight"
97
    num_inflight: u32,
98
    /// Indicate if we noticed we were blocked on channel during an algorithm run. This is used to
99
    /// notice a change from blocked to non-blocked in order to reset the num_sendme_per_cwnd.
100
    /// C-tor: "blocked_chan"
101
    is_blocked_on_chan: bool,
102
}
103

            
104
impl Vegas {
105
    /// Create a new [`Vegas`] from the specified parameters, state, and cwnd.
106
356
    pub(crate) fn new(params: VegasParams, state: &State, cwnd: CongestionWindow) -> Self {
107
356
        Self {
108
356
            params,
109
356
            bdp: BdpEstimator::default(),
110
356
            num_cell_until_sendme: cwnd.sendme_inc(),
111
356
            num_inflight: 0,
112
356
            num_sendme_per_cwnd: 0,
113
356
            num_sendme_until_cwnd_update: cwnd.update_rate(state),
114
356
            cwnd,
115
356
            is_blocked_on_chan: false,
116
356
        }
117
356
    }
118
}
119

            
120
impl CongestionControlAlgorithm for Vegas {
121
12
    fn uses_stream_sendme(&self) -> bool {
122
        // Not allowed as in Vegas doesn't need them.
123
12
        false
124
12
    }
125

            
126
76
    fn uses_xon_xoff(&self) -> bool {
127
76
        true
128
76
    }
129

            
130
1200
    fn is_next_cell_sendme(&self) -> bool {
131
        // Matching inflight number to the SENDME increment, time to send a SENDME. Contrary to
132
        // C-tor, this is called after num_inflight is incremented.
133
1200
        self.num_inflight.is_multiple_of(self.cwnd.sendme_inc())
134
1200
    }
135

            
136
9380
    fn can_send(&self) -> bool {
137
9380
        self.num_inflight < self.cwnd.get()
138
9380
    }
139

            
140
500
    fn cwnd(&self) -> Option<CongestionWindow> {
141
500
        Some(self.cwnd)
142
500
    }
143

            
144
    /// Called when a SENDME cell is received.
145
    ///
146
    /// This is where the Vegas algorithm magic happens entirely. For every SENDME we get, the
147
    /// entire state is updated which usually result in the congestion window being changed.
148
    ///
149
    /// An error is returned if there is a protocol violation with regards to flow or congestion
150
    /// control.
151
    ///
152
    /// Spec: prop324 section 3.3 (TOR_VEGAS)
153
    /// C-tor: congestion_control_vegas_process_sendme() in congestion_control_vegas.c
154
156
    fn sendme_received(
155
156
        &mut self,
156
156
        state: &mut State,
157
156
        rtt: &mut RoundtripTimeEstimator,
158
156
        signals: CongestionSignals,
159
156
    ) -> Result<()> {
160
        // Update the countdown until we need to update the congestion window.
161
156
        self.num_sendme_until_cwnd_update = self.num_sendme_until_cwnd_update.saturating_sub(1);
162
        // We just got a SENDME so decrement the amount of expected SENDMEs for a cwnd.
163
156
        self.num_sendme_per_cwnd = self.num_sendme_per_cwnd.saturating_sub(1);
164

            
165
        // From here, C-tor proceeds to update the RTT and BDP (circuit estimates). The RTT is
166
        // updated before this is called and so the "rtt" object is up to date with the latest. As
167
        // for the BDP, we update it now. See C-tor congestion_control_update_circuit_estimates().
168

            
169
        // Update the BDP estimator even if the RTT estimator is not ready. If that is the case,
170
        // we'll estimate a BDP value to bootstrap.
171
156
        self.bdp.update(&self.cwnd, rtt, &signals);
172

            
173
        // Evaluate if we changed state on the blocked chan. This is done in the BDP update function
174
        // in C-tor. Instead, we do it now after the update of the BDP value.
175
156
        if rtt.is_ready() {
176
156
            if signals.channel_blocked {
177
                // Going from non blocked to block, it is an immediate congestion signal so reset the
178
                // number of sendme per cwnd because we are about to reevaluate it.
179
6
                if !self.is_blocked_on_chan {
180
                    self.num_sendme_until_cwnd_update = 0;
181
6
                }
182
            } else {
183
                // Going from blocked to non block, need to reevaluate the cwnd and so reset num
184
                // sendme.
185
150
                if self.is_blocked_on_chan {
186
                    self.num_sendme_until_cwnd_update = 0;
187
150
                }
188
            }
189
        }
190
156
        self.is_blocked_on_chan = signals.channel_blocked;
191

            
192
        // Only run the algorithm if the RTT estimator is ready or we have a blocked channel.
193
156
        if !rtt.is_ready() && !self.is_blocked_on_chan {
194
            // The inflight value can never be below a sendme_inc because every time a cell is sent,
195
            // inflight is incremented and we only end up decrementing if we receive a valid
196
            // authenticated SENDME which is always after the sendme_inc value that we get that.
197
            debug_assert!(self.num_inflight >= self.cwnd.sendme_inc());
198
            self.num_inflight = self.num_inflight.saturating_sub(self.cwnd.sendme_inc());
199
            return Ok(());
200
156
        }
201

            
202
        // The queue use is the amount in which our cwnd is above BDP;
203
        // if it is below, then 0 queue use.
204
156
        let queue_use = self.cwnd.get().saturating_sub(self.bdp.get());
205

            
206
        // Evaluate if the congestion window has became full or not.
207
156
        self.cwnd.eval_fullness(
208
156
            self.num_inflight,
209
156
            self.params.cwnd_full_gap(),
210
156
            self.params.cwnd_full_min_pct().as_percent(),
211
        );
212

            
213
        // Spec: See the pseudocode of TOR_VEGAS with RFC3742
214
156
        if state.in_slow_start() {
215
128
            if queue_use < self.params.cell_in_queue_params().gamma() && !self.is_blocked_on_chan {
216
                // If the congestion window is not fully in use, skip any increment in slow start.
217
122
                if self.cwnd.is_full() {
218
                    // This is the "Limited Slow Start" increment.
219
104
                    let inc = self
220
104
                        .cwnd
221
104
                        .rfc3742_ss_inc(self.params.cell_in_queue_params().ss_cwnd_cap());
222

            
223
                    // Check if inc is less than what we would do in steady-state avoidance. Note
224
                    // that this is likely never to happen in practice. If so, exit slow start.
225
104
                    if (inc * self.cwnd.sendme_per_cwnd())
226
104
                        <= (self.cwnd.increment() * self.cwnd.increment_rate())
227
                    {
228
                        *state = State::Steady;
229
104
                    }
230
18
                }
231
6
            } else {
232
6
                // Congestion signal: Set cwnd to gamma threshold
233
6
                self.cwnd
234
6
                    .set(self.bdp.get() + self.params.cell_in_queue_params().gamma());
235
6
                // Exit slow start due to congestion signal.
236
6
                *state = State::Steady;
237
6
            }
238

            
239
            // Max the window and exit slow start.
240
128
            if self.cwnd.get() >= self.params.ss_cwnd_max() {
241
                self.cwnd.set(self.params.ss_cwnd_max());
242
                *state = State::Steady;
243
128
            }
244
28
        } else if self.num_sendme_until_cwnd_update == 0 {
245
            // Once in steady state, we only update once per window.
246
28
            if queue_use > self.params.cell_in_queue_params().delta() {
247
4
                // Above delta threshold, drop cwnd down to the delta.
248
4
                self.cwnd.set(
249
4
                    self.bdp.get() + self.params.cell_in_queue_params().delta()
250
4
                        - self.cwnd.increment(),
251
4
                );
252
24
            } else if queue_use > self.params.cell_in_queue_params().beta()
253
20
                || self.is_blocked_on_chan
254
8
            {
255
8
                // Congestion signal: Above beta or if channel is blocked, decrement window.
256
8
                self.cwnd.dec();
257
16
            } else if self.cwnd.is_full() && queue_use < self.params.cell_in_queue_params().alpha()
258
10
            {
259
10
                // Congestion window is full and the queue usage is below alpha, increment.
260
10
                self.cwnd.inc();
261
10
            }
262
        }
263

            
264
        // Reset our counters if they reached their bottom.
265
156
        if self.num_sendme_until_cwnd_update == 0 {
266
156
            self.num_sendme_until_cwnd_update = self.cwnd.update_rate(state);
267
156
        }
268
156
        if self.num_sendme_per_cwnd == 0 {
269
26
            self.num_sendme_per_cwnd = self.cwnd.sendme_per_cwnd();
270
130
        }
271

            
272
        // Decide if enough time has passed to reset the cwnd.
273
156
        if self.params.cwnd_full_per_cwnd() != 0 {
274
156
            if self.num_sendme_per_cwnd == self.cwnd.sendme_per_cwnd() {
275
26
                self.cwnd.reset_full();
276
130
            }
277
        } else if self.num_sendme_until_cwnd_update == self.cwnd.update_rate(state) {
278
            self.cwnd.reset_full();
279
        }
280

            
281
        // Finally, update the inflight now that we have a SENDME.
282
156
        self.num_inflight = self.num_inflight.saturating_sub(self.cwnd.sendme_inc());
283
156
        Ok(())
284
156
    }
285

            
286
    fn sendme_sent(&mut self) -> Result<()> {
287
        // SENDME is on the wire, set our counter until next one.
288
        self.num_cell_until_sendme = self.cwnd.sendme_inc();
289
        Ok(())
290
    }
291

            
292
52
    fn data_received(&mut self) -> Result<bool> {
293
52
        if self.num_cell_until_sendme == 0 {
294
            // This is not a protocol violation, it is a code flow error and so don't close the
295
            // circuit by sending back an Error. Catching this prevents from sending two SENDMEs
296
            // back to back. We recover from this but scream very loudly.
297
            error_report!(internal!("Congestion control unexptected data cell"), "");
298
            return Ok(false);
299
52
        }
300

            
301
        // Decrement the expected window.
302
52
        self.num_cell_until_sendme = self.num_cell_until_sendme.saturating_sub(1);
303

            
304
        // Reaching zero, lets inform the caller a SENDME needs to be sent. This counter is reset
305
        // when the SENDME is actually sent.
306
52
        Ok(self.num_cell_until_sendme == 0)
307
52
    }
308

            
309
1200
    fn data_sent(&mut self) -> Result<()> {
310
        // This can be above cwnd because that cwnd can shrink while we are still sending data.
311
1200
        self.num_inflight = self.num_inflight.saturating_add(1);
312
1200
        Ok(())
313
1200
    }
314

            
315
    #[cfg(feature = "conflux")]
316
16
    fn inflight(&self) -> Option<u32> {
317
16
        Some(self.num_inflight)
318
16
    }
319

            
320
    #[cfg(test)]
321
12
    fn send_window(&self) -> u32 {
322
12
        self.cwnd.get()
323
12
    }
324

            
325
56
    fn algorithm(&self) -> Algorithm {
326
56
        Algorithm::Vegas(self.params)
327
56
    }
328
}
329

            
330
#[cfg(test)]
331
pub(crate) mod test {
332
    // @@ begin test lint list maintained by maint/add_warning @@
333
    #![allow(clippy::bool_assert_comparison)]
334
    #![allow(clippy::clone_on_copy)]
335
    #![allow(clippy::dbg_macro)]
336
    #![allow(clippy::mixed_attributes_style)]
337
    #![allow(clippy::print_stderr)]
338
    #![allow(clippy::print_stdout)]
339
    #![allow(clippy::single_char_pattern)]
340
    #![allow(clippy::unwrap_used)]
341
    #![allow(clippy::unchecked_time_subtraction)]
342
    #![allow(clippy::useless_vec)]
343
    #![allow(clippy::needless_pass_by_value)]
344
    //! <!-- @@ end test lint list maintained by maint/add_warning @@ -->
345

            
346
    use std::{
347
        collections::VecDeque,
348
        time::{Duration, Instant},
349
    };
350
    use tor_units::Percentage;
351

            
352
    use super::*;
353
    use crate::congestion::{
354
        params::VegasParamsBuilder,
355
        test_utils::{new_cwnd, new_rtt_estimator},
356
    };
357

            
358
    impl Vegas {
359
        /// Set the number of inflight cell.
360
        pub(crate) fn set_inflight(&mut self, v: u32) {
361
            self.num_inflight = v;
362
        }
363
        /// Return the state of the blocked on chan flag.
364
        fn is_blocked_on_chan(&self) -> bool {
365
            self.is_blocked_on_chan
366
        }
367
        /// Set the state of the blocked on chan flag.
368
        fn set_is_blocked_on_chan(&mut self, v: bool) {
369
            self.is_blocked_on_chan = v;
370
        }
371
    }
372

            
373
    /// The test vector parameters. They have the exact same name as in C-tor in order to help
374
    /// matching them and avoid confusion.
375
    #[derive(Debug)]
376
    struct TestVectorParams {
377
        // Inbound parameters.
378
        sent_usec_in: u64,
379
        got_sendme_usec_in: u64,
380
        or_conn_blocked_in: bool,
381
        inflight_in: u32,
382
        // Expected outbound parameters.
383
        ewma_rtt_usec_out: u32,
384
        min_rtt_usec_out: u32,
385
        cwnd_out: u32,
386
        in_slow_start_out: bool,
387
        cwnd_full_out: bool,
388
        blocked_chan_out: bool,
389
    }
390

            
391
    impl From<[u32; 10]> for TestVectorParams {
392
        fn from(arr: [u32; 10]) -> Self {
393
            Self {
394
                sent_usec_in: u64::from(arr[0]),
395
                got_sendme_usec_in: u64::from(arr[1]),
396
                or_conn_blocked_in: arr[2] == 1,
397
                inflight_in: arr[3],
398
                ewma_rtt_usec_out: arr[4],
399
                min_rtt_usec_out: arr[5],
400
                cwnd_out: arr[6],
401
                in_slow_start_out: arr[7] == 1,
402
                cwnd_full_out: arr[8] == 1,
403
                blocked_chan_out: arr[9] == 1,
404
            }
405
        }
406
    }
407

            
408
    struct VegasTest {
409
        params: VecDeque<TestVectorParams>,
410
        rtt: RoundtripTimeEstimator,
411
        state: State,
412
        vegas: Vegas,
413
    }
414

            
415
    impl VegasTest {
416
        fn new(vec: Vec<[u32; 10]>) -> Self {
417
            let mut params = VecDeque::new();
418
            for values in vec {
419
                params.push_back(values.into());
420
            }
421
            let state = State::default();
422
            Self {
423
                params,
424
                rtt: new_rtt_estimator(),
425
                vegas: Vegas::new(build_vegas_params(), &state, new_cwnd()),
426
                state,
427
            }
428
        }
429

            
430
        fn run_once(&mut self, p: &TestVectorParams) {
431
            eprintln!("Testing vector: {:?}", p);
432
            // Set the inflight and channel blocked value from the test vector.
433
            self.vegas.set_inflight(p.inflight_in);
434
            self.vegas.set_is_blocked_on_chan(p.or_conn_blocked_in);
435

            
436
            let now = Instant::now();
437
            self.rtt
438
                .expect_sendme(now + Duration::from_micros(p.sent_usec_in));
439
            let ret = self.rtt.update(
440
                now + Duration::from_micros(p.got_sendme_usec_in),
441
                &self.state,
442
                &self.vegas.cwnd().expect("No CWND"),
443
            );
444
            assert!(ret.is_ok());
445

            
446
            let signals = CongestionSignals::new(p.or_conn_blocked_in, 0);
447
            let ret = self
448
                .vegas
449
                .sendme_received(&mut self.state, &mut self.rtt, signals);
450
            assert!(ret.is_ok());
451

            
452
            assert_eq!(self.rtt.ewma_rtt_usec().unwrap(), p.ewma_rtt_usec_out);
453
            assert_eq!(self.rtt.min_rtt_usec().unwrap(), p.min_rtt_usec_out);
454
            assert_eq!(self.vegas.cwnd().expect("No CWND").get(), p.cwnd_out);
455
            assert_eq!(
456
                self.vegas.cwnd().expect("No CWND").is_full(),
457
                p.cwnd_full_out
458
            );
459
            assert_eq!(self.state.in_slow_start(), p.in_slow_start_out);
460
            assert_eq!(self.vegas.is_blocked_on_chan(), p.blocked_chan_out);
461
        }
462

            
463
        fn run(&mut self) {
464
            while let Some(param) = self.params.pop_front() {
465
                self.run_once(&param);
466
            }
467
        }
468
    }
469

            
470
    pub(crate) fn build_vegas_params() -> VegasParams {
471
        const OUTBUF_CELLS: u32 = 62;
472
        VegasParamsBuilder::default()
473
            .cell_in_queue_params(
474
                (
475
                    3 * OUTBUF_CELLS, // alpha
476
                    4 * OUTBUF_CELLS, // beta
477
                    5 * OUTBUF_CELLS, // delta
478
                    3 * OUTBUF_CELLS, // gamma
479
                    600,              // ss_cap
480
                )
481
                    .into(),
482
            )
483
            .ss_cwnd_max(5_000)
484
            .cwnd_full_gap(4)
485
            .cwnd_full_min_pct(Percentage::new(25))
486
            .cwnd_full_per_cwnd(1)
487
            .build()
488
            .expect("Unable to build Vegas parameters")
489
    }
490

            
491
    #[test]
492
    fn test_vectors() {
493
        let vec1 = vec![
494
            [100000, 200000, 0, 124, 100000, 100000, 155, 1, 0, 0],
495
            [200000, 300000, 0, 155, 100000, 100000, 186, 1, 1, 0],
496
            [350000, 500000, 0, 186, 133333, 100000, 217, 1, 1, 0],
497
            [500000, 550000, 0, 217, 77777, 77777, 248, 1, 1, 0],
498
            [600000, 700000, 0, 248, 92592, 77777, 279, 1, 1, 0],
499
            [700000, 750000, 0, 279, 64197, 64197, 310, 1, 0, 0], // Fullness expiry
500
            [750000, 875000, 0, 310, 104732, 64197, 341, 1, 1, 0],
501
            [875000, 900000, 0, 341, 51577, 51577, 372, 1, 1, 0],
502
            [900000, 950000, 0, 279, 50525, 50525, 403, 1, 1, 0],
503
            [950000, 1000000, 0, 279, 50175, 50175, 434, 1, 1, 0],
504
            [1000000, 1050000, 0, 279, 50058, 50058, 465, 1, 1, 0],
505
            [1050000, 1100000, 0, 279, 50019, 50019, 496, 1, 1, 0],
506
            [1100000, 1150000, 0, 279, 50006, 50006, 527, 1, 1, 0],
507
            [1150000, 1200000, 0, 279, 50002, 50002, 558, 1, 1, 0],
508
            [1200000, 1250000, 0, 550, 50000, 50000, 589, 1, 1, 0],
509
            [1250000, 1300000, 0, 550, 50000, 50000, 620, 1, 0, 0], // Fullness expiry
510
            [1300000, 1350000, 0, 550, 50000, 50000, 635, 1, 1, 0],
511
            [1350000, 1400000, 0, 550, 50000, 50000, 650, 1, 1, 0],
512
            [1400000, 1450000, 0, 150, 50000, 50000, 650, 1, 0, 0], // cwnd not full
513
            [1450000, 1500000, 0, 150, 50000, 50000, 650, 1, 0, 0], // cwnd not full
514
            [1500000, 1550000, 0, 550, 50000, 50000, 664, 1, 1, 0], // cwnd full
515
            [1500000, 1600000, 0, 550, 83333, 50000, 584, 0, 1, 0], // gamma exit
516
            [1600000, 1650000, 0, 550, 61111, 50000, 585, 0, 1, 0], // alpha
517
            [1650000, 1700000, 0, 550, 53703, 50000, 586, 0, 1, 0],
518
            [1700000, 1750000, 0, 100, 51234, 50000, 586, 0, 0, 0], // alpha, not full
519
            [1750000, 1900000, 0, 100, 117078, 50000, 559, 0, 0, 0], // delta, not full
520
            [1900000, 2000000, 0, 100, 105692, 50000, 558, 0, 0, 0], // beta, not full
521
            [2000000, 2075000, 0, 500, 85230, 50000, 558, 0, 1, 0], // no change
522
            [2075000, 2125000, 1, 500, 61743, 50000, 557, 0, 1, 1], // beta, blocked
523
            [2125000, 2150000, 0, 500, 37247, 37247, 558, 0, 1, 0], // alpha
524
            [2150000, 2350000, 0, 500, 145749, 37247, 451, 0, 1, 0], // delta
525
        ];
526
        VegasTest::new(vec1).run();
527

            
528
        let vec2 = vec![
529
            [100000, 200000, 0, 124, 100000, 100000, 155, 1, 0, 0],
530
            [200000, 300000, 0, 155, 100000, 100000, 186, 1, 1, 0],
531
            [350000, 500000, 0, 186, 133333, 100000, 217, 1, 1, 0],
532
            [500000, 550000, 1, 217, 77777, 77777, 403, 0, 1, 1], // ss exit, blocked
533
            [600000, 700000, 0, 248, 92592, 77777, 404, 0, 1, 0], // alpha
534
            [700000, 750000, 1, 404, 64197, 64197, 403, 0, 0, 1], // blocked beta
535
            [750000, 875000, 0, 403, 104732, 64197, 404, 0, 1, 0],
536
        ];
537
        VegasTest::new(vec2).run();
538

            
539
        let vec3 = vec![
540
            [18258527, 19002938, 0, 83, 744411, 744411, 155, 1, 0, 0],
541
            [18258580, 19254257, 0, 52, 911921, 744411, 186, 1, 1, 0],
542
            [20003224, 20645298, 0, 164, 732023, 732023, 217, 1, 1, 0],
543
            [20003367, 21021444, 0, 133, 922725, 732023, 248, 1, 1, 0],
544
            [20003845, 21265508, 0, 102, 1148683, 732023, 279, 1, 1, 0],
545
            [20003975, 21429157, 0, 71, 1333015, 732023, 310, 1, 0, 0],
546
            [20004309, 21707677, 0, 40, 1579917, 732023, 310, 1, 0, 0],
547
        ];
548
        VegasTest::new(vec3).run();
549

            
550
        let vec4 = vec![
551
            [358297091, 358854163, 0, 83, 557072, 557072, 155, 1, 0, 0],
552
            [358297649, 359123845, 0, 52, 736488, 557072, 186, 1, 1, 0],
553
            [359492879, 359995330, 0, 186, 580463, 557072, 217, 1, 1, 0],
554
            [359493043, 360489243, 0, 217, 857621, 557072, 248, 1, 1, 0],
555
            [359493232, 360489673, 0, 248, 950167, 557072, 279, 1, 1, 0],
556
            [359493795, 360489971, 0, 279, 980839, 557072, 310, 1, 0, 0],
557
            [359493918, 360490248, 0, 310, 991166, 557072, 341, 1, 1, 0],
558
            [359494029, 360716465, 0, 341, 1145346, 557072, 372, 1, 1, 0],
559
            [359996888, 360948867, 0, 372, 1016434, 557072, 403, 1, 1, 0],
560
            [359996979, 360949330, 0, 403, 973712, 557072, 434, 1, 1, 0],
561
            [360489528, 361113615, 0, 434, 740628, 557072, 465, 1, 1, 0],
562
            [360489656, 361281604, 0, 465, 774841, 557072, 496, 1, 1, 0],
563
            [360489837, 361500461, 0, 496, 932029, 557072, 482, 0, 1, 0],
564
            [360489963, 361500631, 0, 482, 984455, 557072, 482, 0, 1, 0],
565
            [360490117, 361842481, 0, 482, 1229727, 557072, 481, 0, 1, 0],
566
        ];
567
        VegasTest::new(vec4).run();
568
    }
569
}