OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2007 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2007 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 |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 ASSERT_NE(-1, socket->GetOption(Socket::OPT_RCVBUF, &recv_size)); | 1006 ASSERT_NE(-1, socket->GetOption(Socket::OPT_RCVBUF, &recv_size)); |
1007 ASSERT_NE(-1, socket->GetOption(Socket::OPT_SNDBUF, &send_size)); | 1007 ASSERT_NE(-1, socket->GetOption(Socket::OPT_SNDBUF, &send_size)); |
1008 // make sure they are right | 1008 // make sure they are right |
1009 ASSERT_EQ(expected_size, recv_size); | 1009 ASSERT_EQ(expected_size, recv_size); |
1010 ASSERT_EQ(expected_size, send_size); | 1010 ASSERT_EQ(expected_size, send_size); |
1011 | 1011 |
1012 // Check that we can't set NODELAY on a UDP socket. | 1012 // Check that we can't set NODELAY on a UDP socket. |
1013 int current_nd, desired_nd = 1; | 1013 int current_nd, desired_nd = 1; |
1014 ASSERT_EQ(-1, socket->GetOption(Socket::OPT_NODELAY, ¤t_nd)); | 1014 ASSERT_EQ(-1, socket->GetOption(Socket::OPT_NODELAY, ¤t_nd)); |
1015 ASSERT_EQ(-1, socket->SetOption(Socket::OPT_NODELAY, desired_nd)); | 1015 ASSERT_EQ(-1, socket->SetOption(Socket::OPT_NODELAY, desired_nd)); |
1016 | |
1017 // Skip the esimate MTU test for IPv6 for now. | |
1018 if (loopback.family() != AF_INET6) { | |
1019 // Try estimating MTU. | |
1020 std::unique_ptr<AsyncSocket> mtu_socket( | |
1021 ss_->CreateAsyncSocket(loopback.family(), SOCK_DGRAM)); | |
1022 mtu_socket->Bind(SocketAddress(loopback, 0)); | |
1023 uint16_t mtu; | |
1024 // should fail until we connect | |
1025 ASSERT_EQ(-1, mtu_socket->EstimateMTU(&mtu)); | |
1026 mtu_socket->Connect(SocketAddress(loopback, 0)); | |
1027 #if defined(WEBRTC_WIN) | |
1028 // now it should succeed | |
1029 ASSERT_NE(-1, mtu_socket->EstimateMTU(&mtu)); | |
1030 ASSERT_GE(mtu, 1492); // should be at least the 1492 "plateau" on localhost | |
1031 #elif defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) | |
1032 // except on WEBRTC_MAC && !WEBRTC_IOS, where it's not yet implemented | |
1033 ASSERT_EQ(-1, mtu_socket->EstimateMTU(&mtu)); | |
1034 #else | |
1035 // and the behavior seems unpredictable on Linux, | |
1036 // failing on the build machine | |
1037 // but succeeding on my Ubiquity instance. | |
1038 #endif | |
1039 } | |
1040 } | 1016 } |
1041 | 1017 |
1042 void SocketTest::SocketRecvTimestamp(const IPAddress& loopback) { | 1018 void SocketTest::SocketRecvTimestamp(const IPAddress& loopback) { |
1043 std::unique_ptr<Socket> socket( | 1019 std::unique_ptr<Socket> socket( |
1044 ss_->CreateSocket(loopback.family(), SOCK_DGRAM)); | 1020 ss_->CreateSocket(loopback.family(), SOCK_DGRAM)); |
1045 EXPECT_EQ(0, socket->Bind(SocketAddress(loopback, 0))); | 1021 EXPECT_EQ(0, socket->Bind(SocketAddress(loopback, 0))); |
1046 SocketAddress address = socket->GetLocalAddress(); | 1022 SocketAddress address = socket->GetLocalAddress(); |
1047 | 1023 |
1048 int64_t send_time_1 = TimeMicros(); | 1024 int64_t send_time_1 = TimeMicros(); |
1049 socket->SendTo("foo", 3, address); | 1025 socket->SendTo("foo", 3, address); |
(...skipping 11 matching lines...) Expand all Loading... |
1061 socket->RecvFrom(buffer, 3, nullptr, &recv_timestamp_2); | 1037 socket->RecvFrom(buffer, 3, nullptr, &recv_timestamp_2); |
1062 | 1038 |
1063 int64_t system_time_diff = send_time_2 - send_time_1; | 1039 int64_t system_time_diff = send_time_2 - send_time_1; |
1064 int64_t recv_timestamp_diff = recv_timestamp_2 - recv_timestamp_1; | 1040 int64_t recv_timestamp_diff = recv_timestamp_2 - recv_timestamp_1; |
1065 // Compare against the system time at the point of sending, because | 1041 // Compare against the system time at the point of sending, because |
1066 // SleepMs may not sleep for exactly the requested time. | 1042 // SleepMs may not sleep for exactly the requested time. |
1067 EXPECT_NEAR(system_time_diff, recv_timestamp_diff, 10000); | 1043 EXPECT_NEAR(system_time_diff, recv_timestamp_diff, 10000); |
1068 } | 1044 } |
1069 | 1045 |
1070 } // namespace rtc | 1046 } // namespace rtc |
OLD | NEW |