diff options
author | hubbe@chromium.org <hubbe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-15 00:22:02 +0000 |
---|---|---|
committer | hubbe@chromium.org <hubbe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-15 00:22:02 +0000 |
commit | 266e01990bf121f2c2fc16ffa4082240ef0dbdc2 (patch) | |
tree | 84df34fbdcd5759920ea5a9d641f58020e1c6b8c /media | |
parent | deb8f7997fc4029a0a580a1d6b27357c2c68cfec (diff) | |
download | chromium_src-266e01990bf121f2c2fc16ffa4082240ef0dbdc2.zip chromium_src-266e01990bf121f2c2fc16ffa4082240ef0dbdc2.tar.gz chromium_src-266e01990bf121f2c2fc16ffa4082240ef0dbdc2.tar.bz2 |
Cast: Make udp proxy work for mirroring v1
When only two arguments are given, remember the last two ip:port pairs and forward from one to the other.
This should make udp_proxy work for cast v1, if approperiate changes are made in the cast extension.
Review URL: https://codereview.chromium.org/283653003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270533 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/cast/test/utility/udp_proxy.cc | 25 | ||||
-rw-r--r-- | media/cast/test/utility/udp_proxy.h | 6 | ||||
-rw-r--r-- | media/cast/test/utility/udp_proxy_main.cc | 24 |
3 files changed, 36 insertions, 19 deletions
diff --git a/media/cast/test/utility/udp_proxy.cc b/media/cast/test/utility/udp_proxy.cc index 1132815..f0bb4f6 100644 --- a/media/cast/test/utility/udp_proxy.cc +++ b/media/cast/test/utility/udp_proxy.cc @@ -371,34 +371,34 @@ void BuildPipe(scoped_ptr<PacketPipe>* pipe, PacketPipe* next) { scoped_ptr<PacketPipe> WifiNetwork() { // This represents the buffer on the sender. scoped_ptr<PacketPipe> pipe; - BuildPipe(&pipe, new Buffer(256 << 10, 5000000)); + BuildPipe(&pipe, new Buffer(256 << 10, 20)); BuildPipe(&pipe, new RandomDrop(0.005)); // This represents the buffer on the router. BuildPipe(&pipe, new ConstantDelay(1E-3)); BuildPipe(&pipe, new RandomSortedDelay(1E-3, 20E-3, 3)); - BuildPipe(&pipe, new Buffer(256 << 10, 5000000)); + BuildPipe(&pipe, new Buffer(256 << 10, 20)); BuildPipe(&pipe, new ConstantDelay(1E-3)); BuildPipe(&pipe, new RandomSortedDelay(1E-3, 20E-3, 3)); BuildPipe(&pipe, new RandomDrop(0.005)); // This represents the buffer on the receiving device. - BuildPipe(&pipe, new Buffer(256 << 10, 5000000)); + BuildPipe(&pipe, new Buffer(256 << 10, 20)); return pipe.Pass(); } scoped_ptr<PacketPipe> BadNetwork() { scoped_ptr<PacketPipe> pipe; // This represents the buffer on the sender. - BuildPipe(&pipe, new Buffer(64 << 10, 5000000)); // 64 kb buf, 5mbit/s + BuildPipe(&pipe, new Buffer(64 << 10, 5)); // 64 kb buf, 5mbit/s BuildPipe(&pipe, new RandomDrop(0.05)); // 5% packet drop BuildPipe(&pipe, new RandomSortedDelay(2E-3, 20E-3, 1)); // This represents the buffer on the router. - BuildPipe(&pipe, new Buffer(64 << 10, 2000000)); // 64 kb buf, 2mbit/s + BuildPipe(&pipe, new Buffer(64 << 10, 5)); // 64 kb buf, 4mbit/s BuildPipe(&pipe, new ConstantDelay(1E-3)); // Random 40ms every other second // BuildPipe(&pipe, new NetworkGlitchPipe(2, 40E-1)); BuildPipe(&pipe, new RandomUnsortedDelay(5E-3)); // This represents the buffer on the receiving device. - BuildPipe(&pipe, new Buffer(64 << 10, 4000000)); // 64 kb buf, 4mbit/s + BuildPipe(&pipe, new Buffer(64 << 10, 5)); // 64 kb buf, 5mbit/s return pipe.Pass(); } @@ -406,17 +406,17 @@ scoped_ptr<PacketPipe> BadNetwork() { scoped_ptr<PacketPipe> EvilNetwork() { // This represents the buffer on the sender. scoped_ptr<PacketPipe> pipe; - BuildPipe(&pipe, new Buffer(4 << 10, 2000000)); + BuildPipe(&pipe, new Buffer(4 << 10, 5)); // 4 kb buf, 2mbit/s // This represents the buffer on the router. BuildPipe(&pipe, new RandomDrop(0.1)); // 10% packet drop BuildPipe(&pipe, new RandomSortedDelay(20E-3, 60E-3, 1)); - BuildPipe(&pipe, new Buffer(4 << 10, 1000000)); // 4 kb buf, 1mbit/s + BuildPipe(&pipe, new Buffer(4 << 10, 2)); // 4 kb buf, 2mbit/s BuildPipe(&pipe, new RandomDrop(0.1)); // 10% packet drop BuildPipe(&pipe, new ConstantDelay(1E-3)); BuildPipe(&pipe, new NetworkGlitchPipe(2.0, 0.3)); BuildPipe(&pipe, new RandomUnsortedDelay(20E-3)); // This represents the buffer on the receiving device. - BuildPipe(&pipe, new Buffer(4 << 10, 2000000)); // 4 kb buf, 2mbit/s + BuildPipe(&pipe, new Buffer(4 << 10, 2)); // 4 kb buf, 2mbit/s return pipe.Pass(); } @@ -429,6 +429,7 @@ class UDPProxyImpl : public UDPProxy { net::NetLog* net_log) : local_port_(local_port), destination_(destination), + destination_is_mutable_(destination.address().empty()), proxy_thread_("media::cast::test::UdpProxy Thread"), to_dest_pipe_(to_dest_pipe.Pass()), from_dest_pipe_(from_dest_pipe.Pass()) { @@ -492,6 +493,11 @@ class UDPProxyImpl : public UDPProxy { return; } packet_->resize(len); + if (destination_is_mutable_ && + !(recv_address_ == return_address_) && + !(recv_address_ == destination_)) { + destination_ = recv_address_; + } if (recv_address_ == destination_) { from_dest_pipe_->Send(packet_.Pass()); } else { @@ -527,6 +533,7 @@ class UDPProxyImpl : public UDPProxy { net::IPEndPoint local_port_; net::IPEndPoint destination_; + bool destination_is_mutable_; net::IPEndPoint recv_address_; net::IPEndPoint return_address_; base::Thread proxy_thread_; diff --git a/media/cast/test/utility/udp_proxy.h b/media/cast/test/utility/udp_proxy.h index 9dce0cf..6d2f70c 100644 --- a/media/cast/test/utility/udp_proxy.h +++ b/media/cast/test/utility/udp_proxy.h @@ -90,16 +90,16 @@ scoped_ptr<PacketPipe> NewNetworkGlitchPipe(double average_work_time, double average_outage_time); // This method builds a stack of PacketPipes to emulate a reasonably -// good wifi network. ~5mbit, 1% packet loss, ~3ms latency. +// good wifi network. ~20mbit, 1% packet loss, ~3ms latency. scoped_ptr<PacketPipe> WifiNetwork(); // This method builds a stack of PacketPipes to emulate a -// bad wifi network. ~2mbit, 5% packet loss, ~7ms latency +// bad wifi network. ~5mbit, 5% packet loss, ~7ms latency // 40ms dropouts every ~2 seconds. Can reorder packets. scoped_ptr<PacketPipe> BadNetwork(); // This method builds a stack of PacketPipes to emulate a crappy wifi network. -// ~1mbit, 20% packet loss, ~40ms latency and packets can get reordered. +// ~2mbit, 20% packet loss, ~40ms latency and packets can get reordered. // 300ms drouputs every ~2 seconds. scoped_ptr<PacketPipe> EvilNetwork(); diff --git a/media/cast/test/utility/udp_proxy_main.cc b/media/cast/test/utility/udp_proxy_main.cc index 0202d8c..800f09dc 100644 --- a/media/cast/test/utility/udp_proxy_main.cc +++ b/media/cast/test/utility/udp_proxy_main.cc @@ -116,9 +116,11 @@ void CheckByteCounters() { } int main(int argc, char** argv) { - if (argc < 5) { + if (argc != 5 && argc != 3) { fprintf(stderr, "Usage: udp_proxy <localport> <remotehost> <remoteport> <type>\n" + "or:\n" + " udp_proxy <localport> <type>\n" "Where type is one of: perfect, wifi, bad, evil\n"); exit(1); } @@ -127,18 +129,26 @@ int main(int argc, char** argv) { CommandLine::Init(argc, argv); InitLogging(logging::LoggingSettings()); - int local_port = atoi(argv[1]); - int remote_port = atoi(argv[3]); net::IPAddressNumber remote_ip_number; net::IPAddressNumber local_ip_number; - - CHECK(net::ParseIPLiteralToNumber(argv[2], &remote_ip_number)); + std::string network_type; + int local_port = atoi(argv[1]); + int remote_port = 0; CHECK(net::ParseIPLiteralToNumber("0.0.0.0", &local_ip_number)); + + if (argc == 5) { + // V2 proxy + CHECK(net::ParseIPLiteralToNumber(argv[2], &remote_ip_number)); + remote_port = atoi(argv[3]); + network_type = argv[4]; + } else { + // V1 proxy + network_type = argv[2]; + } net::IPEndPoint remote_endpoint(remote_ip_number, remote_port); net::IPEndPoint local_endpoint(local_ip_number, local_port); - scoped_ptr<media::cast::test::PacketPipe> in_pipe, out_pipe; - std::string network_type = argv[4]; + if (network_type == "perfect") { // No action needed. } else if (network_type == "wifi") { |