example/dce-dccp.cc
author frederic.urbani@inria.fr
Thu, 28 Mar 2013 15:19:04 +0100
changeset 425 456bb670b7d2
parent 367 be749a6bbde0
permissions -rw-r--r--
remove very old TODO file.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
314
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
     1
#include "ns3/network-module.h"
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
     2
#include "ns3/core-module.h"
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
     3
#include "ns3/dce-module.h"
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
     4
#include "ns3/csma-module.h"
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
     5
#include "ns3/internet-module.h"
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
     6
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
     7
using namespace ns3;
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
     8
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
     9
int main (int argc, char *argv[])
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    10
{
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    11
  CommandLine cmd;
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    12
  cmd.Parse (argc, argv);
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    13
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    14
  NodeContainer nodes;
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    15
  nodes.Create (2);
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    16
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    17
  CsmaHelper csma;
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    18
  csma.SetChannelAttribute ("DataRate", StringValue ("5Mbps"));
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    19
  csma.SetChannelAttribute ("Delay", StringValue ("2ms"));
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    20
  NetDeviceContainer devices = csma.Install (nodes);
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    21
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    22
  DceManagerHelper dceManager;
316
e7d41a9bf04d stick Ucontext fiber for some issues during exit
Hajime Tazaki <tazaki@nict.go.jp>
parents: 314
diff changeset
    23
  dceManager.SetTaskManagerAttribute ("FiberManagerType",
e7d41a9bf04d stick Ucontext fiber for some issues during exit
Hajime Tazaki <tazaki@nict.go.jp>
parents: 314
diff changeset
    24
                                      StringValue ("UcontextFiberManager"));
367
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 316
diff changeset
    25
  dceManager.SetNetworkStack ("ns3::LinuxSocketFdFactory",
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 316
diff changeset
    26
                              "Library", StringValue ("liblinux.so"));
314
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    27
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    28
  LinuxStackHelper stack;
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    29
  stack.Install (nodes);
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    30
  Ipv4AddressHelper address;
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    31
  address.SetBase ("10.0.0.0", "255.255.255.0");
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    32
  Ipv4InterfaceContainer interfaces = address.Assign (devices);
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    33
  dceManager.Install (nodes);
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    34
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    35
  DceApplicationHelper dce;
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    36
  ApplicationContainer apps;
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    37
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    38
  dce.SetBinary ("dccp-server");
367
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 316
diff changeset
    39
  dce.SetStackSize (1 << 16);
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 316
diff changeset
    40
  dce.ResetArguments ();
314
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    41
  apps = dce.Install (nodes.Get (0));
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    42
  apps.Start (Seconds (4.0));
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    43
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    44
  dce.SetBinary ("dccp-client");
367
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 316
diff changeset
    45
  dce.SetStackSize (1 << 16);
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 316
diff changeset
    46
  dce.ResetArguments ();
314
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    47
  dce.AddArgument ("10.0.0.1");
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    48
  apps = dce.Install (nodes.Get (1));
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    49
  apps.Start (Seconds (4.5));
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    50
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    51
  csma.EnablePcapAll ("dce-dccp");
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    52
367
be749a6bbde0 coding style adapted. check-style.py applied with manuay modification.
Hajime Tazaki <tazaki@nict.go.jp>
parents: 316
diff changeset
    53
  Simulator::Stop (Seconds (1000100.0));
314
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    54
  Simulator::Run ();
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    55
  Simulator::Destroy ();
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    56
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    57
  return 0;
c617b90f0b73 add DCCP support with ns-3-linux update
Hajime Tazaki <tazaki@nict.go.jp>
parents:
diff changeset
    58
}