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
    params::VegasParams, rtt::RoundtripTimeEstimator, CongestionControlAlgorithm,
9
    CongestionSignals, CongestionWindow, State,
10
};
11
use crate::Result;
12

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

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

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

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

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

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

            
117
impl CongestionControlAlgorithm for Vegas {
118
    fn uses_stream_sendme(&self) -> bool {
119
        // Not allowed as in Vegas doesn't need them.
120
        false
121
    }
122
    fn is_next_cell_sendme(&self) -> bool {
123
        // Matching inflight number to the SENDME increment, time to send a SENDME. Contrary to
124
        // C-tor, this is called after num_inflight is incremented.
125
        self.num_inflight % self.cwnd.sendme_inc() == 0
126
    }
127

            
128
8
    fn can_send(&self) -> bool {
129
8
        self.num_inflight < self.cwnd.get()
130
8
    }
131

            
132
360
    fn cwnd(&self) -> Option<&CongestionWindow> {
133
360
        Some(&self.cwnd)
134
360
    }
135

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

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

            
161
120
        // Update the BDP estimator even if the RTT estimator is not ready. If that is the case,
162
120
        // we'll estimate a BDP value to bootstrap.
163
120
        self.bdp.update(&self.cwnd, rtt, &signals);
164
120

            
165
120
        // Evaluate if we changed state on the blocked chan. This is done in the BDP update function
166
120
        // in C-tor. Instead, we do it now after the update of the BDP value.
167
120
        if rtt.is_ready() {
168
120
            if signals.channel_blocked {
169
                // Going from non blocked to block, it is an immediate congestion signal so reset the
170
                // number of sendme per cwnd because we are about to reevaluate it.
171
6
                if !self.is_blocked_on_chan {
172
                    self.num_sendme_until_cwnd_update = 0;
173
6
                }
174
            } else {
175
                // Going from blocked to non block, need to reevaluate the cwnd and so reset num
176
                // sendme.
177
114
                if self.is_blocked_on_chan {
178
                    self.num_sendme_until_cwnd_update = 0;
179
114
                }
180
            }
181
        }
182
120
        self.is_blocked_on_chan = signals.channel_blocked;
183
120

            
184
120
        // Only run the algorithm if the RTT estimator is ready or we have a blocked channel.
185
120
        if !rtt.is_ready() && !self.is_blocked_on_chan {
186
            // The inflight value can never be below a sendme_inc because every time a cell is sent,
187
            // inflight is incremented and we only end up decrementing if we receive a valid
188
            // authenticated SENDME which is always after the sendme_inc value that we get that.
189
            debug_assert!(self.num_inflight >= self.cwnd.sendme_inc());
190
            self.num_inflight = self.num_inflight.saturating_sub(self.cwnd.sendme_inc());
191
            return Ok(());
192
120
        }
193
120

            
194
120
        // The queue use is the amount in which our cwnd is above BDP;
195
120
        // if it is below, then 0 queue use.
196
120
        let queue_use = self.cwnd.get().saturating_sub(self.bdp.get());
197
120

            
198
120
        // Evaluate if the congestion window has became full or not.
199
120
        self.cwnd.eval_fullness(
200
120
            self.num_inflight,
201
120
            self.params.cwnd_full_gap(),
202
120
            self.params.cwnd_full_min_pct().as_percent(),
203
120
        );
204
120

            
205
120
        // Spec: See the pseudocode of TOR_VEGAS with RFC3742
206
120
        if state.in_slow_start() {
207
92
            if queue_use < self.params.cell_in_queue_params().gamma() && !self.is_blocked_on_chan {
208
                // If the congestion window is not fully in use, skip any increment in slow start.
209
86
                if self.cwnd.is_full() {
210
                    // This is the "Limited Slow Start" increment.
211
80
                    let inc = self
212
80
                        .cwnd
213
80
                        .rfc3742_ss_inc(self.params.cell_in_queue_params().ss_cwnd_cap());
214
80

            
215
80
                    // Check if inc is less than what we would do in steady-state avoidance. Note
216
80
                    // that this is likely never to happen in practice. If so, exit slow start.
217
80
                    if (inc * self.cwnd.sendme_per_cwnd())
218
80
                        <= (self.cwnd.increment() * self.cwnd.increment_rate())
219
                    {
220
                        *state = State::Steady;
221
80
                    }
222
6
                }
223
6
            } else {
224
6
                // Congestion signal: Set cwnd to gamma threshold
225
6
                self.cwnd
226
6
                    .set(self.bdp.get() + self.params.cell_in_queue_params().gamma());
227
6
                // Exit slow start due to congestion signal.
228
6
                *state = State::Steady;
229
6
            }
230

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

            
256
        // Reset our counters if they reached their bottom.
257
120
        if self.num_sendme_until_cwnd_update == 0 {
258
120
            self.num_sendme_until_cwnd_update = self.cwnd.update_rate(state);
259
120
        }
260
120
        if self.num_sendme_per_cwnd == 0 {
261
18
            self.num_sendme_per_cwnd = self.cwnd.sendme_per_cwnd();
262
102
        }
263

            
264
        // Decide if enough time has passed to reset the cwnd.
265
120
        if self.params.cwnd_full_per_cwnd() != 0 {
266
120
            if self.num_sendme_per_cwnd == self.cwnd.sendme_per_cwnd() {
267
18
                self.cwnd.reset_full();
268
102
            }
269
        } else if self.num_sendme_until_cwnd_update == self.cwnd.update_rate(state) {
270
            self.cwnd.reset_full();
271
        }
272

            
273
        // Finally, update the inflight now that we have a SENDME.
274
120
        self.num_inflight = self.num_inflight.saturating_sub(self.cwnd.sendme_inc());
275
120
        Ok(())
276
120
    }
277

            
278
    fn sendme_sent(&mut self) -> Result<()> {
279
        // SENDME is on the wire, set our counter until next one.
280
        self.num_cell_until_sendme = self.cwnd.sendme_inc();
281
        Ok(())
282
    }
283

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

            
293
        // Decrement the expected window.
294
        self.num_cell_until_sendme = self.num_cell_until_sendme.saturating_sub(1);
295

            
296
        // Reaching zero, lets inform the caller a SENDME needs to be sent. This counter is reset
297
        // when the SENDME is actually sent.
298
        Ok(self.num_cell_until_sendme == 0)
299
    }
