Sebastian Jansson | 8d3e4bd | 2019-07-31 18:33:17 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | #ifndef TEST_NETWORK_SIMULATED_NETWORK_NODE_H_ |
| 11 | #define TEST_NETWORK_SIMULATED_NETWORK_NODE_H_ |
| 12 | |
| 13 | #include "api/test/network_emulation_manager.h" |
| 14 | #include "call/simulated_network.h" |
| 15 | |
| 16 | namespace webrtc { |
| 17 | namespace test { |
| 18 | // Helper struct to simplify creation of simulated network behaviors. |
| 19 | struct SimulatedNetworkNode { |
| 20 | SimulatedNetwork* simulation; |
| 21 | EmulatedNetworkNode* node; |
| 22 | class Builder { |
| 23 | public: |
| 24 | Builder(); |
| 25 | explicit Builder(NetworkEmulationManager* net); |
| 26 | Builder& config(SimulatedNetwork::Config config); |
| 27 | Builder& delay_ms(int queue_delay_ms); |
| 28 | Builder& capacity_kbps(int link_capacity_kbps); |
| 29 | Builder& capacity_Mbps(int link_capacity_Mbps); |
| 30 | Builder& loss(double loss_rate); |
| 31 | SimulatedNetworkNode Build() const; |
| 32 | SimulatedNetworkNode Build(NetworkEmulationManager* net) const; |
| 33 | |
| 34 | private: |
| 35 | NetworkEmulationManager* const net_ = nullptr; |
| 36 | SimulatedNetwork::Config config_; |
| 37 | }; |
| 38 | }; |
| 39 | } // namespace test |
| 40 | } // namespace webrtc |
| 41 | |
| 42 | #endif // TEST_NETWORK_SIMULATED_NETWORK_NODE_H_ |