Update some examples.
--- a/example/ccnx/dce-ccnd-linear-multiple.cc Mon Jul 16 11:34:40 2012 +0200
+++ b/example/ccnx/dce-ccnd-linear-multiple.cc Mon Jul 16 13:45:42 2012 +0200
@@ -17,7 +17,7 @@
*
* Author: Frederic Urbani <frederic.urbani@inria.fr>
*
-*/
+ */
#include "ns3/network-module.h"
#include "ns3/core-module.h"
@@ -29,6 +29,7 @@
#include "misc-tools.h"
using namespace ns3;
+
//
// Network topology
// 1 2 3 4 5 6
@@ -64,7 +65,7 @@
int ccnxVersion = 4;
CommandLine cmd;
- cmd.AddValue("nNodes", "Number of nodes to place in the line", nNodes);
+ cmd.AddValue ("nNodes", "Number of nodes to place in the line", nNodes);
cmd.AddValue ("tcp", "Use TCP to link ccnd daemons.", useTcp);
cmd.AddValue ("kernel", "Use kernel linux IP stack.", useKernel);
cmd.AddValue ("cv", "Ccnx version 4 for 0.4.x variantes and 5 for 0.5.x variantes, default: 4",
@@ -91,7 +92,11 @@
InternetStackHelper stack;
stack.Install (nodes);
}
-
+ else
+ {
+ LinuxStackHelper stack;
+ stack.Install (nodes);
+ }
NetDeviceContainer devices;
std::vector<Ipv4InterfaceContainer> vInterfaces;
std::vector<std::vector<Ipv4Address> > networks;
@@ -100,42 +105,15 @@
{
devices = pointToPoint.Install (nodes.Get (n), nodes.Get ( 1 + n ) );
- if ( useKernel )
- {
- std::vector<Ipv4Address> addrs;
+ std::vector<Ipv4Address> addrs;
- addrs.push_back ( address.NewAddress ());
- addrs.push_back ( address.NewAddress ());
- address.NewNetwork ();
- networks.push_back (addrs);
- }
- else
- {
- std::vector<Ipv4Address> addrs;
+ Ipv4InterfaceContainer interfaces = address.Assign (devices);
+ address.NewNetwork ();
- Ipv4InterfaceContainer interfaces = address.Assign (devices);
- address.NewNetwork ();
- vInterfaces.push_back ( interfaces );
- addrs.push_back ( vInterfaces[n].GetAddress ( 0 ));
- addrs.push_back ( vInterfaces[n].GetAddress ( 1 ) );
- networks.push_back (addrs);
- }
-
- if (useKernel)
- {
- std::string devName = n?"sim1":"sim0";
- AddAddress (nodes.Get (n), Seconds ( 0.01 ), devName.c_str (), (Ipv4AddressToString (networks[n][0] ) + "/24").c_str () );
- RunIp (nodes.Get (n), Seconds ( 0.1 ), ("link set "+devName+" up arp off").c_str ());
-
- AddAddress (nodes.Get (n+1), Seconds ( 0.02 ), "sim0", (Ipv4AddressToString (networks[n][1]) + "/24").c_str () );
- RunIp (nodes.Get (n+1), Seconds ( 0.12 ), "link set sim0 up arp off");
- }
- }
-
- if (!useKernel)
- {
- // setup ip routes
- Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
+ vInterfaces.push_back ( interfaces );
+ addrs.push_back ( vInterfaces[n].GetAddress ( 0 ));
+ addrs.push_back ( vInterfaces[n].GetAddress ( 1 ) );
+ networks.push_back (addrs);
}
DceManagerHelper dceManager;
--- a/example/ccnx/dce-ccnd-udp-2-nodes.cc Mon Jul 16 11:34:40 2012 +0200
+++ b/example/ccnx/dce-ccnd-udp-2-nodes.cc Mon Jul 16 13:45:42 2012 +0200
@@ -76,32 +76,27 @@
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
+ DceManagerHelper dceManager;
+
if (!useKernel)
{
InternetStackHelper 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 ();
+ }
+ else
+ {
+ dceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory", "Library", StringValue ("libnet-next-2.6.so"));
+ LinuxStackHelper stack;
+ stack.Install (nodes);
}
- DceManagerHelper dceManager;
-
- if (useKernel)
- {
- dceManager.SetNetworkStack("ns3::LinuxSocketFdFactory", "Library", StringValue ("libnet-next-2.6.so"));
+ Ipv4AddressHelper address;
+ address.SetBase ("10.1.1.0", "255.255.255.252");
+ Ipv4InterfaceContainer interfaces = address.Assign (devices);
- AddAddress (nodes.Get (0), Seconds (0.1), "sim0", "10.1.1.1/8");
- RunIp (nodes.Get (0), Seconds (0.2), "link set sim0 up arp off");
+ // setup ip routes
+ Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
- AddAddress (nodes.Get (1), Seconds (0.3), "sim0","10.1.1.2/8");
- RunIp (nodes.Get (1), Seconds (0.4), "link set sim0 up arp off");
-
- }
dceManager.Install (nodes);
// Names::Add ("NODE_Zero", nodes.Get (0));
--- a/example/dce-iperf.cc Mon Jul 16 11:34:40 2012 +0200
+++ b/example/dce-iperf.cc Mon Jul 16 13:45:42 2012 +0200
@@ -32,7 +32,6 @@
// ===========================================================================
int main (int argc, char *argv[])
{
- std::string animFile = "NetAnim.tr";
bool useKernel = 0;
bool useUdp = 0;
std::string bandWidth = "1m";
@@ -52,33 +51,28 @@
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
+ DceManagerHelper dceManager;
+ dceManager.SetTaskManagerAttribute( "FiberManagerType", StringValue ( "UcontextFiberManager" ) );
+
if (!useKernel)
{
InternetStackHelper 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 ();
+ }
+ else
+ {
+ dceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory", "Library", StringValue ("libnet-next-2.6.so"));
+ LinuxStackHelper stack;
+ stack.Install (nodes);
}
- DceManagerHelper dceManager;
- dceManager.SetTaskManagerAttribute( "FiberManagerType", StringValue ( "UcontextFiberManager" ) );
-
- if (useKernel)
- {
- dceManager.SetNetworkStack("ns3::LinuxSocketFdFactory", "Library", StringValue ("libnet-next-2.6.so"));
+ Ipv4AddressHelper address;
+ address.SetBase ("10.1.1.0", "255.255.255.252");
+ Ipv4InterfaceContainer interfaces = address.Assign (devices);
- AddAddress (nodes.Get (0), Seconds (0.1), "sim0", "10.1.1.1/8");
- RunIp (nodes.Get (0), Seconds (0.2), "link set sim0 up arp off");
+ // setup ip routes
+ Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
- AddAddress (nodes.Get (1), Seconds (0.3), "sim0","10.1.1.2/8");
- RunIp (nodes.Get (1), Seconds (0.4), "link set sim0 up arp off");
-
- }
dceManager.Install (nodes);
DceApplicationHelper dce;
@@ -122,25 +116,15 @@
apps = dce.Install (nodes.Get (1));
pointToPoint.EnablePcapAll (useKernel?"iperf-kernel":"iperf-ns3", false);
-// pointToPoint.EnablePcap("dev0", devices.Get(0), false, false);
-// pointToPoint.EnablePcap("dev0", devices.Get(0), false, false);
-
apps.Start (Seconds (0.6));
setPos (nodes.Get (0), 1, 10, 0);
setPos (nodes.Get (1), 50,10, 0);
- // Create the animation object and configure for specified output
-
-// AnimationInterface anim (animFile, false);
-
- //anim.StartAnimation ();
Simulator::Stop (Seconds(40.0));
Simulator::Run ();
Simulator::Destroy ();
-// anim.StopAnimation ();
-
return 0;
}
--- a/example/dce-linux.cc Mon Jul 16 11:34:40 2012 +0200
+++ b/example/dce-linux.cc Mon Jul 16 13:45:42 2012 +0200
@@ -5,6 +5,7 @@
#include "ns3/csma-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mobility-module.h"
+#include "ns3/internet-module.h"
#include <fstream>
using namespace ns3;
@@ -21,14 +22,6 @@
apps.Start (at);
}
-static void AddAddress (Ptr<Node> node, Time at, const char *name, const std::string prefixAddr,
- int number, std::string suffixAddr)
-{
- std::ostringstream oss;
- oss << "-f inet addr add " << prefixAddr << number << suffixAddr << " dev " << name;
- RunIp (node, at, oss.str ());
-}
-
int main (int argc, char *argv[])
{
CommandLine cmd;
@@ -103,52 +96,56 @@
}
DceManagerHelper processManager;
- // processManager.SetLoader ("ns3::DlmLoaderFactory");
- processManager.SetNetworkStack("ns3::LinuxSocketFdFactory",
- "Library", StringValue ("libnet-next-2.6.so"));
+ // processManager.SetLoader ("ns3::DlmLoaderFactory");
+ processManager.SetNetworkStack("ns3::LinuxSocketFdFactory", "Library", StringValue ("libnet-next-2.6.so"));
+ LinuxStackHelper stack;
+ stack.Install (nodes);
+
+ Ipv4AddressHelper address;
+ address.SetBase ("10.0.0.0", "255.255.255.0");
+ Ipv4InterfaceContainer interfaces = address.Assign (devices);
+
processManager.Install (nodes);
+
for (int n=0; n < 2; n++)
{
- AddAddress (nodes.Get (n), Seconds (0.1), "sim0", "10.0.0.", 2 + n, "/8" );
- RunIp (nodes.Get (n), Seconds (0.11),
- ( 'p' == linkType )? "link set sim0 up arp off":"link set sim0 up arp on");
RunIp (nodes.Get (n), Seconds (0.2), "link show");
RunIp (nodes.Get (n), Seconds (0.3), "route show table all");
RunIp (nodes.Get (n), Seconds (0.4), "addr list");
}
- DceApplicationHelper process;
- ApplicationContainer apps;
+ DceApplicationHelper process;
+ ApplicationContainer apps;
- if (reliable)
- {
- process.SetBinary ("tcp-server");
- process.ResetArguments ();
- process.SetStackSize (1<<16);
- apps = process.Install (nodes.Get (0));
- apps.Start (Seconds (1.0));
+ if (reliable)
+ {
+ process.SetBinary ("tcp-server");
+ process.ResetArguments ();
+ process.SetStackSize (1<<16);
+ apps = process.Install (nodes.Get (0));
+ apps.Start (Seconds (1.0));
- process.SetBinary ("tcp-client");
- process.ResetArguments ();
- process.ParseArguments ("10.0.0.2");
- apps = process.Install (nodes.Get (1));
- apps.Start (Seconds (1.5));
- }
- else
- {
- process.SetBinary ("udp-server");
- process.ResetArguments ();
- process.SetStackSize (1<<16);
- apps = process.Install (nodes.Get (0));
- apps.Start (Seconds (1.0));
+ process.SetBinary ("tcp-client");
+ process.ResetArguments ();
+ process.ParseArguments ("10.0.0.1");
+ apps = process.Install (nodes.Get (1));
+ apps.Start (Seconds (1.5));
+ }
+ else
+ {
+ process.SetBinary ("udp-server");
+ process.ResetArguments ();
+ process.SetStackSize (1<<16);
+ apps = process.Install (nodes.Get (0));
+ apps.Start (Seconds (1.0));
- process.SetBinary ("udp-client");
- process.ResetArguments ();
- process.ParseArguments ("10.0.0.2");
- apps = process.Install (nodes.Get (1));
- apps.Start (Seconds (1.5));
- }
+ process.SetBinary ("udp-client");
+ process.ResetArguments ();
+ process.ParseArguments ("10.0.0.1");
+ apps = process.Install (nodes.Get (1));
+ apps.Start (Seconds (1.5));
+ }
Simulator::Stop (Seconds (2000000.0));
Simulator::Run ();