example/dce-sctp-simple.cc
author Hajime Tazaki <tazaki@sfc.wide.ad.jp>
Mon, 21 Nov 2016 16:01:12 +0900
changeset 772 274220a5a949
permissions -rw-r--r--
follow up fix for waf-1.8 upgrade
     1 #include "ns3/core-module.h"
     2 #include "ns3/network-module.h"
     3 #include "ns3/dce-module.h"
     4 #include "ns3/point-to-point-module.h"
     5 #include "ns3/internet-module.h"
     6 #include <fstream>
     7 
     8 using namespace ns3;
     9 
    10 static void RunIp (Ptr<Node> node, Time at, std::string str)
    11 {
    12   DceApplicationHelper process;
    13   ApplicationContainer apps;
    14   process.SetBinary ("ip");
    15   process.SetStackSize (1<<16);
    16   process.ResetArguments();
    17   process.ParseArguments(str.c_str ());
    18   apps = process.Install (node);
    19   apps.Start (at);
    20 }
    21 
    22 int main (int argc, char *argv[])
    23 {
    24   CommandLine cmd;
    25   cmd.Parse (argc, argv);
    26 
    27   NodeContainer nodes;
    28   nodes.Create (2);
    29 
    30   NetDeviceContainer devices;
    31 
    32   PointToPointHelper p2p;
    33   p2p.SetDeviceAttribute ("DataRate", StringValue ("5Gbps"));
    34   p2p.SetChannelAttribute ("Delay", StringValue ("1ms"));
    35   devices = p2p.Install (nodes);
    36   p2p.EnablePcapAll ("dce-sctp-simple");
    37 
    38   DceManagerHelper processManager;
    39   processManager.SetTaskManagerAttribute ("FiberManagerType",
    40                                           StringValue ("UcontextFiberManager"));
    41   // processManager.SetLoader ("ns3::DlmLoaderFactory");
    42   processManager.SetNetworkStack("ns3::LinuxSocketFdFactory", "Library", StringValue ("liblinux.so"));
    43   LinuxStackHelper stack;
    44   stack.Install (nodes);
    45 
    46   Ipv4AddressHelper address;
    47   address.SetBase ("10.0.0.0", "255.255.255.0");
    48   Ipv4InterfaceContainer interfaces = address.Assign (devices);
    49 
    50   processManager.Install (nodes);
    51 
    52 
    53   for (int n=0; n < 2; n++)
    54     {
    55       RunIp (nodes.Get (n), Seconds (0.2), "link show");
    56       RunIp (nodes.Get (n), Seconds (0.3), "route show table all");
    57       RunIp (nodes.Get (n), Seconds (0.4), "addr list");
    58     }
    59 
    60   DceApplicationHelper process;
    61   ApplicationContainer apps;
    62 
    63   process.SetBinary ("sctp-server");
    64   process.ResetArguments ();
    65   process.SetStackSize (1<<16);
    66   apps = process.Install (nodes.Get (0));
    67   apps.Start (Seconds (1.0));
    68 
    69   process.SetBinary ("sctp-client");
    70   process.ResetArguments ();
    71   process.ParseArguments ("10.0.0.1");
    72   apps = process.Install (nodes.Get (1));
    73   apps.Start (Seconds (1.5));
    74 
    75   Simulator::Stop (Seconds (2000000.0));
    76   Simulator::Run ();
    77   Simulator::Destroy ();
    78 
    79   return 0;
    80 }