Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: webrtc/tools/network_tester/test_controller.cc

Issue 2790513002: Add packet logger and server (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "webrtc/tools/network_tester/test_controller.h" 11 #include "webrtc/tools/network_tester/test_controller.h"
12 12
13 namespace webrtc { 13 namespace webrtc {
14 14
15 TestController::TestController(int min_port, 15 TestController::TestController(int min_port,
16 int max_port, 16 int max_port,
17 const std::string& config_file_path) 17 const std::string& config_file_path,
18 const std::string& log_file_path)
18 : config_file_path_(config_file_path), 19 : config_file_path_(config_file_path),
20 packet_logger_(log_file_path),
19 local_test_done_(false), 21 local_test_done_(false),
20 remote_test_done_(false) { 22 remote_test_done_(false) {
21 auto socket = 23 auto socket =
22 std::unique_ptr<rtc::AsyncPacketSocket>(socket_factory_.CreateUdpSocket( 24 std::unique_ptr<rtc::AsyncPacketSocket>(socket_factory_.CreateUdpSocket(
23 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0), min_port, max_port)); 25 rtc::SocketAddress(rtc::GetAnyIP(AF_INET), 0), min_port, max_port));
24 socket->SignalReadPacket.connect(this, &TestController::OnReadPacket); 26 socket->SignalReadPacket.connect(this, &TestController::OnReadPacket);
25 udp_transport_.reset( 27 udp_transport_.reset(
26 new cricket::UdpTransport("signaling transport", std::move(socket))); 28 new cricket::UdpTransport("signaling transport", std::move(socket)));
27 } 29 }
28 30
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 break; 63 break;
62 } 64 }
63 case NetworkTesterPacket::START_SEND: { 65 case NetworkTesterPacket::START_SEND: {
64 packet_sender_.reset(new PacketSender(this, config_file_path_)); 66 packet_sender_.reset(new PacketSender(this, config_file_path_));
65 packet_sender_->StartSending(); 67 packet_sender_->StartSending();
66 break; 68 break;
67 } 69 }
68 case NetworkTesterPacket::TEST_DATA: { 70 case NetworkTesterPacket::TEST_DATA: {
69 packet.set_arrival_timestamp(packet_time.timestamp); 71 packet.set_arrival_timestamp(packet_time.timestamp);
70 packet.set_packet_size(len); 72 packet.set_packet_size(len);
71 // log packet 73 packet_logger_.LogPacket(packet);
72 break; 74 break;
73 } 75 }
74 case NetworkTesterPacket::TEST_DONE: { 76 case NetworkTesterPacket::TEST_DONE: {
75 remote_test_done_ = true; 77 remote_test_done_ = true;
76 break; 78 break;
77 } 79 }
78 default: { RTC_NOTREACHED(); } 80 default: { RTC_NOTREACHED(); }
79 } 81 }
80 } 82 }
81 83
82 void TestController::SendData(const NetworkTesterPacket& packet, 84 void TestController::SendData(const NetworkTesterPacket& packet,
83 rtc::Optional<size_t> data_size) { 85 rtc::Optional<size_t> data_size) {
84 size_t packet_size = packet.ByteSize(); 86 size_t packet_size = packet.ByteSize();
85 send_data_[0] = packet_size; 87 send_data_[0] = packet_size;
86 packet.SerializeToArray(&send_data_[1], std::numeric_limits<char>::max()); 88 packet.SerializeToArray(&send_data_[1], std::numeric_limits<char>::max());
87 if (data_size && *data_size > packet_size) 89 if (data_size && *data_size > packet_size)
88 packet_size = *data_size; 90 packet_size = *data_size;
89 udp_transport_->SendPacket(send_data_.data(), packet_size + 1, 91 udp_transport_->SendPacket(send_data_.data(), packet_size + 1,
90 rtc::PacketOptions(), 0); 92 rtc::PacketOptions(), 0);
91 } 93 }
92 94
93 void TestController::OnTestDone() { 95 void TestController::OnTestDone() {
94 NetworkTesterPacket packet; 96 NetworkTesterPacket packet;
95 packet.set_type(NetworkTesterPacket::TEST_DONE); 97 packet.set_type(NetworkTesterPacket::TEST_DONE);
96 SendData(packet, rtc::Optional<size_t>()); 98 SendData(packet, rtc::Optional<size_t>());
97 local_test_done_ = true; 99 local_test_done_ = true;
98 } 100 }
99 101
100 } // namespace webrtc 102 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698