OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_TOOLS_NETWORK_TESTER_TEST_CONTROLLER_H_ | 11 #ifndef WEBRTC_TOOLS_NETWORK_TESTER_TEST_CONTROLLER_H_ |
12 #define WEBRTC_TOOLS_NETWORK_TESTER_TEST_CONTROLLER_H_ | 12 #define WEBRTC_TOOLS_NETWORK_TESTER_TEST_CONTROLLER_H_ |
13 | 13 |
14 #include <array> | 14 #include <array> |
15 #include <limits> | 15 #include <limits> |
16 #include <memory> | 16 #include <memory> |
17 #include <string> | 17 #include <string> |
18 #include <utility> | 18 #include <utility> |
19 | 19 |
| 20 #include "webrtc/base/constructormagic.h" |
20 #include "webrtc/base/ignore_wundef.h" | 21 #include "webrtc/base/ignore_wundef.h" |
21 #include "webrtc/p2p/base/basicpacketsocketfactory.h" | 22 #include "webrtc/p2p/base/basicpacketsocketfactory.h" |
22 #include "webrtc/p2p/base/udptransport.h" | 23 #include "webrtc/p2p/base/udptransport.h" |
| 24 #include "webrtc/tools/network_tester/packet_logger.h" |
23 #include "webrtc/tools/network_tester/packet_sender.h" | 25 #include "webrtc/tools/network_tester/packet_sender.h" |
24 | 26 |
25 #ifdef WEBRTC_NETWORK_TESTER_PROTO | 27 #ifdef WEBRTC_NETWORK_TESTER_PROTO |
26 RTC_PUSH_IGNORING_WUNDEF() | 28 RTC_PUSH_IGNORING_WUNDEF() |
27 #include "webrtc/tools/network_tester/network_tester_packet.pb.h" | 29 #include "webrtc/tools/network_tester/network_tester_packet.pb.h" |
28 RTC_POP_IGNORING_WUNDEF() | 30 RTC_POP_IGNORING_WUNDEF() |
29 using webrtc::network_tester::packet::NetworkTesterPacket; | 31 using webrtc::network_tester::packet::NetworkTesterPacket; |
30 #else | 32 #else |
31 class NetworkTesterPacket; | 33 class NetworkTesterPacket; |
32 #endif // WEBRTC_NETWORK_TESTER_PROTO | 34 #endif // WEBRTC_NETWORK_TESTER_PROTO |
33 | 35 |
34 namespace webrtc { | 36 namespace webrtc { |
35 | 37 |
36 constexpr size_t kEthernetMtu = 1500; | 38 constexpr size_t kEthernetMtu = 1500; |
37 | 39 |
38 class TestController : public sigslot::has_slots<> { | 40 class TestController : public sigslot::has_slots<> { |
39 public: | 41 public: |
40 TestController(int min_port, | 42 TestController(int min_port, |
41 int max_port, | 43 int max_port, |
42 const std::string& config_file_path); | 44 const std::string& config_file_path, |
| 45 const std::string& log_file_path); |
43 | 46 |
44 void Run(); | 47 void Run(); |
45 | 48 |
46 void SendConnectTo(const std::string& hostname, int port); | 49 void SendConnectTo(const std::string& hostname, int port); |
47 | 50 |
48 void SendData(const NetworkTesterPacket& packet, | 51 void SendData(const NetworkTesterPacket& packet, |
49 rtc::Optional<size_t> data_size); | 52 rtc::Optional<size_t> data_size); |
50 | 53 |
51 void OnTestDone(); | 54 void OnTestDone(); |
52 | 55 |
53 bool IsTestDone(); | 56 bool IsTestDone(); |
54 | 57 |
55 private: | 58 private: |
56 void OnReadPacket(rtc::AsyncPacketSocket* socket, | 59 void OnReadPacket(rtc::AsyncPacketSocket* socket, |
57 const char* data, | 60 const char* data, |
58 size_t len, | 61 size_t len, |
59 const rtc::SocketAddress& remote_addr, | 62 const rtc::SocketAddress& remote_addr, |
60 const rtc::PacketTime& packet_time); | 63 const rtc::PacketTime& packet_time); |
61 rtc::ThreadChecker test_controller_thread_checker_; | 64 rtc::ThreadChecker test_controller_thread_checker_; |
62 rtc::SequencedTaskChecker packet_sender_checker_; | 65 rtc::SequencedTaskChecker packet_sender_checker_; |
63 rtc::BasicPacketSocketFactory socket_factory_; | 66 rtc::BasicPacketSocketFactory socket_factory_; |
64 const std::string config_file_path_; | 67 const std::string config_file_path_; |
| 68 PacketLogger packet_logger_; |
65 rtc::CriticalSection local_test_done_lock_; | 69 rtc::CriticalSection local_test_done_lock_; |
66 bool local_test_done_ GUARDED_BY(local_test_done_lock_); | 70 bool local_test_done_ GUARDED_BY(local_test_done_lock_); |
67 bool remote_test_done_; | 71 bool remote_test_done_; |
68 std::array<char, kEthernetMtu> send_data_; | 72 std::array<char, kEthernetMtu> send_data_; |
69 std::unique_ptr<cricket::UdpTransport> udp_transport_; | 73 std::unique_ptr<cricket::UdpTransport> udp_transport_; |
70 std::unique_ptr<PacketSender> packet_sender_; | 74 std::unique_ptr<PacketSender> packet_sender_; |
| 75 |
| 76 RTC_DISALLOW_COPY_AND_ASSIGN(TestController); |
71 }; | 77 }; |
72 | 78 |
73 } // namespace webrtc | 79 } // namespace webrtc |
74 | 80 |
75 #endif // WEBRTC_TOOLS_NETWORK_TESTER_TEST_CONTROLLER_H_ | 81 #endif // WEBRTC_TOOLS_NETWORK_TESTER_TEST_CONTROLLER_H_ |
OLD | NEW |