examples/simple-global-routing.cc
author Florian Westphal <fw@strlen.de>
Wed, 03 Sep 2008 23:24:59 +0200
changeset 3595 693faf7f4e9b
parent 3381 3cdd9d60f7c7
child 4218 debf1a8a96d3
permissions -rw-r--r--
nsc: Fix build problem if gtk config store is disabled gtk config store pulled in libdl.so for us, so things fail to link of the config store isn't enabled. This makes nsc pull in libdl itself when its enabled.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
/*
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
 *
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
 * GNU General Public License for more details.
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
 *
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
 *
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    16
 * ns-2 simple.tcl script (ported from ns-2)
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
 * Originally authored by Steve McCanne, 12/19/1996
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    18
 */
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    19
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
// Port of ns-2/tcl/ex/simple.tcl to ns-3
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
//
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    22
// Network topology
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    23
//
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
//  n0
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
//     \ 5 Mb/s, 2ms
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    26
//      \          1.5Mb/s, 10ms
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    27
//       n2 -------------------------n3
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
//      /
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    29
//     / 5 Mb/s, 2ms
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    30
//   n1
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    31
//
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    32
// - all links are point-to-point links with indicated one-way BW/delay
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    33
// - CBR/UDP flows from n0 to n3, and from n3 to n1
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    34
// - FTP/TCP flow from n0 to n3, starting at time 1.2 to time 1.35 sec.
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    35
// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec.
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    36
//   (i.e., DataRate of 448,000 bps)
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
// - DropTail queues 
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    38
// - Tracing of queues and packet receptions to file "simple-global-routing.tr"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    39
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    40
#include <iostream>
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    41
#include <fstream>
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    42
#include <string>
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    43
#include <cassert>
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    44
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    45
#include "ns3/core-module.h"
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    46
#include "ns3/simulator-module.h"
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
    47
#include "ns3/node-module.h"
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    48
#include "ns3/helper-module.h"
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    49
#include "ns3/global-route-manager.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    50
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    51
using namespace ns3;
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    52
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    53
NS_LOG_COMPONENT_DEFINE ("SimpleGlobalRoutingExample");
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    54
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    55
int 
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    56
main (int argc, char *argv[])
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    57
{
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    58
  // Users may find it convenient to turn on explicit debugging
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    59
  // for selected modules; the below lines suggest how to do this
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    60
#if 0 
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    61
  LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO);
2861
18930dcd33e0 test test
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    62
#endif
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    63
2861
18930dcd33e0 test test
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    64
  //
18930dcd33e0 test test
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    65
  // Make the random number generators generate reproducible results.
18930dcd33e0 test test
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    66
  //
18930dcd33e0 test test
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    67
  RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
18930dcd33e0 test test
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    68
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    69
  // Set up some default values for the simulation.  Use the 
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
    70
  Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (210));
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
    71
  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
1224
7cbc1d661b89 rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1209
diff changeset
    73
  //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);   
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    74
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
  // Allow the user to override any of the defaults and the above
1224
7cbc1d661b89 rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1209
diff changeset
    76
  // DefaultValue::Bind ()s at run-time, via command-line arguments
2575
1aae382e65e2 rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2533
diff changeset
    77
  CommandLine cmd;
1aae382e65e2 rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2533
diff changeset
    78
  cmd.Parse (argc, argv);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    80
  // Here, we will explicitly create four nodes.  In more sophisticated
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    81
  // topologies, we could configure a node factory.
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    82
  NS_LOG_INFO ("Create nodes.");
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    83
  NodeContainer c;
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    84
  c.Create (4);
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    85
  NodeContainer n0n2 = NodeContainer (c.Get(0), c.Get (2));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    86
  NodeContainer n1n2 = NodeContainer (c.Get(1), c.Get (2));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    87
  NodeContainer n3n2 = NodeContainer (c.Get(3), c.Get (2));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    88
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    89
  InternetStackHelper internet;
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
    90
  internet.Install (c);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    91
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    92
  // We create the channels first without any IP addressing information
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    93
  NS_LOG_INFO ("Create channels.");
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    94
  PointToPointHelper p2p;
3381
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    95
  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    96
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
    97
  NetDeviceContainer d0d2 = p2p.Install (n0n2);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    98
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
    99
  NetDeviceContainer d1d2 = p2p.Install (n1n2);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   100
  
