OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <string> | 6 #include <string> |
7 #include <sys/epoll.h> | 7 #include <sys/epoll.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "net/quic/quic_framer.h" | 21 #include "net/quic/quic_framer.h" |
22 #include "net/quic/quic_packet_creator.h" | 22 #include "net/quic/quic_packet_creator.h" |
23 #include "net/quic/quic_protocol.h" | 23 #include "net/quic/quic_protocol.h" |
24 #include "net/quic/quic_sent_packet_manager.h" | 24 #include "net/quic/quic_sent_packet_manager.h" |
25 #include "net/quic/quic_server_id.h" | 25 #include "net/quic/quic_server_id.h" |
26 #include "net/quic/test_tools/quic_connection_peer.h" | 26 #include "net/quic/test_tools/quic_connection_peer.h" |
27 #include "net/quic/test_tools/quic_session_peer.h" | 27 #include "net/quic/test_tools/quic_session_peer.h" |
28 #include "net/quic/test_tools/quic_test_utils.h" | 28 #include "net/quic/test_tools/quic_test_utils.h" |
29 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 29 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
30 #include "net/test/gtest_util.h" | 30 #include "net/test/gtest_util.h" |
31 #include "net/tools/epoll_server/epoll_server.h" | |
31 #include "net/tools/quic/quic_epoll_connection_helper.h" | 32 #include "net/tools/quic/quic_epoll_connection_helper.h" |
32 #include "net/tools/quic/quic_in_memory_cache.h" | 33 #include "net/tools/quic/quic_in_memory_cache.h" |
33 #include "net/tools/quic/quic_packet_writer_wrapper.h" | 34 #include "net/tools/quic/quic_packet_writer_wrapper.h" |
34 #include "net/tools/quic/quic_server.h" | 35 #include "net/tools/quic/quic_server.h" |
35 #include "net/tools/quic/quic_socket_utils.h" | 36 #include "net/tools/quic/quic_socket_utils.h" |
36 #include "net/tools/quic/quic_spdy_client_stream.h" | 37 #include "net/tools/quic/quic_spdy_client_stream.h" |
37 #include "net/tools/quic/test_tools/http_message.h" | 38 #include "net/tools/quic/test_tools/http_message.h" |
38 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h" | 39 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h" |
39 #include "net/tools/quic/test_tools/quic_client_peer.h" | 40 #include "net/tools/quic/test_tools/quic_client_peer.h" |
40 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" | 41 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" |
41 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" | 42 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" |
42 #include "net/tools/quic/test_tools/quic_server_peer.h" | 43 #include "net/tools/quic/test_tools/quic_server_peer.h" |
43 #include "net/tools/quic/test_tools/quic_test_client.h" | 44 #include "net/tools/quic/test_tools/quic_test_client.h" |
44 #include "net/tools/quic/test_tools/server_thread.h" | 45 #include "net/tools/quic/test_tools/server_thread.h" |
45 #include "testing/gtest/include/gtest/gtest.h" | 46 #include "testing/gtest/include/gtest/gtest.h" |
46 | 47 |
47 using base::StringPiece; | 48 using base::StringPiece; |
48 using base::WaitableEvent; | 49 using base::WaitableEvent; |
50 using net::EpollServer; | |
49 using net::test::GenerateBody; | 51 using net::test::GenerateBody; |
50 using net::test::QuicConnectionPeer; | 52 using net::test::QuicConnectionPeer; |
51 using net::test::QuicSessionPeer; | 53 using net::test::QuicSessionPeer; |
52 using net::test::ReliableQuicStreamPeer; | 54 using net::test::ReliableQuicStreamPeer; |
53 using net::tools::test::PacketDroppingTestWriter; | 55 using net::tools::test::PacketDroppingTestWriter; |
54 using net::tools::test::QuicDispatcherPeer; | 56 using net::tools::test::QuicDispatcherPeer; |
55 using net::tools::test::QuicServerPeer; | 57 using net::tools::test::QuicServerPeer; |
56 using std::ostream; | 58 using std::ostream; |
57 using std::string; | 59 using std::string; |
58 using std::vector; | 60 using std::vector; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 EXPECT_EQ(500u, client_->response_headers()->parsed_response_code()); | 476 EXPECT_EQ(500u, client_->response_headers()->parsed_response_code()); |
475 } | 477 } |
476 | 478 |
477 // TODO(rtenneti): DISABLED_LargePostNoPacketLoss seems to be flaky. | 479 // TODO(rtenneti): DISABLED_LargePostNoPacketLoss seems to be flaky. |
478 // http://crbug.com/297040. | 480 // http://crbug.com/297040. |
479 TEST_P(EndToEndTest, DISABLED_LargePostNoPacketLoss) { | 481 TEST_P(EndToEndTest, DISABLED_LargePostNoPacketLoss) { |
480 ASSERT_TRUE(Initialize()); | 482 ASSERT_TRUE(Initialize()); |
481 | 483 |
482 client_->client()->WaitForCryptoHandshakeConfirmed(); | 484 client_->client()->WaitForCryptoHandshakeConfirmed(); |
483 | 485 |
484 // 1 Mb body. | 486 // 1 MB body. |
485 string body; | 487 string body; |
486 GenerateBody(&body, 1024 * 1024); | 488 GenerateBody(&body, 1024 * 1024); |
487 | 489 |
488 HTTPMessage request(HttpConstants::HTTP_1_1, | 490 HTTPMessage request(HttpConstants::HTTP_1_1, |
489 HttpConstants::POST, "/foo"); | 491 HttpConstants::POST, "/foo"); |
490 request.AddBody(body, true); | 492 request.AddBody(body, true); |
491 | 493 |
492 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 494 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
493 VerifyCleanConnection(false); | 495 VerifyCleanConnection(false); |
494 } | 496 } |
495 | 497 |
496 TEST_P(EndToEndTest, LargePostNoPacketLoss1sRTT) { | 498 TEST_P(EndToEndTest, LargePostNoPacketLoss1sRTT) { |
497 ASSERT_TRUE(Initialize()); | 499 ASSERT_TRUE(Initialize()); |
498 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(1000)); | 500 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(1000)); |
499 | 501 |
500 client_->client()->WaitForCryptoHandshakeConfirmed(); | 502 client_->client()->WaitForCryptoHandshakeConfirmed(); |
501 | 503 |
502 // 1 Mb body. | 504 // 100 KB body. |
503 string body; | 505 string body; |
504 GenerateBody(&body, 100 * 1024); | 506 GenerateBody(&body, 100 * 1024); |
505 | 507 |
506 HTTPMessage request(HttpConstants::HTTP_1_1, | 508 HTTPMessage request(HttpConstants::HTTP_1_1, |
507 HttpConstants::POST, "/foo"); | 509 HttpConstants::POST, "/foo"); |
508 request.AddBody(body, true); | 510 request.AddBody(body, true); |
509 | 511 |
510 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 512 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
511 VerifyCleanConnection(false); | 513 VerifyCleanConnection(false); |
512 } | 514 } |
513 | 515 |
514 TEST_P(EndToEndTest, LargePostWithPacketLoss) { | 516 TEST_P(EndToEndTest, LargePostWithPacketLoss) { |
515 // Connect with lower fake packet loss than we'd like to test. Until | 517 // Connect with lower fake packet loss than we'd like to test. Until |
516 // b/10126687 is fixed, losing handshake packets is pretty brutal. | 518 // b/10126687 is fixed, losing handshake packets is pretty brutal. |
517 SetPacketLossPercentage(5); | 519 SetPacketLossPercentage(5); |
518 ASSERT_TRUE(Initialize()); | 520 ASSERT_TRUE(Initialize()); |
519 | 521 |
520 // Wait for the server SHLO before upping the packet loss. | 522 // Wait for the server SHLO before upping the packet loss. |
521 client_->client()->WaitForCryptoHandshakeConfirmed(); | 523 client_->client()->WaitForCryptoHandshakeConfirmed(); |
522 SetPacketLossPercentage(30); | 524 SetPacketLossPercentage(30); |
523 | 525 |
524 // 10 Kb body. | 526 // 10 KB body. |
525 string body; | 527 string body; |
526 GenerateBody(&body, 1024 * 10); | 528 GenerateBody(&body, 1024 * 10); |
527 | 529 |
528 HTTPMessage request(HttpConstants::HTTP_1_1, | 530 HTTPMessage request(HttpConstants::HTTP_1_1, |
529 HttpConstants::POST, "/foo"); | 531 HttpConstants::POST, "/foo"); |
530 request.AddBody(body, true); | 532 request.AddBody(body, true); |
531 | 533 |
532 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 534 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
533 } | |
534 | |
535 TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) { | |
536 ASSERT_TRUE(Initialize()); | |
537 | |
538 client_->client()->WaitForCryptoHandshakeConfirmed(); | |
539 // Both of these must be called when the writer is not actively used. | |
540 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); | |
541 SetReorderPercentage(30); | |
542 | |
543 // 1 Mb body. | |
544 string body; | |
545 GenerateBody(&body, 1024 * 1024); | |
546 | |
547 HTTPMessage request(HttpConstants::HTTP_1_1, | |
548 HttpConstants::POST, "/foo"); | |
549 request.AddBody(body, true); | |
550 | |
551 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | |
552 VerifyCleanConnection(true); | 535 VerifyCleanConnection(true); |
553 } | 536 } |
554 | 537 |
555 TEST_P(EndToEndTest, LargePostWithPacketLossAndBlockedSocket) { | 538 TEST_P(EndToEndTest, LargePostWithPacketLossAndBlockedSocket) { |
556 // Connect with lower fake packet loss than we'd like to test. Until | 539 // Connect with lower fake packet loss than we'd like to test. Until |
557 // b/10126687 is fixed, losing handshake packets is pretty brutal. | 540 // b/10126687 is fixed, losing handshake packets is pretty brutal. |
558 SetPacketLossPercentage(5); | 541 SetPacketLossPercentage(5); |
559 ASSERT_TRUE(Initialize()); | 542 ASSERT_TRUE(Initialize()); |
560 | 543 |
561 // Wait for the server SHLO before upping the packet loss. | 544 // Wait for the server SHLO before upping the packet loss. |
562 client_->client()->WaitForCryptoHandshakeConfirmed(); | 545 client_->client()->WaitForCryptoHandshakeConfirmed(); |
563 SetPacketLossPercentage(10); | 546 SetPacketLossPercentage(10); |
564 client_writer_->set_fake_blocked_socket_percentage(10); | 547 client_writer_->set_fake_blocked_socket_percentage(10); |
565 | 548 |
566 // 10 Kb body. | 549 // 10 KB body. |
567 string body; | 550 string body; |
568 GenerateBody(&body, 1024 * 10); | 551 GenerateBody(&body, 1024 * 10); |
569 | 552 |
570 HTTPMessage request(HttpConstants::HTTP_1_1, | 553 HTTPMessage request(HttpConstants::HTTP_1_1, |
571 HttpConstants::POST, "/foo"); | 554 HttpConstants::POST, "/foo"); |
555 request.AddBody(body, true); | |
556 | |
557 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | |
558 } | |
559 | |
560 TEST_P(EndToEndTest, LargePostNoPacketLossWithDelayAndReordering) { | |
561 ASSERT_TRUE(Initialize()); | |
562 | |
563 client_->client()->WaitForCryptoHandshakeConfirmed(); | |
564 // Both of these must be called when the writer is not actively used. | |
565 SetPacketSendDelay(QuicTime::Delta::FromMilliseconds(2)); | |
566 SetReorderPercentage(30); | |
567 | |
568 // 1 MB body. | |
569 string body; | |
570 GenerateBody(&body, 1024 * 1024); | |
571 | |
572 HTTPMessage request(HttpConstants::HTTP_1_1, | |
573 HttpConstants::POST, "/foo"); | |
572 request.AddBody(body, true); | 574 request.AddBody(body, true); |
573 | 575 |
574 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 576 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
575 } | 577 } |
576 | 578 |
577 // TODO(rtenneti): rch is investigating the root cause. Will enable after we | 579 // TODO(rtenneti): rch is investigating the root cause. Will enable after we |
578 // find the bug. | 580 // find the bug. |
579 TEST_P(EndToEndTest, DISABLED_LargePostZeroRTTFailure) { | 581 TEST_P(EndToEndTest, DISABLED_LargePostZeroRTTFailure) { |
580 // Have the server accept 0-RTT without waiting a startup period. | 582 // Have the server accept 0-RTT without waiting a startup period. |
581 strike_register_no_startup_period_ = true; | 583 strike_register_no_startup_period_ = true; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
648 GenerateBody(&body, 10240); | 650 GenerateBody(&body, 10240); |
649 | 651 |
650 HTTPMessage request(HttpConstants::HTTP_1_1, | 652 HTTPMessage request(HttpConstants::HTTP_1_1, |
651 HttpConstants::POST, "/foo"); | 653 HttpConstants::POST, "/foo"); |
652 request.AddBody(body, true); | 654 request.AddBody(body, true); |
653 | 655 |
654 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 656 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
655 VerifyCleanConnection(true); | 657 VerifyCleanConnection(true); |
656 } | 658 } |
657 | 659 |
658 // TODO(rtenneti): DISABLED_LargePostLargeBuffer seems to be flaky. | 660 TEST_P(EndToEndTest, LargePostSmallBandwidthLargeBuffer) { |
659 // http://crbug.com/370087. | |
660 TEST_P(EndToEndTest, DISABLED_LargePostLargeBuffer) { | |
661 ASSERT_TRUE(Initialize()); | 661 ASSERT_TRUE(Initialize()); |
662 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1)); | 662 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1)); |
663 // 1Mbit per second with a 128k buffer from server to client. Wireless | 663 // 256KB per second with a 256k buffer from server to client. Wireless |
wtc
2014/05/13 18:49:23
Nit: 256k => 256KB ?
ramant (doing other things)
2014/05/14 05:33:29
Made this change in https://codereview.chromium.or
| |
664 // clients commonly have larger buffers, but our max CWND is 200. | 664 // clients commonly have larger buffers, but our max CWND is 200. |
665 server_writer_->set_max_bandwidth_and_buffer_size( | 665 server_writer_->set_max_bandwidth_and_buffer_size( |
666 QuicBandwidth::FromBytesPerSecond(256 * 1024), 128 * 1024); | 666 QuicBandwidth::FromBytesPerSecond(256 * 1024), 256 * 1024); |
667 | 667 |
668 client_->client()->WaitForCryptoHandshakeConfirmed(); | 668 client_->client()->WaitForCryptoHandshakeConfirmed(); |
669 | 669 |
670 // 1 Mb body. | 670 // 1 MB body. |
671 string body; | 671 string body; |
672 GenerateBody(&body, 1024 * 1024); | 672 GenerateBody(&body, 1024 * 1024); |
673 | 673 |
674 HTTPMessage request(HttpConstants::HTTP_1_1, | 674 HTTPMessage request(HttpConstants::HTTP_1_1, |
675 HttpConstants::POST, "/foo"); | 675 HttpConstants::POST, "/foo"); |
676 request.AddBody(body, true); | 676 request.AddBody(body, true); |
677 | 677 |
678 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 678 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
679 // This connection will not drop packets, because the buffer size is larger | |
680 // than the default receive window. | |
679 VerifyCleanConnection(false); | 681 VerifyCleanConnection(false); |
680 } | 682 } |
681 | 683 |
682 TEST_P(EndToEndTest, InvalidStream) { | 684 TEST_P(EndToEndTest, InvalidStream) { |
683 ASSERT_TRUE(Initialize()); | 685 ASSERT_TRUE(Initialize()); |
684 client_->client()->WaitForCryptoHandshakeConfirmed(); | 686 client_->client()->WaitForCryptoHandshakeConfirmed(); |
685 | 687 |
686 string body; | 688 string body; |
687 GenerateBody(&body, kMaxPacketSize); | 689 GenerateBody(&body, kMaxPacketSize); |
688 | 690 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 EXPECT_EQ(FLAGS_enable_quic_pacing, | 785 EXPECT_EQ(FLAGS_enable_quic_pacing, |
784 client_sent_packet_manager.using_pacing()); | 786 client_sent_packet_manager.using_pacing()); |
785 | 787 |
786 EXPECT_EQ(100000u, | 788 EXPECT_EQ(100000u, |
787 client_sent_packet_manager.GetRttStats()->initial_rtt_us()); | 789 client_sent_packet_manager.GetRttStats()->initial_rtt_us()); |
788 EXPECT_EQ(1u, server_sent_packet_manager.GetRttStats()->initial_rtt_us()); | 790 EXPECT_EQ(1u, server_sent_packet_manager.GetRttStats()->initial_rtt_us()); |
789 | 791 |
790 // Now use the negotiated limits with packet loss. | 792 // Now use the negotiated limits with packet loss. |
791 SetPacketLossPercentage(30); | 793 SetPacketLossPercentage(30); |
792 | 794 |
793 // 10 Kb body. | 795 // 10 KB body. |
794 string body; | 796 string body; |
795 GenerateBody(&body, 1024 * 10); | 797 GenerateBody(&body, 1024 * 10); |
796 | 798 |
797 HTTPMessage request(HttpConstants::HTTP_1_1, | 799 HTTPMessage request(HttpConstants::HTTP_1_1, |
798 HttpConstants::POST, "/foo"); | 800 HttpConstants::POST, "/foo"); |
799 request.AddBody(body, true); | 801 request.AddBody(body, true); |
800 | 802 |
801 server_thread_->Resume(); | 803 server_thread_->Resume(); |
802 | 804 |
803 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 805 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
946 buffer, buf_len, self_address_.address(), peer_address); | 948 buffer, buf_len, self_address_.address(), peer_address); |
947 } | 949 } |
948 | 950 |
949 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE { | 951 virtual bool IsWriteBlockedDataBuffered() const OVERRIDE { |
950 return false; | 952 return false; |
951 } | 953 } |
952 | 954 |
953 IPEndPoint self_address_; | 955 IPEndPoint self_address_; |
954 }; | 956 }; |
955 | 957 |
956 TEST_P(EndToEndTest, ConnectionMigration) { | 958 TEST_P(EndToEndTest, ConnectionMigrationClientIPChanged) { |
959 // Tests that the client's IP can not change during an established QUIC | |
960 // connection. If it changes, the connection is closed by the server as we do | |
961 // not yet support IP migration. | |
957 ASSERT_TRUE(Initialize()); | 962 ASSERT_TRUE(Initialize()); |
958 | 963 |
959 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | 964 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); |
960 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | 965 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); |
961 | 966 |
962 scoped_ptr<WrongAddressWriter> writer(new WrongAddressWriter()); | 967 scoped_ptr<WrongAddressWriter> writer(new WrongAddressWriter()); |
963 | 968 |
964 writer->set_writer(new QuicDefaultPacketWriter(client_->client()->fd())); | 969 writer->set_writer(new QuicDefaultPacketWriter(client_->client()->fd())); |
965 QuicConnectionPeer::SetWriter(client_->client()->session()->connection(), | 970 QuicConnectionPeer::SetWriter(client_->client()->session()->connection(), |
966 writer.get()); | 971 writer.get()); |
967 | 972 |
968 client_->SendSynchronousRequest("/bar"); | 973 client_->SendSynchronousRequest("/bar"); |
969 | 974 |
970 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); | 975 EXPECT_EQ(QUIC_STREAM_CONNECTION_ERROR, client_->stream_error()); |
971 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error()); | 976 EXPECT_EQ(QUIC_ERROR_MIGRATING_ADDRESS, client_->connection_error()); |
972 } | 977 } |
973 | 978 |
979 TEST_P(EndToEndTest, ConnectionMigrationClientPortChanged) { | |
980 // Tests that the client's port can change during an established QUIC | |
981 // connection, and that doing so does not result in the connection being | |
982 // closed by the server. | |
983 FLAGS_quic_allow_port_migration = true; | |
984 | |
985 ASSERT_TRUE(Initialize()); | |
986 | |
987 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); | |
988 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | |
989 | |
990 // Store the client address which was used to send the first request. | |
991 IPEndPoint old_address = client_->client()->client_address(); | |
992 | |
993 // Stop listening on the old FD. | |
994 EpollServer* eps = client_->client()->epoll_server(); | |
995 int old_fd = client_->client()->fd(); | |
996 eps->UnregisterFD(old_fd); | |
997 close(old_fd); | |
998 | |
999 // Create a new socket, which will result in a new ephemeral port. | |
1000 QuicClientPeer::CreateUDPSocket(client_->client()); | |
1001 | |
1002 // The packet writer needs to be updated to use the new FD. | |
1003 client_->client()->CreateQuicPacketWriter(); | |
1004 | |
1005 // Change the internal state of the client and connection to use the new port, | |
1006 // this is done because in a real NAT rebinding the client wouldn't see any | |
1007 // port change, and so expects no change to incoming port. | |
1008 // This is kind of ugly, but needed as we are simply swapping out the client | |
1009 // FD rather than any more complex NAT rebinding simulation. | |
1010 int new_port = client_->client()->client_address().port(); | |
1011 QuicClientPeer::SetClientPort(client_->client(), new_port); | |
1012 QuicConnectionPeer::SetSelfAddress( | |
1013 client_->client()->session()->connection(), | |
1014 IPEndPoint( | |
1015 client_->client()->session()->connection()->self_address().address(), | |
1016 new_port)); | |
1017 | |
1018 // Register the new FD for epoll events. | |
1019 int new_fd = client_->client()->fd(); | |
1020 eps->RegisterFD(new_fd, client_->client(), EPOLLIN | EPOLLOUT | EPOLLET); | |
1021 | |
1022 // Send a second request, using the new FD. | |
1023 EXPECT_EQ(kBarResponseBody, client_->SendSynchronousRequest("/bar")); | |
1024 EXPECT_EQ(200u, client_->response_headers()->parsed_response_code()); | |
1025 | |
1026 // Verify that the client's ephemeral port is different. | |
1027 IPEndPoint new_address = client_->client()->client_address(); | |
1028 EXPECT_EQ(old_address.address(), new_address.address()); | |
1029 EXPECT_NE(old_address.port(), new_address.port()); | |
1030 } | |
1031 | |
974 TEST_P(EndToEndTest, DifferentFlowControlWindows) { | 1032 TEST_P(EndToEndTest, DifferentFlowControlWindows) { |
975 // Client and server can set different initial flow control receive windows. | 1033 // Client and server can set different initial flow control receive windows. |
976 // These are sent in CHLO/SHLO. Tests that these values are exchanged properly | 1034 // These are sent in CHLO/SHLO. Tests that these values are exchanged properly |
977 // in the crypto handshake. | 1035 // in the crypto handshake. |
978 | 1036 |
979 const uint32 kClientIFCW = 123456; | 1037 const uint32 kClientIFCW = 123456; |
980 set_client_initial_flow_control_receive_window(kClientIFCW); | 1038 set_client_initial_flow_control_receive_window(kClientIFCW); |
981 | 1039 |
982 const uint32 kServerIFCW = 654321; | 1040 const uint32 kServerIFCW = 654321; |
983 set_server_initial_flow_control_receive_window(kServerIFCW); | 1041 set_server_initial_flow_control_receive_window(kServerIFCW); |
(...skipping 17 matching lines...) Expand all Loading... | |
1001 QuicSession* session = dispatcher->session_map().begin()->second; | 1059 QuicSession* session = dispatcher->session_map().begin()->second; |
1002 EXPECT_EQ(kClientIFCW, | 1060 EXPECT_EQ(kClientIFCW, |
1003 session->config()->ReceivedInitialFlowControlWindowBytes()); | 1061 session->config()->ReceivedInitialFlowControlWindowBytes()); |
1004 server_thread_->Resume(); | 1062 server_thread_->Resume(); |
1005 } | 1063 } |
1006 | 1064 |
1007 } // namespace | 1065 } // namespace |
1008 } // namespace test | 1066 } // namespace test |
1009 } // namespace tools | 1067 } // namespace tools |
1010 } // namespace net | 1068 } // namespace net |
OLD | NEW |