Bug 1759 - dce httpd example stops working with big files (~1MB)
authorHajime Tazaki <tazaki@sfc.wide.ad.jp>
Wed, 25 Sep 2013 16:02:32 +0900
changeset 515 98f8c21e069f
parent 514 3ad33fe5a5a1
child 516 c51ea1c25ebe
child 517 6c4effc7210a
Bug 1759 - dce httpd example stops working with big files (~1MB)
doc/source/dce-thttpd.rst
example/dce-httpd.cc
example/examples-to-run.py
model/dce-fd.cc
myscripts/httpd/README
myscripts/httpd/dce-httpd.cc
myscripts/httpd/dce-thttpd.patch
myscripts/httpd/wscript
utils/dce-thttpd.patch
wscript
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/source/dce-thttpd.rst	Wed Sep 25 16:02:32 2013 +0900
@@ -0,0 +1,50 @@
+This scenario use HTTP protocol using a real server and a real client.
+
+We use 2 externals software to do this experience:
+
+ 1. thttpd which is a light weight HTTP server
+ 
+ 2. wget is a well known HTTP client.
+
+The topology is simple we use 2 nodes linked by a point to point channel.
+
+As you must know to use a real application under NS-3/DCE you need to recompile it. 
+So below there is the recipes to compile the needed softwares for DCE usage.
+
+THTTPD  -------------------------------------------------------------------------------------------------
+
+Below there is the commands you may use to build thttpd :
+
+wget http://www.acme.com/software/thttpd/thttpd-2.25b.tar.gz
+tar xf thttpd-2.25b.tar.gz
+cd thttpd-2.25b
+./configure
+patch -p1 < dce-thttpd.patch
+CFLAGS=-fPIC LDFLAGS=-pie make
+cp thttpd $BASEDCE/build/bin_dce
+
+WGET ----------------------------------------------------------------------------------------------------
+
+Below there is the commands you may use to build wget:
+
+echo to get wget sources you need wget binary :)
+wget http://ftp.gnu.org/gnu/wget/wget-1.14.tar.gz
+tar xf wget-1.14.tar.gz
+cd wget-1.14/
+CFLAGS=-fPIC LDFLAGS=-pie ./configure --disable-opie  --disable-digest --disable-ntlm  --disable-largefile --disable-threads --disable-nls  --disable-rpath  --disable-iri --without-ssl --without-zlib  --without-libiconv-prefix --without-libintl-prefix --without-libpth-prefix  --without-included-regex
+make
+cp src/wget $BASEDCE/build/bin_dce
+
+---------------------------------------------------------------------------------------------------------
+
+Then to run the scenario you must provide some web pages to download at the root of the node 0 
+at minimum you should provide a file named index.html under files-0
+then you can launch the simulation by calling:
+
+$BASEDCE/build/myscripts/httpd/bin/dce-httpd
+
+the downloaded files can be found under files-1/10.1.1.1 directory
+
+---
+
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/dce-httpd.cc	Wed Sep 25 16:02:32 2013 +0900
@@ -0,0 +1,122 @@
+// ===========================================================================
+//
+//   Topology
+//
+//         node 0                 node 1
+//   +----------------+    +----------------+
+//   |    ns-3 TCP    |    |    ns-3 TCP    |
+//   +----------------+    +----------------+
+//   |    10.1.1.1    |    |    10.1.1.2    |
+//   +----------------+    +----------------+
+//   | point-to-point |    | point-to-point |
+//   +----------------+    +----------------+
+//           |                     |
+//           +---------------------+
+//                100 Mbps, 1 ms
+//
+// This experience do http
+//
+// ===========================================================================
+
+#include "ns3/network-module.h"
+#include "ns3/core-module.h"
+#include "ns3/internet-module.h"
+#include "ns3/dce-module.h"
+#include "ns3/point-to-point-module.h"
+#include "ns3/applications-module.h"
+#include "ns3/trace-helper.h"
+#include <sys/stat.h>
+#include <sys/types.h>
+
+using namespace ns3;
+void
+CreateFiles ()
+{
+  FILE *fp = fopen ("files-0/index.html", "wb"); 
+  int i;
+  for (i = 0; i < 500000;i++)
+    {
+      fprintf (fp, "%d\n", i);
+    }
+  fclose (fp);
+}
+int
+main (int argc, char *argv[])
+{
+  bool useKernel = 0;
+
+  CommandLine cmd;
+  cmd.AddValue ("kernel", "Use kernel linux IP stack.", useKernel);
+  cmd.Parse (argc, argv);
+
+  mkdir ("files-0",0744);
+  CreateFiles ();
+
+  NodeContainer nodes;
+  nodes.Create (2);
+
+  PointToPointHelper pointToPoint;
+  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("100Mbps"));
+  pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ms"));
+
+  NetDeviceContainer devices;
+  devices = pointToPoint.Install (nodes);
+
+  DceManagerHelper dceManager;
+//  dceManager.SetTaskManagerAttribute( "FiberManagerType", StringValue ( "UcontextFiberManager" ) );
+
+  if (!useKernel)
+    {
+      InternetStackHelper stack;
+      stack.Install (nodes);
+    }
+  else
+    {
+      dceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory", "Library", StringValue ("liblinux.so"));
+      LinuxStackHelper stack;
+      stack.Install (nodes);
+    }
+
+  Ipv4AddressHelper address;
+  address.SetBase ("10.1.1.0", "255.255.255.252");
+  Ipv4InterfaceContainer interfaces = address.Assign (devices);
+
+  // setup ip routes
+  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
+
+  dceManager.Install (nodes);
+
+
+  DceApplicationHelper dce;
+  ApplicationContainer server, client;
+
+  dce.SetStackSize (1 << 20);
+
+  // Launch the server HTTP
+  dce.SetBinary ("thttpd");
+  dce.ResetArguments ();
+  dce.ResetEnvironment ();
+  dce.SetUid (1);
+  dce.SetEuid (1);
+  server = dce.Install (nodes.Get (0));
+  server.Start (Seconds (1));
+
+  dce.SetBinary ("wget");
+  dce.ResetArguments ();
+  dce.ResetEnvironment ();
+  dce.AddArgument ("-r");
+  dce.AddArgument ("http://10.1.1.1/index.html");
+
+  server = dce.Install (nodes.Get (1));
+  server.Start (Seconds (2));
+
+  pointToPoint.EnablePcapAll ("thttpd", false);
+
+  Simulator::Stop (Seconds (60.0));
+  Simulator::Run ();
+
+  Simulator::Destroy ();
+
+  return 0;
+}
+
--- a/example/examples-to-run.py	Wed Sep 18 16:42:51 2013 +0200
+++ b/example/examples-to-run.py	Wed Sep 25 16:02:32 2013 +0900
@@ -71,6 +71,7 @@
     ("dce-mptcp-handoff-v4v6 --v6Primary=1 --errRate=0.5", "True", "True"),
     ("dce-mptcp-handoff-v4v6 --v6Primary=1 --errRate=0.8", "True", "True"),
 #    ("dce-mptcp-lte-wifi", "True", "True"),
