examples/simple-global-routing.cc
author Tom Henderson <tomh@tomh.org>
Tue, 11 Sep 2007 22:40:04 -0700
changeset 1456 7372ff049e61
parent 1320 60b14f0bcff1
child 1504 36ecc970ba96
permissions -rw-r--r--
Remove m_quiet variable, fix copyright
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
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    45
#include "ns3/debug.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    46
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    47
#include "ns3/command-line.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    48
#include "ns3/default-value.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    49
#include "ns3/ptr.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    50
#include "ns3/random-variable.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    51
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    52
#include "ns3/simulator.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    53
#include "ns3/nstime.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    54
#include "ns3/data-rate.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    55
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    56
#include "ns3/ascii-trace.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    57
#include "ns3/pcap-trace.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    58
#include "ns3/internet-node.h"
1121
541bfe1308b2 fix compilation problems and test
Tom Henderson <tomh@tomh.org>
parents: 1117
diff changeset
    59
#include "ns3/point-to-point-channel.h"
541bfe1308b2 fix compilation problems and test
Tom Henderson <tomh@tomh.org>
parents: 1117
diff changeset
    60
#include "ns3/point-to-point-net-device.h"
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    61
#include "ns3/ipv4-address.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    62
#include "ns3/ipv4.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    63
#include "ns3/socket.h"
1199
d9caeae5943c use the InetSocketAddress API for ip sockets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1121
diff changeset
    64
#include "ns3/inet-socket-address.h"
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    65
#include "ns3/ipv4-route.h"
1121
541bfe1308b2 fix compilation problems and test
Tom Henderson <tomh@tomh.org>
parents: 1117
diff changeset
    66
#include "ns3/point-to-point-topology.h"
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    67
#include "ns3/onoff-application.h"
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
    68
#include "ns3/packet-sink.h"
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
#include "ns3/global-route-manager.h"
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    70
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    71
using namespace ns3;
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    73
int main (int argc, char *argv[])
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
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    76
  // 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
    77
  // 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
    78
#if 0 
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
  DebugComponentEnable ("Object");
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    80
  DebugComponentEnable ("Queue");
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    81
  DebugComponentEnable ("DropTailQueue");
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    82
  DebugComponentEnable ("Channel");
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    83
  DebugComponentEnable ("PointToPointChannel");
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    84
  DebugComponentEnable ("PointToPointNetDevice");
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    85
  DebugComponentEnable ("GlobalRouter");
1199
d9caeae5943c use the InetSocketAddress API for ip sockets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1121
diff changeset
    86
  DebugComponentEnable ("GlobalRouteMaager");
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    87
#endif
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    88
1224
7cbc1d661b89 rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1209
diff changeset
    89
  // Set up some default values for the simulation.  Use the DefaultValue::Bind ()
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    90
  // technique to tell the system what subclass of Queue to use,
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    91
  // and what the queue limit is
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    92
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    93
  // The below Bind command tells the queue factory which class to
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    94
  // instantiate, when the queue factory is invoked in the topology code
1224
7cbc1d661b89 rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1209
diff changeset
    95
  DefaultValue::Bind ("Queue", "DropTailQueue");
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    96
1224
7cbc1d661b89 rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1209
diff changeset
    97
  DefaultValue::Bind ("OnOffApplicationPacketSize", "210");