3381
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
   101
  p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
   102
  p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   103
  NetDeviceContainer d3d2 = p2p.Install (n3n2);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   104
  
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   105
  // Later, we add IP addresses.  
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
   106
  NS_LOG_INFO ("Assign IP Addresses.");
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   107
  Ipv4AddressHelper ipv4;
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   108
  ipv4.SetBase ("10.1.1.0", "255.255.255.0");
2888
872dc8466352 Ipv4AddressHelper::Allocate -> Ipv4AddressHelper::Assign
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2887
diff changeset
   109
  Ipv4InterfaceContainer i0i2 = ipv4.Assign (d0d2);
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   110
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   111
  ipv4.SetBase ("10.1.2.0", "255.255.255.0");
2888
872dc8466352 Ipv4AddressHelper::Allocate -> Ipv4AddressHelper::Assign
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2887
diff changeset
   112
  Ipv4InterfaceContainer i1i2 = ipv4.Assign (d1d2);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   113
  
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   114
  ipv4.SetBase ("10.1.3.0", "255.255.255.0");
2888
872dc8466352 Ipv4AddressHelper::Allocate -> Ipv4AddressHelper::Assign
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2887
diff changeset
   115
  Ipv4InterfaceContainer i3i2 = ipv4.Assign (d3d2);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   117
  // Create router nodes, initialize routing database and set up the routing
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   118
  // tables in the nodes.
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   119
  GlobalRouteManager::PopulateRoutingTables ();
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   120
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   121
  // Create the OnOff application to send UDP datagrams of size
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   122
  // 210 bytes at a rate of 448 Kb/s
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
   123
  NS_LOG_INFO ("Create Applications.");
1514
addb79f47ba5 change port number used by example scripts to 'discard' or 'echo' instead of '80'
Tom Henderson <tomh@tomh.org>
parents: 1504
diff changeset
   124
  uint16_t port = 9;   // Discard port (RFC 863)
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 2997
diff changeset
   125
  OnOffHelper onoff ("ns3::UdpSocketFactory", 
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
   126
    Address (InetSocketAddress (i3i2.GetAddress (0), port)));
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
   127
  onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1)));
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
   128
  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   129
  ApplicationContainer apps = onoff.Install (c.Get (0));
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   130
  apps.Start (Seconds (1.0));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   131
  apps.Stop (Seconds (10.0));
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   132
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   133
  // Create a packet sink to receive these packets
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 2997
diff changeset
   134
  PacketSinkHelper sink ("ns3::UdpSocketFactory",
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
   135
    Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   136
  apps = sink.Install (c.Get (3));
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   137
  apps.Start (Seconds (1.0));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   138
  apps.Stop (Seconds (10.0));
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   139
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   140
  // Create a similar flow from n3 to n1, starting at time 1.1 seconds
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
   141
  onoff.SetAttribute ("Remote", 
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2890
diff changeset
   142
    AddressValue (InetSocketAddress (i1i2.GetAddress (0), port)));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   143
  apps = onoff.Install (c.Get (3));
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   144
  apps.Start (Seconds (1.1));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   145
  apps.Stop (Seconds (10.0));
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   146
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   147
  // Create a packet sink to receive these packets
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   148
  apps = sink.Install (c.Get (1));
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   149
  apps.Start (Seconds (1.1));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   150
  apps.Stop (Seconds (10.0));
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   151
2820
14449d494cc1 use static method syntax to setup tracing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2818
diff changeset
   152
  std::ofstream ascii;
14449d494cc1 use static method syntax to setup tracing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2818
diff changeset
   153
  ascii.open ("simple-global-routing.tr");
2996
a83b94e277d4 EnablePcap()->EnablePcapAll(); EnableAscii()->EnableAsciiAll()
Tom Henderson <tomh@tomh.org>
parents: 2890
diff changeset
   154
  PointToPointHelper::EnablePcapAll ("simple-global-routing");
a83b94e277d4 EnablePcap()->EnablePcapAll(); EnableAscii()->EnableAsciiAll()
Tom Henderson <tomh@tomh.org>
parents: 2890
diff changeset
   155
  PointToPointHelper::EnableAsciiAll (ascii);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   156
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
   157
  NS_LOG_INFO ("Run Simulation.");
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   158
  Simulator::Run ();
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   159
  Simulator::Destroy ();
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
   160
  NS_LOG_INFO ("Done.");
1201
9bb4f158c60e main should return a value
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1199
diff changeset
   161
9bb4f158c60e main should return a value
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1199
diff changeset
   162
  return 0;
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   163
}