+    ("dce-httpd", "True", "True"),
 ]
 
 # A list of Python examples to run in order to ensure that they remain
--- a/model/dce-fd.cc	Wed Sep 18 16:42:51 2013 +0200
+++ b/model/dce-fd.cc	Wed Sep 25 16:02:32 2013 +0900
@@ -319,11 +319,11 @@
       return -1;
     }
 
-  char buf[count], *bufp = buf;
+  void *buf = malloc (count);
   for (int i = 0; i < iovcnt; ++i)
     {
-      memcpy (bufp, iov[i].iov_base, iov[i].iov_len);
-      bufp += iov[i].iov_len;
+      memcpy (buf, iov[i].iov_base, iov[i].iov_len);
+      buf += iov[i].iov_len;
     }
 
   UnixFd *unixFd = current->process->openFiles[fd]->GetFileInc ();
--- a/myscripts/httpd/README	Wed Sep 18 16:42:51 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-This scenario use HTTP protocol using a real server and a real client.
-
-We use 2 externals software to do this experience:
-
- 1. thttpd which is a light weight HTTP server
- 
- 2. wget is a well known HTTP client.
-
-The topology is simple we use 2 nodes linked by a point to point channel.
-
-As you must know to use a real application under NS-3/DCE you need to recompile it. 
-So below there is the recipes to compile the needed softwares for DCE usage.
-
-THTTPD  -------------------------------------------------------------------------------------------------
-
-Below there is the commands you may use to build thttpd :
-
-wget http://www.acme.com/software/thttpd/thttpd-2.25b.tar.gz
-tar xf thttpd-2.25b.tar.gz
-cd thttpd-2.25b
-./configure
-patch -p1 < dce-thttpd.patch
-CFLAGS=-fPIC LDFLAGS=-pie make
-cp thttpd $BASEDCE/build/bin_dce
-
-WGET ----------------------------------------------------------------------------------------------------
-
-Below there is the commands you may use to build wget:
-
-echo to get wget sources you need wget binary :)
-wget http://ftp.gnu.org/gnu/wget/wget-1.14.tar.gz
-tar xf wget-1.14.tar.gz
-cd wget-1.14/
-CFLAGS=-fPIC LDFLAGS=-pie ./configure --disable-opie  --disable-digest --disable-ntlm  --disable-largefile --disable-threads --disable-nls  --disable-rpath  --disable-iri --without-ssl --without-zlib  --without-libiconv-prefix --without-libintl-prefix --without-libpth-prefix  --without-included-regex
-make
-cp src/wget $BASEDCE/build/bin_dce
-
----------------------------------------------------------------------------------------------------------
-
-Then to run the scenario you must provide some web pages to download at the root of the node 0 
-at minimum you should provide a file named index.html under files-0
-then you can launch the simulation by calling:
-
-$BASEDCE/build/myscripts/httpd/bin/dce-httpd
-
-the downloaded files can be found under files-1/10.1.1.1 directory
-
----
-
- 
\ No newline at end of file
--- a/myscripts/httpd/dce-httpd.cc	Wed Sep 18 16:42:51 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-// ===========================================================================
-//
-//   Topology
-//
-//         node 0                 node 1
-//   +----------------+    +----------------+
-//   |    ns-3 TCP    |    |    ns-3 TCP    |
-//   +----------------+    +----------------+
-//   |    10.1.1.1    |    |    10.1.1.2    |
-//   +----------------+    +----------------+
-//   | point-to-point |    | point-to-point |
-//   +----------------+    +----------------+
-//           |                     |
-//           +---------------------+
-//                100 Mbps, 1 ms
-//
-// This experience do http
-//
-// ===========================================================================
-
-#include "ns3/network-module.h"
-#include "ns3/core-module.h"
-#include "ns3/internet-module.h"
-#include "ns3/dce-module.h"
-#include "ns3/point-to-point-module.h"
-#include "ns3/applications-module.h"
-#include "ns3/trace-helper.h"
-#include <sys/stat.h>
-#include <sys/types.h>
-
-using namespace ns3;
-void
-CreateFiles ()
-{
-  std::ofstream osf ("files-0/index.html", std::fstream::trunc);
-  osf << "<HTML><HEAD><TITLE>Hello</TITLE></HEAD><BODY><H3>HELLO</H3>"
-      << "<P>is all right ?</BODY></HTML>" << std::endl;
-  osf.close ();
-}
-int
-main (int argc, char *argv[])
-{
-  bool useKernel = 0;
-
-  CommandLine cmd;
-  cmd.AddValue ("kernel", "Use kernel linux IP stack.", useKernel);
-  cmd.Parse (argc, argv);
-
-  mkdir ("files-0",0744);
-//  CreateFiles ();
-
-  NodeContainer nodes;
-  nodes.Create (2);
-
-  PointToPointHelper pointToPoint;
-  pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("100Mbps"));
-  pointToPoint.SetChannelAttribute ("Delay", StringValue ("1ms"));
-
-  NetDeviceContainer devices;
-  devices = pointToPoint.Install (nodes);
-
-  DceManagerHelper dceManager;
-//  dceManager.SetTaskManagerAttribute( "FiberManagerType", StringValue ( "UcontextFiberManager" ) );
-
-  if (!useKernel)
-    {
-      InternetStackHelper stack;
-      stack.Install (nodes);
-    }
-  else
-    {
-      dceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory", "Library", StringValue ("liblinux.so"));
-      LinuxStackHelper stack;
-      stack.Install (nodes);
-    }
-
-  Ipv4AddressHelper address;
-  address.SetBase ("10.1.1.0", "255.255.255.252");
-  Ipv4InterfaceContainer interfaces = address.Assign (devices);
-
-  // setup ip routes
-  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
-
-  dceManager.Install (nodes);
-
-
-  DceApplicationHelper dce;
-  ApplicationContainer server, client;
-
-  dce.SetStackSize (1 << 20);
-
-  // Launch the server HTTP
-  dce.SetBinary ("thttpd");
-  dce.ResetArguments ();
-  dce.ResetEnvironment ();
-  dce.SetUid (1);
-  dce.SetEuid (1);
-  server = dce.Install (nodes.Get (0));
-  server.Start (Seconds (1));
-
-  dce.SetBinary ("wget");
-  dce.ResetArguments ();
-  dce.ResetEnvironment ();
-  dce.AddArgument ("-r");
-  dce.AddArgument ("http://10.1.1.1/index.html");
-
-  server = dce.Install (nodes.Get (1));
-  server.Start (Seconds (2));
-
-  pointToPoint.EnablePcapAll ("thttpd", false);
-
-  Simulator::Stop (Seconds (60.0));
-  Simulator::Run ();
-
-  Simulator::Destroy ();
-
-  return 0;
-}
-
--- a/myscripts/httpd/dce-thttpd.patch	Wed Sep 18 16:42:51 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-diff -r 26e35047fda8 Makefile
---- a/Makefile	Tue Oct 23 15:40:55 2012 +0200
-+++ b/Makefile	Tue Oct 23 15:41:39 2012 +0200
-@@ -49,10 +49,10 @@
- 
- CC =		gcc
- CCOPT =		-O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=	
- LIBS =		-lcrypt 
- NETLIBS =	
- INSTALL =	/usr/bin/install -c
--- a/myscripts/httpd/wscript	Wed Sep 18 16:42:51 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
-
-import ns3waf
-
-def configure(conf):
-    ns3waf.check_modules(conf, ['core', 'internet', 'point-to-point' ], mandatory = True)
-
-def build(bld):
-    if bld.env['KERNEL_STACK']:
-      bld.build_a_script('dce', needed = ['core', 'internet', 'dce', 'point-to-point' ],
-				  target='bin/dce-httpd',
-				  source=['dce-httpd.cc'],
-				  )
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/utils/dce-thttpd.patch	Wed Sep 25 16:02:32 2013 +0900
@@ -0,0 +1,17 @@
+diff -r 26e35047fda8 Makefile
+--- a/Makefile	Tue Oct 23 15:40:55 2012 +0200
++++ b/Makefile	Tue Oct 23 15:41:39 2012 +0200
+@@ -49,10 +49,10 @@
+ 
+ CC =		gcc
+ CCOPT =		-O2
+-DEFS =		 -DHAVE__PROGNAME=1 -DHAVE_FCNTL_H=1 -DHAVE_GRP_H=1 -DHAVE_MEMORY_H=1 -DHAVE_PATHS_H=1 -DHAVE_POLL_H=1 -DHAVE_SYS_POLL_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_DIRENT_H=1 -DHAVE_LIBCRYPT=1 -DHAVE_STRERROR=1 -DHAVE_WAITPID=1 -DHAVE_VSNPRINTF=1 -DHAVE_DAEMON=1 -DHAVE_SETSID=1 -DHAVE_GETADDRINFO=1 -DHAVE_GETNAMEINFO=1 -DHAVE_GAI_STRERROR=1 -DHAVE_SIGSET=1 -DHAVE_ATOLL=1 -DHAVE_UNISTD_H=1 -DHAVE_GETPAGESIZE=1 -DHAVE_MMAP=1 -DHAVE_SELECT=1 -DHAVE_POLL=1 -DHAVE_TM_GMTOFF=1 -DHAVE_INT64T=1 -DHAVE_SOCKLENT=1 
++DEFS =		 -DHAVE__PROGNAME=1 -DHAVE_FCNTL_H=1 -DHAVE_GRP_H=1 -DHAVE_MEMORY_H=1 -DHAVE_PATHS_H=1 -DHAVE_POLL_H=1 -DHAVE_SYS_POLL_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_DIRENT_H=1 -DHAVE_LIBCRYPT=1 -DHAVE_STRERROR=1 -DHAVE_WAITPID=1 -DHAVE_VSNPRINTF=1 -DHAVE_DAEMON=1 -DHAVE_SETSID=1 -DHAVE_GETADDRINFO=1 -DHAVE_GETNAMEINFO=1 -DHAVE_GAI_STRERROR=1 -DHAVE_ATOLL=1 -DHAVE_UNISTD_H=1 -DHAVE_GETPAGESIZE=1 -DHAVE_MMAP=1 -DHAVE_SELECT=1 -DHAVE_POLL=1 -DHAVE_TM_GMTOFF=1 -DHAVE_INT64T=1 -DHAVE_SOCKLENT=1 
+ INCLS =		-I.
+-CFLAGS =	$(CCOPT) $(DEFS) $(INCLS)
+-LDFLAGS =	
++CFLAGS +=	$(CCOPT) $(DEFS) $(INCLS) -fPIC -g
++LDFLAGS +=	-pie -rdynamic
+ LIBS =		-lcrypt 
+ NETLIBS =	
+ INSTALL =	/usr/bin/install -c
--- a/wscript	Wed Sep 18 16:42:51 2013 +0200
+++ b/wscript	Wed Sep 25 16:02:32 2013 +0900
@@ -411,6 +411,10 @@
                        target='bin/dce-tcp-ns3-nsc-comparison',
                        source=['example/dce-tcp-ns3-nsc-comparison.cc'])
 
+    module.add_example(needed = ['core', 'internet', 'dce', 'point-to-point'],
+                       target='bin/dce-httpd',
+                       source=['example/dce-httpd.cc'])
+
 # Add a script to build system 
 def build_a_script(bld, name, needed = [], **kw):
     external = [i for i in needed if not i == name]