This prepares for an upcoming CL removing cross traffic processing when it's not used. Bug: webrtc:10365 Change-Id: I7f1f3998f7f38c2a627b888c3db6b0c459d8271d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133485 Reviewed-by: Artem Titov <titovartem@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27682}
97 lines
3.1 KiB
C++
97 lines
3.1 KiB
C++
/*
|
|
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef TEST_SCENARIO_NETWORK_CROSS_TRAFFIC_H_
|
|
#define TEST_SCENARIO_NETWORK_CROSS_TRAFFIC_H_
|
|
|
|
#include <memory>
|
|
|
|
#include "api/units/data_rate.h"
|
|
#include "api/units/data_size.h"
|
|
#include "api/units/time_delta.h"
|
|
#include "api/units/timestamp.h"
|
|
#include "rtc_base/random.h"
|
|
#include "rtc_base/synchronization/sequence_checker.h"
|
|
#include "test/scenario/column_printer.h"
|
|
#include "test/scenario/network/traffic_route.h"
|
|
|
|
namespace webrtc {
|
|
namespace test {
|
|
|
|
struct RandomWalkConfig {
|
|
int random_seed = 1;
|
|
DataRate peak_rate = DataRate::kbps(100);
|
|
DataSize min_packet_size = DataSize::bytes(200);
|
|
TimeDelta min_packet_interval = TimeDelta::ms(1);
|
|
TimeDelta update_interval = TimeDelta::ms(200);
|
|
double variance = 0.6;
|
|
double bias = -0.1;
|
|
};
|
|
|
|
class RandomWalkCrossTraffic {
|
|
public:
|
|
RandomWalkCrossTraffic(RandomWalkConfig config, TrafficRoute* traffic_route);
|
|
~RandomWalkCrossTraffic();
|
|
|
|
void Process(Timestamp at_time);
|
|
DataRate TrafficRate() const;
|
|
ColumnPrinter StatsPrinter();
|
|
|
|
private:
|
|
SequenceChecker sequence_checker_;
|
|
const RandomWalkConfig config_;
|
|
TrafficRoute* const traffic_route_ RTC_PT_GUARDED_BY(sequence_checker_);
|
|
webrtc::Random random_ RTC_GUARDED_BY(sequence_checker_);
|
|
|
|
Timestamp last_process_time_ RTC_GUARDED_BY(sequence_checker_) =
|
|
Timestamp::MinusInfinity();
|
|
Timestamp last_update_time_ RTC_GUARDED_BY(sequence_checker_) =
|
|
Timestamp::MinusInfinity();
|
|
Timestamp last_send_time_ RTC_GUARDED_BY(sequence_checker_) =
|
|
Timestamp::MinusInfinity();
|
|
double intensity_ RTC_GUARDED_BY(sequence_checker_) = 0;
|
|
DataSize pending_size_ RTC_GUARDED_BY(sequence_checker_) = DataSize::Zero();
|
|
};
|
|
|
|
struct PulsedPeaksConfig {
|
|
DataRate peak_rate = DataRate::kbps(100);
|
|
DataSize min_packet_size = DataSize::bytes(200);
|
|
TimeDelta min_packet_interval = TimeDelta::ms(1);
|
|
TimeDelta send_duration = TimeDelta::ms(100);
|
|
TimeDelta hold_duration = TimeDelta::ms(2000);
|
|
};
|
|
|
|
class PulsedPeaksCrossTraffic {
|
|
public:
|
|
PulsedPeaksCrossTraffic(PulsedPeaksConfig config,
|
|
TrafficRoute* traffic_route);
|
|
~PulsedPeaksCrossTraffic();
|
|
|
|
void Process(Timestamp at_time);
|
|
DataRate TrafficRate() const;
|
|
ColumnPrinter StatsPrinter();
|
|
|
|
private:
|
|
SequenceChecker sequence_checker_;
|
|
const PulsedPeaksConfig config_;
|
|
TrafficRoute* const traffic_route_ RTC_PT_GUARDED_BY(sequence_checker_);
|
|
|
|
Timestamp last_update_time_ RTC_GUARDED_BY(sequence_checker_) =
|
|
Timestamp::MinusInfinity();
|
|
Timestamp last_send_time_ RTC_GUARDED_BY(sequence_checker_) =
|
|
Timestamp::MinusInfinity();
|
|
bool sending_ RTC_GUARDED_BY(sequence_checker_) = false;
|
|
};
|
|
|
|
} // namespace test
|
|
} // namespace webrtc
|
|
|
|
#endif // TEST_SCENARIO_NETWORK_CROSS_TRAFFIC_H_
|