300

            
301
    fn data_sent(&mut self) -> Result<()> {
302
        // This can be above cwnd because that cwnd can shrink while we are still sending data.
303
        self.num_inflight = self.num_inflight.saturating_add(1);
304
        Ok(())
305
    }
306

            
307
    #[cfg(feature = "conflux")]
308
    fn inflight(&self) -> Option<u32> {
309
        Some(self.num_inflight)
310
    }
311

            
312
    #[cfg(test)]
313
    fn send_window(&self) -> u32 {
314
        self.cwnd.get()
315
    }
316
}
317

            
318
#[cfg(test)]
319
#[allow(clippy::print_stderr)]
320
pub(crate) mod test {
321
    // @@ begin test lint list maintained by maint/add_warning @@
322
    #![allow(clippy::bool_assert_comparison)]
323
    #![allow(clippy::clone_on_copy)]
324
    #![allow(clippy::dbg_macro)]
325
    #![allow(clippy::mixed_attributes_style)]
326
    #![allow(clippy::print_stderr)]
327
    #![allow(clippy::print_stdout)]
328
    #![allow(clippy::single_char_pattern)]
329
    #![allow(clippy::unwrap_used)]
330
    #![allow(clippy::unchecked_duration_subtraction)]
331
    #![allow(clippy::useless_vec)]
332
    #![allow(clippy::needless_pass_by_value)]
333
    //! <!-- @@ end test lint list maintained by maint/add_warning @@ -->
334

            
335
    use std::{
336
        collections::VecDeque,
337
        time::{Duration, Instant},
338
    };
339
    use tor_units::Percentage;
340

            
341
    use super::*;
342
    use crate::congestion::{
343
        params::VegasParamsBuilder,
344
        test_utils::{new_cwnd, new_rtt_estimator},
345
    };
346

            
347
    impl Vegas {
348
        /// Set the number of inflight cell.
349
        pub(crate) fn set_inflight(&mut self, v: u32) {
350
            self.num_inflight = v;
351
        }
352
        /// Return the state of the blocked on chan flag.
353
        fn is_blocked_on_chan(&self) -> bool {
354
            self.is_blocked_on_chan
355
        }
356
        /// Set the state of the blocked on chan flag.
357
        fn set_is_blocked_on_chan(&mut self, v: bool) {
358
            self.is_blocked_on_chan = v;
359
        }
360
    }
361

            
362
    /// The test vector parameters. They have the exact same name as in C-tor in order to help
363
    /// matching them and avoid confusion.
364
    #[derive(Debug)]
365
    struct TestVectorParams {
366
        // Inbound parameters.
367
        sent_usec_in: u64,
368
        got_sendme_usec_in: u64,
369
        or_conn_blocked_in: bool,
370
        inflight_in: u32,
371
        // Expected outbound parameters.
372
        ewma_rtt_usec_out: u32,
373
        min_rtt_usec_out: u32,
374
        cwnd_out: u32,
375
        in_slow_start_out: bool,
376
        cwnd_full_out: bool,
377
        blocked_chan_out: bool,
378
    }
379

            
380
    impl From<[u32; 10]> for TestVectorParams {
381
        fn from(arr: [u32; 10]) -> Self {
382
            Self {
383
                sent_usec_in: u64::from(arr[0]),
384
                got_sendme_usec_in: u64::from(arr[1]),
385
                or_conn_blocked_in: arr[2] == 1,
386
                inflight_in: arr[3],
387
                ewma_rtt_usec_out: arr[4],
388
                min_rtt_usec_out: arr[5],
389
                cwnd_out: arr[6],
390
                in_slow_start_out: arr[7] == 1,
391
                cwnd_full_out: arr[8] == 1,
392
                blocked_chan_out: arr[9] == 1,
393
            }
394
        }
395
    }
396

            
397
    struct VegasTest {
398
        params: VecDeque<TestVectorParams>,
399
        rtt: RoundtripTimeEstimator,
400
        state: State,
401
        vegas: Vegas,
402
    }
403

            
404
    impl VegasTest {
405
        fn new(vec: Vec<[u32; 10]>) -> Self {
406
            let mut params = VecDeque::new();
407
            for values in vec {
408
                params.push_back(values.into());
409
            }
410
            let state = State::default();
411
            Self {
412
                params,
413
                rtt: new_rtt_estimator(),
414
                vegas: Vegas::new(&build_vegas_params(), &state, new_cwnd()),
415
                state,
416
            }
417
        }
418

            
419
        fn run_once(&mut self, p: &TestVectorParams) {
420
            eprintln!("Testing vector: {:?}", p);
421
            // Set the inflight and channel blocked value from the test vector.
422
            self.vegas.set_inflight(p.inflight_in);
423
            self.vegas.set_is_blocked_on_chan(p.or_conn_blocked_in);
424

            
425
            let now = Instant::now();
426
            self.rtt
427
                .expect_sendme(now + Duration::from_micros(p.sent_usec_in));
428
            let ret = self.rtt.update(
429
                now + Duration::from_micros(p.got_sendme_usec_in),
430
                &self.state,
431
                self.vegas.cwnd().expect("No CWND"),
432
            );
433
            assert!(ret.is_ok());
434

            
435
            let signals = CongestionSignals::new(p.or_conn_blocked_in, 0);
436
            let ret = self
437
                .vegas
438
                .sendme_received(&mut self.state, &mut self.rtt, signals);
439
            assert!(ret.is_ok());
440

            
441
            assert_eq!(self.rtt.ewma_rtt_usec(), p.ewma_rtt_usec_out);
442
            assert_eq!(self.rtt.min_rtt_usec(), p.min_rtt_usec_out);
443
            assert_eq!(self.vegas.cwnd().expect("No CWND").get(), p.cwnd_out);
444
            assert_eq!(
445
                self.vegas.cwnd().expect("No CWND").is_full(),
446
                p.cwnd_full_out
447
            );
448
            assert_eq!(self.state.in_slow_start(), p.in_slow_start_out);
449
            assert_eq!(self.vegas.is_blocked_on_chan(), p.blocked_chan_out);
450
        }
451

            
452
        fn run(&mut self) {
453
            while let Some(param) = self.params.pop_front() {
454
                self.run_once(&param);
455
            }
456
        }
457
    }
458

            
459
    pub(crate) fn build_vegas_params() -> VegasParams {
460
        const OUTBUF_CELLS: u32 = 62;
461
        VegasParamsBuilder::default()
462
            .cell_in_queue_params(
463
                (
464
                    3 * OUTBUF_CELLS, // alpha
465
                    4 * OUTBUF_CELLS, // beta
466
                    5 * OUTBUF_CELLS, // delta
467
                    3 * OUTBUF_CELLS, // gamma
468
                    600,              // ss_cap
469
                )
470
                    .into(),
471
            )
472
            .ss_cwnd_max(5_000)
473
            .cwnd_full_gap(4)
474
            .cwnd_full_min_pct(Percentage::new(25))
475
            .cwnd_full_per_cwnd(1)
476
            .build()
477
            .expect("Unable to build Vegas parameters")
478
    }
479

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

            
517
        let vec2 = vec![
518
            [100000, 200000, 0, 124, 100000, 100000, 155, 1, 0, 0],
519
            [200000, 300000, 0, 155, 100000, 100000, 186, 1, 1, 0],
520
            [350000, 500000, 0, 186, 133333, 100000, 217, 1, 1, 0],
521
            [500000, 550000, 1, 217, 77777, 77777, 403, 0, 1, 1], // ss exit, blocked
522
            [600000, 700000, 0, 248, 92592, 77777, 404, 0, 1, 0], // alpha
523
            [700000, 750000, 1, 404, 64197, 64197, 403, 0, 0, 1], // blocked beta
524
            [750000, 875000, 0, 403, 104732, 64197, 404, 0, 1, 0],
525
        ];
526
        VegasTest::new(vec2).run();
527

            
528
        let vec3 = vec![
529
            [18258527, 19002938, 0, 83, 744411, 744411, 155, 1, 0, 0],
530
            [18258580, 19254257, 0, 52, 911921, 744411, 186, 1, 1, 0],
531
            [20003224, 20645298, 0, 164, 732023, 732023, 217, 1, 1, 0],
532
            [20003367, 21021444, 0, 133, 922725, 732023, 248, 1, 1, 0],
533
            [20003845, 21265508, 0, 102, 1148683, 732023, 279, 1, 1, 0],
534
            [20003975, 21429157, 0, 71, 1333015, 732023, 310, 1, 0, 0],
535
            [20004309, 21707677, 0, 40, 1579917, 732023, 310, 1, 0, 0],
536
        ];
537
        VegasTest::new(vec3).run();
538

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