examples/simple-global-routing.cc
author Raj Bhattacharjea <raj.b@gatech.edu>
Wed, 01 Apr 2009 19:09:12 -0400
changeset 4306 5396ecd09060
parent 4225 f1d873a81159
child 4616 a84f60b6cd12
permissions -rw-r--r--
Update AUTHORS for ns-3.4
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
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    64
  // 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
    65
  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
    66
  Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("448kb/s"));
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    67
1224
7cbc1d661b89 rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1209
diff changeset
    68
  //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);   
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    70
  // 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
    71
  // 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
    72
  CommandLine cmd;
1aae382e65e2 rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2533
diff changeset
    73
  cmd.Parse (argc, argv);
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
  // 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
    76
  // topologies, we could configure a node factory.
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
    77
  NS_LOG_INFO ("Create nodes.");
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    78
  NodeContainer c;
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    79
  c.Create (4);
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    80
  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
    81
  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
    82
  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
    83
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    84
  InternetStackHelper internet;
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
    85
  internet.Install (c);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    86
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    87
  // 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
    88
  NS_LOG_INFO ("Create channels.");
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
    89
  PointToPointHelper p2p;
3381
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    90
  p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    91
  p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
    92
  NetDeviceContainer d0d2 = p2p.Install (n0n2);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    93
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
    94
  NetDeviceContainer d1d2 = p2p.Install (n1n2);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    95
  
3381
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    96
  p2p.SetDeviceAttribute ("DataRate", StringValue ("1500kbps"));
3cdd9d60f7c7 bug 232, references to Parameter obsolete
Craig Dowell <craigdo@ee.washington.edu>
parents: 3181
diff changeset
    97
  p2p.SetChannelAttribute ("Delay", StringValue ("10ms"));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
    98
  NetDeviceContainer d3d2 = p2p.Install (n3n2);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    99
  
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   100
  // Later, we add IP addresses.  
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
   101
  NS_LOG_INFO ("Assign IP Addresses.");
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   102
  Ipv4AddressHelper ipv4;
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   103
  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
   104
  Ipv4InterfaceContainer i0i2 = ipv4.Assign (d0d2);
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   105
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   106
  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
   107
  Ipv4InterfaceContainer i1i2 = ipv4.Assign (d1d2);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   108
  
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   109
  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
   110
  Ipv4InterfaceContainer i3i2 = ipv4.Assign (d3d2);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   111
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   112
  // 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
   113
  // tables in the nodes.
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   114
  GlobalRouteManager::PopulateRoutingTables ();
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   115
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   116
  // 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
   117
  // 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
   118
  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
   119
  uint16_t port = 9;   // Discard port (RFC 863)
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 2997
diff changeset
   120
  OnOffHelper onoff ("ns3::UdpSocketFactory", 
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
   121
    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
   122
  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
   123
  onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   124
  ApplicationContainer apps = onoff.Install (c.Get (0));
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   125
  apps.Start (Seconds (1.0));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   126
  apps.Stop (Seconds (10.0));
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   127
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   128
  // Create a packet sink to receive these packets
3125
d2d8a36cfd23 s/ns3::Udp/ns3::UdpSocketFactory
Tom Henderson <tomh@tomh.org>
parents: 2997
diff changeset
   129
  PacketSinkHelper sink ("ns3::UdpSocketFactory",
2890
172baa5960ff rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents: 2889
diff changeset
   130
    Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   131
  apps = sink.Install (c.Get (3));
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   132
  apps.Start (Seconds (1.0));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   133
  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
   134
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   135
  // 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
   136
  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
   137
    AddressValue (InetSocketAddress (i1i2.GetAddress (0), port)));
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   138
  apps = onoff.Install (c.Get (3));
2761
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   139
  apps.Start (Seconds (1.1));
9a9e6a4187f8 port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2613
diff changeset
   140
  apps.Stop (Seconds (10.0));
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   141
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   142
  // Create a packet sink to receive these packets
2887
9a637e6daee0 Build -> Install
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2861
diff changeset
   143
  apps = sink.Install (c.Get (1));
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));
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   146
2820
14449d494cc1 use static method syntax to setup tracing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2818
diff changeset
   147
  std::ofstream ascii;
14449d494cc1 use static method syntax to setup tracing
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2818
diff changeset
   148
  ascii.open ("simple-global-routing.tr");
2996
a83b94e277d4 EnablePcap()->EnablePcapAll(); EnableAscii()->EnableAsciiAll()
Tom Henderson <tomh@tomh.org>
parents: 2890
diff changeset
   149
  PointToPointHelper::EnablePcapAll ("simple-global-routing");
a83b94e277d4 EnablePcap()->EnablePcapAll(); EnableAscii()->EnableAsciiAll()
Tom Henderson <tomh@tomh.org>
parents: 2890
diff changeset
   150
  PointToPointHelper::EnableAsciiAll (ascii);
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   151
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
   152
  NS_LOG_INFO ("Run Simulation.");
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   153
  Simulator::Run ();
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   154
  Simulator::Destroy ();
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1456
diff changeset
   155
  NS_LOG_INFO ("Done.");
1201
9bb4f158c60e main should return a value
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1199
diff changeset
   156
9bb4f158c60e main should return a value
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1199
diff changeset
   157
  return 0;
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   158
}