7cbc1d661b89 rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1209
diff changeset
    98
  DefaultValue::Bind ("OnOffApplicationDataRate", "448kb/s");
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    99
1224
7cbc1d661b89 rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1209
diff changeset
   100
  //DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30);   
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   101
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   102
  // 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
   103
  // DefaultValue::Bind ()s at run-time, via command-line arguments
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   104
  CommandLine::Parse (argc, argv);
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   105
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   106
  // 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
   107
  // topologies, we could configure a node factory.
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   108
  Ptr<Node> n0 = Create<InternetNode> ();
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   109
  Ptr<Node> n1 = Create<InternetNode> (); 
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   110
  Ptr<Node> n2 = Create<InternetNode> (); 
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   111
  Ptr<Node> n3 = Create<InternetNode> ();
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
  // We create the channels first without any IP addressing information
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   114
  Ptr<PointToPointChannel> channel0 = 
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   115
    PointToPointTopology::AddPointToPointLink (
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   116
      n0, n2, DataRate (5000000), MilliSeconds (2));
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   117
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   118
  Ptr<PointToPointChannel> channel1 = 
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   119
    PointToPointTopology::AddPointToPointLink (
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   120
      n1, n2, DataRate (5000000), MilliSeconds (2));
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   121
  
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   122
  Ptr<PointToPointChannel> channel2 = 
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   123
    PointToPointTopology::AddPointToPointLink (
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   124
      n2, n3, DataRate (1500000), MilliSeconds (10));
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   125
  
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   126
  // Later, we add IP addresses.  
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   127
  PointToPointTopology::AddIpv4Addresses (
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   128
      channel0, n0, Ipv4Address ("10.1.1.1"),
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   129
      n2, Ipv4Address ("10.1.1.2"));
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   130
  
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   131
  PointToPointTopology::AddIpv4Addresses (
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   132
      channel1, n1, Ipv4Address ("10.1.2.1"),
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   133
      n2, Ipv4Address ("10.1.2.2"));
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   134
  
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   135
  PointToPointTopology::AddIpv4Addresses (
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   136
      channel2, n2, Ipv4Address ("10.1.3.1"),
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   137
      n3, Ipv4Address ("10.1.3.2"));
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   138
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   139
  // 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
   140
  // tables in the nodes.
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   141
  GlobalRouteManager::PopulateRoutingTables ();
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   142
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   143
  // 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
   144
  // 210 bytes at a rate of 448 Kb/s
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   145
  Ptr<OnOffApplication> ooff = Create<OnOffApplication> (
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   146
    n0, 
1209
7629e5cd8f5e make the previous merge actually work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1201
diff changeset
   147
    InetSocketAddress ("10.1.3.2", 80), 
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   148
    "Udp",
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   149
    ConstantVariable (1), 
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   150
    ConstantVariable (0));
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   151
  // Start the application
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   152
  ooff->Start (Seconds (1.0));
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   153
  ooff->Stop (Seconds (10.0));
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   154
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   155
  // Create a packet sink to receive these packets
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   156
  // The last argument "true" disables output from the Receive callback
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   157
  Ptr<PacketSink> sink = Create<PacketSink> (
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   158
    n3, 
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   159
    InetSocketAddress (Ipv4Address::GetAny (), 80), 
1456
7372ff049e61 Remove m_quiet variable, fix copyright
Tom Henderson <tomh@tomh.org>
parents: 1320
diff changeset
   160
    "Udp");
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   161
  // Start the sink
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   162
  sink->Start (Seconds (1.0));
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   163
  sink->Stop (Seconds (10.0));
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   164
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   165
  // Create a similar flow from n3 to n1, starting at time 1.1 seconds
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   166
  ooff = Create<OnOffApplication> (
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   167
    n3, 
1209
7629e5cd8f5e make the previous merge actually work
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1201
diff changeset
   168
    InetSocketAddress ("10.1.2.1", 80),
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   169
    "Udp",
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   170
    ConstantVariable (1), 
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   171
    ConstantVariable (0));
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   172
  // Start the application
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   173
  ooff->Start (Seconds (1.1));
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   174
  ooff->Stop (Seconds (10.0));
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   175
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   176
  // Create a packet sink to receive these packets
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   177
  sink = Create<PacketSink> (
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   178
    n1, 
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   179
    InetSocketAddress (Ipv4Address::GetAny (), 80), 
1456
7372ff049e61 Remove m_quiet variable, fix copyright
Tom Henderson <tomh@tomh.org>
parents: 1320
diff changeset
   180
    "Udp");
1320
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   181
  // Start the sink
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   182
  sink->Start (Seconds (1.1));
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   183
  sink->Stop (Seconds (10.0));
60b14f0bcff1 adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents: 1224
diff changeset
   184
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   185
  // Configure tracing of all enqueue, dequeue, and NetDevice receive events
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   186
  // Trace output will be sent to the simple-global-routing.tr file
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   187
  AsciiTrace asciitrace ("simple-global-routing.tr");
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   188
  asciitrace.TraceAllQueues ();
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   189
  asciitrace.TraceAllNetDeviceRx ();
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   190
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   191
  // Also configure some tcpdump traces; each interface will be traced
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   192
  // The output files will be named simple-p2p.pcap-<nodeId>-<interfaceId>
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   193
  // and can be read by the "tcpdump -r" command (use "-tt" option to
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   194
  // display timestamps correctly)
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   195
  PcapTrace pcaptrace ("simple-global-routing.pcap");
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   196
  pcaptrace.TraceAllIp ();
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   197
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   198
  Simulator::Run ();
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   199
    
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   200
  Simulator::Destroy ();
1201
9bb4f158c60e main should return a value
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1199
diff changeset
   201
9bb4f158c60e main should return a value
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1199
diff changeset
   202
  return 0;
1116
e806ecadcc9c add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   203
}