examples/routing/simple-global-routing.cc
author Mitch Watrous
Mon, 13 Aug 2012 16:08:13 -0700
changeset 8966 060dba23e9bb
parent 7256 b04ba6772f8c
child 9000 3ec20a64fd08
permissions -rw-r--r--
Replace src/application usage of RandomVariable with RandomVariableStream
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
 */
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
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
// Network topology
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
//
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
//  n0
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    22
//     \ 5 Mb/s, 2ms
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    23
//      \          1.5Mb/s, 10ms
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
//       n2 -------------------------n3
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
//      /
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    26
//     / 5 Mb/s, 2ms
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    27
//   n1
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
// - 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
    30
// - 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
    31
// - 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
    32
// - 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
    33
//   (i.e., DataRate of 448,000 bps)
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    34
// - DropTail queues 
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    35
// - 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
    36
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
#include <iostream>
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    38
#include <fstream>
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    39
#include <string>
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    40
#include <cassert>
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    41
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    42
#include "ns3/core-module.h"
6823
a27f86fb4e55 Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents: 6821
diff changeset
    43
#include "ns3/network-module.h"
6848
1f453ad50ef3 Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6847
diff changeset
    44
#include "ns3/internet-module.h"
1f453ad50ef3 Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6847
diff changeset
    45
#include "ns3/point-to-point-module.h"
6847
138f00c56381 Move applications to a single module
Mitch Watrous <watrous@u.washington.edu>
parents: 6845
diff changeset
    46
#include "ns3/applications-module.h"
6632
1f0ce8e8a810 flow-monitor-helper.h is no longer part of the helper module
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6047
diff changeset
    47
#include "ns3/flow-monitor-helper.h"
6649
f5413d463948 Missing ipv4-global-routing-helper.h include
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6632
diff changeset
    48
#include "ns3/ipv4-global-routing-helper.h"
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    49
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    50
using namespace ns3;
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    51
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    52
NS_LOG_COMPONENT_DEFINE ("SimpleGlobalRoutingExample");
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    53
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    54
int 
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    55
main (int argc, char *argv[])
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    56
{
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    57
  // 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
    58
  // 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
    59
#if 0 
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    60
  LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO);
2861
18930dcd33e0 test test
Craig Dowell <craigdo@ee.washington.edu>
parents: 2838
diff changeset
    61
#endif
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    62
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    63
  // 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
    64
  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
    65
  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
    67
  //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    68
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
  // 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
    70
  // 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
    71
  CommandLine cmd;
5206
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
    72
  bool enableFlowMonitor = false;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7196
diff changeset
    73
  cmd.AddValue ("EnableMonitor", "Enable Flow Monitor", enableFlowMonitor);
2575
1aae382e65e2 rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2533
diff changeset
    74
  cmd.Parse (argc, argv);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    76
  // 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
    77
  // topologies, we could configure a node factory.
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    78
  NS_LOG_INFO ("Create nodes.");
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    79
  NodeContainer c;
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    80
  c.Create (4);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7196
diff changeset
    81
  NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2));
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7196
diff changeset
    82
  NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2));
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7196
diff changeset
    83
  NodeContainer n3n2 = NodeContainer (c.Get (3), c.Get (2));
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    84
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    85
  InternetStackHelper internet;
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
    86
  internet.Install (c);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    87
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    88
  // 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
    89
  NS_LOG_INFO ("Create channels.");
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    90
  PointToPointHelper p2p;
3381
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    91
  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    92
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
    93
  NetDeviceContainer d0d2 = p2p.Install (n0n2);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    94
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
    95
  NetDeviceContainer d1d2 = p2p.Install (n1n2);
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
    96
3381
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    97
  p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    98
  p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
    99
  NetDeviceContainer d3d2 = p2p.Install (n3n2);
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
   100
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
   101
  // Later, we add IP addresses.
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
   102
  NS_LOG_INFO ("Assign IP Addresses.");
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   103
  Ipv4AddressHelper ipv4;
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   104
  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
   105
  Ipv4InterfaceContainer i0i2 = ipv4.Assign (d0d2);
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   106
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   107
  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
   108
  Ipv4InterfaceContainer i1i2 = ipv4.Assign (d1d2);
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
   109
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   110
  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
   111
  Ipv4InterfaceContainer i3i2 = ipv4.Assign (d3d2);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   112
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   113
  // 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
   114
  // tables in the nodes.
4616
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4225
diff changeset
   115
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
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 the OnOff application to send UDP datagrams of size
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   118
  // 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
   119
  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
   120
  uint16_t port = 9;   // Discard port (RFC 863)
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 2997
diff changeset
   121
  OnOffHelper onoff ("ns3::UdpSocketFactory", 
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
   122
                     Address (InetSocketAddress (i3i2.GetAddress (0), port)));
8966
060dba23e9bb Replace src/application usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7256
diff changeset
   123
  onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]"));
060dba23e9bb Replace src/application usage of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7256
diff changeset
   124
  onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   125
  ApplicationContainer apps = onoff.Install (c.Get (0));
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   126
  apps.Start (Seconds (1.0));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   127
  apps.Stop (Seconds (10.0));
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   128
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   129
  // Create a packet sink to receive these packets
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 2997
diff changeset
   130
  PacketSinkHelper sink ("ns3::UdpSocketFactory",
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
   131
                         Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   132
  apps = sink.Install (c.Get (3));
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   133
  apps.Start (Seconds (1.0));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   134
  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
   135
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   136
  // 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
   137
  onoff.SetAttribute ("Remote", 
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
   138
                      AddressValue (InetSocketAddress (i1i2.GetAddress (0), port)));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   139
  apps = onoff.Install (c.Get (3));
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   140
  apps.Start (Seconds (1.1));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   141
  apps.Stop (Seconds (10.0));
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   142
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   143
  // Create a packet sink to receive these packets
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   144
  apps = sink.Install (c.Get (1));
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   145
  apps.Start (Seconds (1.1));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   146
  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
   147
6014
d251d4a44fde checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   148
  AsciiTraceHelper ascii;
d251d4a44fde checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 6009
diff changeset
   149
  p2p.EnableAsciiAll (ascii.CreateFileStream ("simple-global-routing.tr"));
6009
e1b696a1ed28 redo pcap tracing
Craig Dowell <craigdo@ee.washington.edu>
parents: 5369
diff changeset
   150
  p2p.EnablePcapAll ("simple-global-routing");
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   151
5206
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   152
  // Flow Monitor
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   153
  Ptr<FlowMonitor> flowmon;
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   154
  if (enableFlowMonitor)
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   155
    {
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   156
      FlowMonitorHelper flowmonHelper;
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   157
      flowmon = flowmonHelper.InstallAll ();
7196
0f12b1572bca general examples coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6865
diff changeset
   158
    }
5206
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   159
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
   160
  NS_LOG_INFO ("Run Simulation.");
5212
d94f1040684c Fix the example stop time to make regression tests pass again
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 5206
diff changeset
   161
  Simulator::Stop (Seconds (11));
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   162
  Simulator::Run ();
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
   163
  NS_LOG_INFO ("Done.");
1201
9bb4f158c60e main should return a value
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1199
diff changeset
   164
5206
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   165
  if (enableFlowMonitor)
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   166
    {
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   167
      flowmon->SerializeToXmlFile ("simple-global-routing.flowmon", false, false);
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   168
    }
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   169
6dfb327dcabb Modify example to enable FlowMonitor via command-line option.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 4616
diff changeset
   170
  Simulator::Destroy ();
1201
9bb4f158c60e main should return a value
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1199
diff changeset
   171
  return 0;
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   172
}