From 80cd7ac1465ff252f79bb563d6f7eb6c24ba32f7 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 21 Mar 2016 16:47:41 +0100 Subject: [PATCH 1/5] iperf3 wip... should add some info to doc --- example/dce-iperf.cc | 107 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 19 deletions(-) diff --git a/example/dce-iperf.cc b/example/dce-iperf.cc index deffc8c7..a53d90b5 100644 --- a/example/dce-iperf.cc +++ b/example/dce-iperf.cc @@ -8,6 +8,11 @@ #include "ns3/constant-position-mobility-model.h" #include "ccnx/misc-tools.h" +/** + * Comment to use iperf2 instead + */ +#define IPERF3 + using namespace ns3; NS_LOG_COMPONENT_DEFINE ("DceIperf"); // =========================================================================== @@ -30,20 +35,36 @@ NS_LOG_COMPONENT_DEFINE ("DceIperf"); // allow DCE to have a chance to end an endless loop in iperf as follow: // in source named Thread.c at line 412 in method named thread_rest // you must add a sleep (1); to break the infinite loop.... +// +// Note : Tested with iperf 3.1, you need to modify source as is done in +// utils/iperf3_1.patch // =========================================================================== + + + +// duration of the iperf in seconds (s) +const std::string iperfDuration = "5"; + int main (int argc, char *argv[]) { + Ptr clientNode; + Ptr serverNode; std::string stack = "ns3"; bool useUdp = 0; std::string bandWidth = "1m"; + std::string windowSize = "120KB"; + const Time simMaxDuration = Seconds(40); CommandLine cmd; cmd.AddValue ("stack", "Name of IP stack: ns3/linux/freebsd.", stack); cmd.AddValue ("udp", "Use UDP. Default false (0)", useUdp); cmd.AddValue ("bw", "BandWidth. Default 1m.", bandWidth); + cmd.AddValue ("window", "iperf --window parameter", windowSize); cmd.Parse (argc, argv); NodeContainer nodes; nodes.Create (2); + clientNode = nodes.Get(0); + serverNode = nodes.Get(1); PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); @@ -107,52 +128,100 @@ int main (int argc, char *argv[]) DceApplicationHelper dce; ApplicationContainer apps; + std::ostringstream oss; dce.SetStackSize (1 << 20); + + //! 'i+1' because 0 is localhost + Ipv4Address serverAddr = serverNode->GetObject()->GetAddress(i+1, 0).GetLocal(); + Ipv4Address sourceAddr = clientNode->GetObject()->GetAddress(i+1, 0).GetLocal(); + + //! TODO, we should be able to not specify a port but it seems buggy so for now, let's set a port + // InetSocketAddress local( sourceAddr); + InetSocketAddress local(sourceAddr, 0); + InetSocketAddress remote(serverAddr, 5001); + #ifdef IPERF3 + // Setup client on node 0 + dce.SetBinary ("iperf3"); + dce.ResetArguments (); + dce.ResetEnvironment (); + dce.AddArgument ("-c"); + dce.AddArgument ("10.2.0.1"); + dce.AddArgument ("--interval=1"); // interval between reports + dce.AddArgument ("--time=10"); // duration of the test + dce.AddArgument ("--verbose"); + dce.AddArgument ("--json"); // export to json + dce.AddArgument ("--logfile=client.res"); // into this file +// dce.AddArgument ("-P"); // number of streams to run in parallel +// dce.AddArgument ("1"); + + apps = dce.Install ( clientNode ); + apps.Start (Seconds (5.0)); + apps.Stop (simMaxDuration); + + // Launch iperf server on node 1 + dce.SetBinary ("iperf3"); + dce.ResetArguments (); + dce.ResetEnvironment (); + dce.AddArgument ("--verbose"); + dce.AddArgument ("--json"); // export to json + dce.AddArgument ("--logfile=server.res"); // into this file + dce.AddArgument ("--server"); + if (useUdp) + { + dce.AddArgument ("--udp"); + } + + apps = dce.Install (serverNode); + #else + /* By default iperf2 listens on port 5001 */ + oss.str(""); + oss << "--window=" << windowSize; + // Launch iperf client on node 0 dce.SetBinary ("iperf"); dce.ResetArguments (); dce.ResetEnvironment (); - dce.AddArgument ("-c"); - dce.AddArgument ("10.1.1.2"); + dce.AddArgument ("--client=10.2.0.1"); +// dce.AddArgument (""); dce.AddArgument ("-i"); dce.AddArgument ("1"); dce.AddArgument ("--time"); - dce.AddArgument ("10"); - if (useUdp) - { - dce.AddArgument ("-u"); - dce.AddArgument ("-b"); - dce.AddArgument (bandWidth); - } + dce.AddArgument (iperfDuration); + dce.AddArgument ("--bind=10.1.0.1"); // TODO get address from clientNode + dce.AddArgument ("--reportstyle=C"); // export as CSV + dce.AddArgument (oss.str()); // size of Rcv or send buffer - apps = dce.Install (nodes.Get (0)); - apps.Start (Seconds (0.7)); - apps.Stop (Seconds (20)); + apps = dce.Install ( clientNode ); + apps.Start (Seconds (5.0)); + apps.Stop (simMaxDuration); // Launch iperf server on node 1 dce.SetBinary ("iperf"); dce.ResetArguments (); dce.ResetEnvironment (); dce.AddArgument ("-s"); - dce.AddArgument ("-P"); - dce.AddArgument ("1"); + dce.AddArgument ("--bind=10.2.0.1"); //TODO get address programmatacilly from clientNode + dce.AddArgument ("--parallel=1"); + dce.AddArgument (oss.str()); // size of Rcv or send buffer if (useUdp) { - dce.AddArgument ("-u"); + dce.AddArgument ("--udp"); } - apps = dce.Install (nodes.Get (1)); + apps = dce.Install (serverNode); + #endif + pointToPoint.EnablePcapAll ("iperf-" + stack, false); apps.Start (Seconds (0.6)); - setPos (nodes.Get (0), 1, 10, 0); - setPos (nodes.Get (1), 50,10, 0); + setPos (clientNode, 1, 10, 0); + setPos (serverNode, 50,10, 0); - Simulator::Stop (Seconds (40.0)); + Simulator::Stop (simMaxDuration); Simulator::Run (); Simulator::Destroy (); From 7619f9a1662dfc255e413f9aa47ab51556bbca3e Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 21 Mar 2016 16:47:41 +0100 Subject: [PATCH 2/5] iperf3 wip... should add some info to doc --- example/dce-iperf.cc | 107 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 19 deletions(-) diff --git a/example/dce-iperf.cc b/example/dce-iperf.cc index deffc8c7..a53d90b5 100644 --- a/example/dce-iperf.cc +++ b/example/dce-iperf.cc @@ -8,6 +8,11 @@ #include "ns3/constant-position-mobility-model.h" #include "ccnx/misc-tools.h" +/** + * Comment to use iperf2 instead + */ +#define IPERF3 + using namespace ns3; NS_LOG_COMPONENT_DEFINE ("DceIperf"); // =========================================================================== @@ -30,20 +35,36 @@ NS_LOG_COMPONENT_DEFINE ("DceIperf"); // allow DCE to have a chance to end an endless loop in iperf as follow: // in source named Thread.c at line 412 in method named thread_rest // you must add a sleep (1); to break the infinite loop.... +// +// Note : Tested with iperf 3.1, you need to modify source as is done in +// utils/iperf3_1.patch // =========================================================================== + + + +// duration of the iperf in seconds (s) +const std::string iperfDuration = "5"; + int main (int argc, char *argv[]) { + Ptr clientNode; + Ptr serverNode; std::string stack = "ns3"; bool useUdp = 0; std::string bandWidth = "1m"; + std::string windowSize = "120KB"; + const Time simMaxDuration = Seconds(40); CommandLine cmd; cmd.AddValue ("stack", "Name of IP stack: ns3/linux/freebsd.", stack); cmd.AddValue ("udp", "Use UDP. Default false (0)", useUdp); cmd.AddValue ("bw", "BandWidth. Default 1m.", bandWidth); + cmd.AddValue ("window", "iperf --window parameter", windowSize); cmd.Parse (argc, argv); NodeContainer nodes; nodes.Create (2); + clientNode = nodes.Get(0); + serverNode = nodes.Get(1); PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); @@ -107,52 +128,100 @@ int main (int argc, char *argv[]) DceApplicationHelper dce; ApplicationContainer apps; + std::ostringstream oss; dce.SetStackSize (1 << 20); + + //! 'i+1' because 0 is localhost + Ipv4Address serverAddr = serverNode->GetObject()->GetAddress(i+1, 0).GetLocal(); + Ipv4Address sourceAddr = clientNode->GetObject()->GetAddress(i+1, 0).GetLocal(); + + //! TODO, we should be able to not specify a port but it seems buggy so for now, let's set a port + // InetSocketAddress local( sourceAddr); + InetSocketAddress local(sourceAddr, 0); + InetSocketAddress remote(serverAddr, 5001); + #ifdef IPERF3 + // Setup client on node 0 + dce.SetBinary ("iperf3"); + dce.ResetArguments (); + dce.ResetEnvironment (); + dce.AddArgument ("-c"); + dce.AddArgument ("10.2.0.1"); + dce.AddArgument ("--interval=1"); // interval between reports + dce.AddArgument ("--time=10"); // duration of the test + dce.AddArgument ("--verbose"); + dce.AddArgument ("--json"); // export to json + dce.AddArgument ("--logfile=client.res"); // into this file +// dce.AddArgument ("-P"); // number of streams to run in parallel +// dce.AddArgument ("1"); + + apps = dce.Install ( clientNode ); + apps.Start (Seconds (5.0)); + apps.Stop (simMaxDuration); + + // Launch iperf server on node 1 + dce.SetBinary ("iperf3"); + dce.ResetArguments (); + dce.ResetEnvironment (); + dce.AddArgument ("--verbose"); + dce.AddArgument ("--json"); // export to json + dce.AddArgument ("--logfile=server.res"); // into this file + dce.AddArgument ("--server"); + if (useUdp) + { + dce.AddArgument ("--udp"); + } + + apps = dce.Install (serverNode); + #else + /* By default iperf2 listens on port 5001 */ + oss.str(""); + oss << "--window=" << windowSize; + // Launch iperf client on node 0 dce.SetBinary ("iperf"); dce.ResetArguments (); dce.ResetEnvironment (); - dce.AddArgument ("-c"); - dce.AddArgument ("10.1.1.2"); + dce.AddArgument ("--client=10.2.0.1"); +// dce.AddArgument (""); dce.AddArgument ("-i"); dce.AddArgument ("1"); dce.AddArgument ("--time"); - dce.AddArgument ("10"); - if (useUdp) - { - dce.AddArgument ("-u"); - dce.AddArgument ("-b"); - dce.AddArgument (bandWidth); - } + dce.AddArgument (iperfDuration); + dce.AddArgument ("--bind=10.1.0.1"); // TODO get address from clientNode + dce.AddArgument ("--reportstyle=C"); // export as CSV + dce.AddArgument (oss.str()); // size of Rcv or send buffer - apps = dce.Install (nodes.Get (0)); - apps.Start (Seconds (0.7)); - apps.Stop (Seconds (20)); + apps = dce.Install ( clientNode ); + apps.Start (Seconds (5.0)); + apps.Stop (simMaxDuration); // Launch iperf server on node 1 dce.SetBinary ("iperf"); dce.ResetArguments (); dce.ResetEnvironment (); dce.AddArgument ("-s"); - dce.AddArgument ("-P"); - dce.AddArgument ("1"); + dce.AddArgument ("--bind=10.2.0.1"); //TODO get address programmatacilly from clientNode + dce.AddArgument ("--parallel=1"); + dce.AddArgument (oss.str()); // size of Rcv or send buffer if (useUdp) { - dce.AddArgument ("-u"); + dce.AddArgument ("--udp"); } - apps = dce.Install (nodes.Get (1)); + apps = dce.Install (serverNode); + #endif + pointToPoint.EnablePcapAll ("iperf-" + stack, false); apps.Start (Seconds (0.6)); - setPos (nodes.Get (0), 1, 10, 0); - setPos (nodes.Get (1), 50,10, 0); + setPos (clientNode, 1, 10, 0); + setPos (serverNode, 50,10, 0); - Simulator::Stop (Seconds (40.0)); + Simulator::Stop (simMaxDuration); Simulator::Run (); Simulator::Destroy (); From 8dcacea4c92ecf9192870566d73217fa269761bc Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 22 Mar 2016 00:54:23 +0100 Subject: [PATCH 3/5] Programmatic ips --- example/dce-iperf.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/example/dce-iperf.cc b/example/dce-iperf.cc index a53d90b5..703e9249 100644 --- a/example/dce-iperf.cc +++ b/example/dce-iperf.cc @@ -133,14 +133,14 @@ int main (int argc, char *argv[]) dce.SetStackSize (1 << 20); - //! 'i+1' because 0 is localhost - Ipv4Address serverAddr = serverNode->GetObject()->GetAddress(i+1, 0).GetLocal(); - Ipv4Address sourceAddr = clientNode->GetObject()->GetAddress(i+1, 0).GetLocal(); - - //! TODO, we should be able to not specify a port but it seems buggy so for now, let's set a port - // InetSocketAddress local( sourceAddr); - InetSocketAddress local(sourceAddr, 0); - InetSocketAddress remote(serverAddr, 5001); + //! 'i+1' because 0 is localhost + Ipv4Address serverAddr = serverNode->GetObject()->GetAddress(1, 0).GetLocal(); + Ipv4Address sourceAddr = clientNode->GetObject()->GetAddress(1, 0).GetLocal(); + + //! TODO, we should be able to not specify a port but it seems buggy so for now, let's set a port + // InetSocketAddress local( sourceAddr); + InetSocketAddress local(sourceAddr, 0); + InetSocketAddress remote(serverAddr, 5001); #ifdef IPERF3 // Setup client on node 0 dce.SetBinary ("iperf3"); From 5b8b08f135987003e469fd70a4f42de06f037b19 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 22 Mar 2016 01:56:56 +0100 Subject: [PATCH 4/5] WIP: it fails with error 'Unable to create a new stream' --- example/dce-iperf.cc | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/example/dce-iperf.cc b/example/dce-iperf.cc index 703e9249..b0372710 100644 --- a/example/dce-iperf.cc +++ b/example/dce-iperf.cc @@ -17,7 +17,7 @@ using namespace ns3; NS_LOG_COMPONENT_DEFINE ("DceIperf"); // =========================================================================== // -// node 0 node 1 +// node 0 (client) node 1 (server) // +----------------+ +----------------+ // | | | | // +----------------+ +----------------+ @@ -136,20 +136,18 @@ int main (int argc, char *argv[]) //! 'i+1' because 0 is localhost Ipv4Address serverAddr = serverNode->GetObject()->GetAddress(1, 0).GetLocal(); Ipv4Address sourceAddr = clientNode->GetObject()->GetAddress(1, 0).GetLocal(); +// NS_LOG_UNCOND ("serverAddr=" << serverAddr); - //! TODO, we should be able to not specify a port but it seems buggy so for now, let's set a port - // InetSocketAddress local( sourceAddr); - InetSocketAddress local(sourceAddr, 0); - InetSocketAddress remote(serverAddr, 5001); #ifdef IPERF3 // Setup client on node 0 dce.SetBinary ("iperf3"); dce.ResetArguments (); dce.ResetEnvironment (); dce.AddArgument ("-c"); - dce.AddArgument ("10.2.0.1"); + dce.AddArgument ("10.1.1.2"); dce.AddArgument ("--interval=1"); // interval between reports dce.AddArgument ("--time=10"); // duration of the test + //TODO use iperfDuration dce.AddArgument ("--verbose"); dce.AddArgument ("--json"); // export to json dce.AddArgument ("--logfile=client.res"); // into this file @@ -174,6 +172,8 @@ int main (int argc, char *argv[]) } apps = dce.Install (serverNode); + + pointToPoint.EnablePcapAll ("iperf3-" + stack, false); #else /* By default iperf2 listens on port 5001 */ oss.str(""); @@ -183,13 +183,15 @@ int main (int argc, char *argv[]) dce.SetBinary ("iperf"); dce.ResetArguments (); dce.ResetEnvironment (); - dce.AddArgument ("--client=10.2.0.1"); -// dce.AddArgument (""); + oss.str(""); + oss << "--client="; + serverAddr.Print(oss); + dce.AddArgument (oss.str()); dce.AddArgument ("-i"); dce.AddArgument ("1"); dce.AddArgument ("--time"); dce.AddArgument (iperfDuration); - dce.AddArgument ("--bind=10.1.0.1"); // TODO get address from clientNode +// dce.AddArgument ("--bind=10.1.1.1"); // TODO get address from clientNode dce.AddArgument ("--reportstyle=C"); // export as CSV dce.AddArgument (oss.str()); // size of Rcv or send buffer @@ -202,7 +204,7 @@ int main (int argc, char *argv[]) dce.ResetArguments (); dce.ResetEnvironment (); dce.AddArgument ("-s"); - dce.AddArgument ("--bind=10.2.0.1"); //TODO get address programmatacilly from clientNode +// dce.AddArgument ("--bind=10.1.1.2"); //TODO get address programmatacilly from clientNode dce.AddArgument ("--parallel=1"); dce.AddArgument (oss.str()); // size of Rcv or send buffer if (useUdp) @@ -211,10 +213,9 @@ int main (int argc, char *argv[]) } apps = dce.Install (serverNode); - #endif - - pointToPoint.EnablePcapAll ("iperf-" + stack, false); + pointToPoint.EnablePcapAll ("iperf2-" + stack, false); + #endif apps.Start (Seconds (0.6)); From 471ea4c0a876f44661f04fd990aea5bfd2c59542 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 13 Jun 2016 18:40:41 +0200 Subject: [PATCH 5/5] TODO get address automatically --- example/dce-iperf.cc | 39 ++++++++++++++++++++------------------- test/test-tsearch.cc | 2 +- test/wscript | 3 ++- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/example/dce-iperf.cc b/example/dce-iperf.cc index a53d90b5..48c1e75f 100644 --- a/example/dce-iperf.cc +++ b/example/dce-iperf.cc @@ -19,7 +19,7 @@ NS_LOG_COMPONENT_DEFINE ("DceIperf"); // // node 0 node 1 // +----------------+ +----------------+ -// | | | | +// | Client | | Server | // +----------------+ +----------------+ // | 10.1.1.1 | | 10.1.1.2 | // +----------------+ +----------------+ @@ -43,13 +43,13 @@ NS_LOG_COMPONENT_DEFINE ("DceIperf"); // duration of the iperf in seconds (s) -const std::string iperfDuration = "5"; +const std::string iperfDuration = "20"; int main (int argc, char *argv[]) { Ptr clientNode; Ptr serverNode; - std::string stack = "ns3"; + std::string stack = "linux"; bool useUdp = 0; std::string bandWidth = "1m"; std::string windowSize = "120KB"; @@ -93,7 +93,7 @@ int main (int argc, char *argv[]) #else NS_LOG_ERROR ("Linux kernel stack for DCE is not available. build with dce-linux module."); // silently exit - return 0; + return 1; #endif } else if (stack == "freebsd") @@ -133,21 +133,21 @@ int main (int argc, char *argv[]) dce.SetStackSize (1 << 20); - //! 'i+1' because 0 is localhost - Ipv4Address serverAddr = serverNode->GetObject()->GetAddress(i+1, 0).GetLocal(); - Ipv4Address sourceAddr = clientNode->GetObject()->GetAddress(i+1, 0).GetLocal(); + //! 'i+1' because 0 is localhost +// Ipv4Address serverAddr = serverNode->GetObject()->GetAddress(i+1, 0).GetLocal(); +// Ipv4Address sourceAddr = clientNode->GetObject()->GetAddress(i+1, 0).GetLocal(); - //! TODO, we should be able to not specify a port but it seems buggy so for now, let's set a port - // InetSocketAddress local( sourceAddr); - InetSocketAddress local(sourceAddr, 0); - InetSocketAddress remote(serverAddr, 5001); + //! TODO, we should be able to not specify a port but it seems buggy so for now, let's set a port +// InetSocketAddress local( sourceAddr); +// InetSocketAddress local(sourceAddr, 0); +// InetSocketAddress remote(serverAddr, 5001); #ifdef IPERF3 // Setup client on node 0 dce.SetBinary ("iperf3"); dce.ResetArguments (); dce.ResetEnvironment (); dce.AddArgument ("-c"); - dce.AddArgument ("10.2.0.1"); + dce.AddArgument ("10.1.1.2"); dce.AddArgument ("--interval=1"); // interval between reports dce.AddArgument ("--time=10"); // duration of the test dce.AddArgument ("--verbose"); @@ -160,13 +160,14 @@ int main (int argc, char *argv[]) apps.Start (Seconds (5.0)); apps.Stop (simMaxDuration); - // Launch iperf server on node 1 + // Launch iperf server on node 1, listens on 5201 by default dce.SetBinary ("iperf3"); dce.ResetArguments (); dce.ResetEnvironment (); dce.AddArgument ("--verbose"); - dce.AddArgument ("--json"); // export to json - dce.AddArgument ("--logfile=server.res"); // into this file +// dce.AddArgument ("--json"); // export to json +// dce.AddArgument ("--logfile=server.res"); // into this file + dce.AddArgument ("--bind=10.1.1.2"); //TODO get address programmatacilly from clientNode dce.AddArgument ("--server"); if (useUdp) { @@ -183,7 +184,7 @@ int main (int argc, char *argv[]) dce.SetBinary ("iperf"); dce.ResetArguments (); dce.ResetEnvironment (); - dce.AddArgument ("--client=10.2.0.1"); + dce.AddArgument ("--client=10.1.1.2"); // dce.AddArgument (""); dce.AddArgument ("-i"); dce.AddArgument ("1"); @@ -202,7 +203,7 @@ int main (int argc, char *argv[]) dce.ResetArguments (); dce.ResetEnvironment (); dce.AddArgument ("-s"); - dce.AddArgument ("--bind=10.2.0.1"); //TODO get address programmatacilly from clientNode + dce.AddArgument ("--bind=10.1.1.2"); //TODO get address programmatacilly from clientNode dce.AddArgument ("--parallel=1"); dce.AddArgument (oss.str()); // size of Rcv or send buffer if (useUdp) @@ -212,11 +213,11 @@ int main (int argc, char *argv[]) apps = dce.Install (serverNode); #endif - + apps.Start (Seconds (0.6)); pointToPoint.EnablePcapAll ("iperf-" + stack, false); - apps.Start (Seconds (0.6)); + setPos (clientNode, 1, 10, 0); setPos (serverNode, 50,10, 0); diff --git a/test/test-tsearch.cc b/test/test-tsearch.cc index 2a07b2dc..c9dd0f20 100644 --- a/test/test-tsearch.cc +++ b/test/test-tsearch.cc @@ -72,7 +72,7 @@ main (void) } else if ((*(int **) val) != ptr) { - free (ptr); +// free (ptr); } } twalk (root, action); diff --git a/test/wscript b/test/wscript index 0213477a..2d6ee9d5 100644 --- a/test/wscript +++ b/test/wscript @@ -39,7 +39,8 @@ def build(bld): new_test(bld, 'test-random', '') new_test(bld, 'test-ioctl', '') new_test(bld, 'test-fork', '') + new_test(bld, 'test-tsearch', '') new_test(bld, 'test-local-socket', 'PTHREAD') new_test(bld, 'test-tcp-socket', 'PTHREAD') new_test(bld, 'test-pipe', 'PTHREAD') - \ No newline at end of file +