new simple example for linux kernel
authorMathieu Lacage <mathieu.lacage@inria.fr>
Tue, 01 Feb 2011 13:46:40 +0100
changeset 6789 ee067f423223
parent 6788 c2caead1ca3b
child 6790 967269892662
new simple example for linux kernel
src/dce/example/dce-linux-simple.cc
src/dce/example/wscript
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/dce/example/dce-linux-simple.cc	Tue Feb 01 13:46:40 2011 +0100
@@ -0,0 +1,59 @@
+#include "ns3/helper-module.h"
+#include "ns3/simulator-module.h"
+#include "ns3/core-module.h"
+
+using namespace ns3;
+
+int main (int argc, char *argv[])
+{
+  CommandLine cmd;
+  cmd.Parse (argc, argv);
+
+  NodeContainer nodes;
+  nodes.Create (1);
+
+  DceManagerHelper dceManager;
+  dceManager.SetNetworkStack("ns3::LinuxSocketFdFactory",
+			     "Library", StringValue ("libnet-next-2.6.so"));
+  dceManager.Install (nodes);
+
+  DceApplicationHelper dce;
+  ApplicationContainer apps;
+  dce.SetBinary ("./ip");
+  dce.SetStackSize (1<<16);
+
+  dce.ResetArguments();
+  dce.ParseArguments("-f inet addr add local 127.0.0.1/8 scope host dev lo");
+  apps = dce.Install (nodes.Get (0));
+  apps.Start (Seconds (2.0));
+  dce.ResetArguments();
+  dce.ParseArguments("link set lo up");
+  apps = dce.Install (nodes.Get (0));
+  apps.Start (Seconds (3.0));
+  dce.ResetArguments();
+  dce.ParseArguments("route list table all");
+  apps = dce.Install (nodes.Get (0));
+  apps.Start (Seconds (3.1));
+
+  dce.ResetArguments();
+  dce.ParseArguments("addr show dev lo");
+  apps = dce.Install (nodes.Get (0));
+  apps.Start (Seconds (3.0));
+
+  dce.SetBinary ("udp-server");
+  dce.ResetArguments();
+  apps = dce.Install (nodes.Get (0));
+  apps.Start (Seconds (4.0));
+
+  dce.SetBinary ("udp-client");
+  dce.ResetArguments();
+  dce.AddArgument ("127.0.0.1");
+  apps = dce.Install (nodes.Get (0));
+  apps.Start (Seconds (4.5));
+
+  Simulator::Stop (Seconds(1000100.0));
+  Simulator::Run ();
+  Simulator::Destroy ();
+
+  return 0;
+}
--- a/src/dce/example/wscript	Mon Jan 31 17:26:13 2011 +0100
+++ b/src/dce/example/wscript	Tue Feb 01 13:46:40 2011 +0100
@@ -24,6 +24,11 @@
                                   'internet-stack', 'dce-manager'])
     obj.source = 'dce-udp-simple.cc'
 
+    obj = bld.create_ns3_program('dce-linux-simple', 
+                                 ['core', 'simulator', 'point-to-point', 
+                                  'internet-stack', 'dce-manager'])
+    obj.source = 'dce-linux-simple.cc'
+
     obj = bld.create_ns3_program('dce-iperf', 
                                  ['core', 'simulator', 'point-to-point', 
                                   'internet-stack', 'dce-manager'])