tutorial/tutorial-linear-dumbbell.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 13 Mar 2008 11:10:38 -0700
changeset 2600 6c389d0c717d
parent 2592 3ebf97150166
child 2812 5f2d7dcb31d2
permissions -rw-r--r--
add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
/*
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
 *
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
 * GNU General Public License for more details.
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
 *
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
 */
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    16
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
#include "ns3/log.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    18
#include "ns3/ptr.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    19
#include "ns3/internet-node.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
#include "ns3/point-to-point-channel.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
#include "ns3/csma-channel.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    22
#include "ns3/mac48-address.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    23
#include "ns3/point-to-point-net-device.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
#include "ns3/csma-net-device.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
#include "ns3/point-to-point-topology.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    26
#include "ns3/csma-topology.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    27
#include "ns3/csma-ipv4-topology.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
#include "ns3/udp-echo-client.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    29
#include "ns3/udp-echo-server.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    30
#include "ns3/simulator.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    31
#include "ns3/nstime.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    32
#include "ns3/ascii-trace.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    33
#include "ns3/pcap-trace.h"
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    34
#include "ns3/global-route-manager.h"
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
    35
#include "ns3/inet-socket-address.h"
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
    36
#include "ns3/uinteger.h"
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
1539
69d32521f6b8 tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 1529
diff changeset
    38
NS_LOG_COMPONENT_DEFINE ("DumbbellSimulation");
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    39
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    40
using namespace ns3;
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    41
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    42
// Network topology
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    43
//
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    44
//                       point to point
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    45
//                      +--------------+
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    46
//                      |              |
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    47
//       n0   n1   n2   n3             n4   n5   n6   n7
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    48
//       |    |    |    |              |    |    |    |
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    49
//       ================              ================
1539
69d32521f6b8 tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 1529
diff changeset
    50
//             lan1                          lan2
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    51
//
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    52
int 
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    53
main (int argc, char *argv[])
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    54
{
1539
69d32521f6b8 tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 1529
diff changeset
    55
  LogComponentEnable ("DumbbellSimulation", LOG_LEVEL_INFO);
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    56
1539
69d32521f6b8 tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 1529
diff changeset
    57
  NS_LOG_INFO ("Dumbbell Topology Simulation");
1843
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
    58
//
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
    59
// Create the lan on the left side of the dumbbell.
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
    60
//
2230
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1843
diff changeset
    61
  Ptr<Node> n0 = CreateObject<InternetNode> ();
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1843
diff changeset
    62
  Ptr<Node> n1 = CreateObject<InternetNode> ();
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1843
diff changeset
    63
  Ptr<Node> n2 = CreateObject<InternetNode> ();
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1843
diff changeset
    64
  Ptr<Node> n3 = CreateObject<InternetNode> ();
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    65
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
  Ptr<CsmaChannel> lan1 = 
1539
69d32521f6b8 tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 1529
diff changeset
    67
    CsmaTopology::CreateCsmaChannel (DataRate (10000000), MilliSeconds (2));
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    68
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
  uint32_t nd0 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n0, lan1, 
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    70
    "08:00:2e:00:00:00");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    71
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
  uint32_t nd1 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n1, lan1, 
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    73
    "08:00:2e:00:00:01");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    74
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
  uint32_t nd2 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n2, lan1, 
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    76
    "08:00:2e:00:00:02");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    77
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    78
  uint32_t nd3 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n3, lan1, 
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
    "08:00:2e:00:00:03");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    80
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    81
  CsmaIpv4Topology::AddIpv4Address (n0, nd0, "10.1.1.1", "255.255.255.0");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    82
  CsmaIpv4Topology::AddIpv4Address (n1, nd1, "10.1.1.2", "255.255.255.0");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    83
  CsmaIpv4Topology::AddIpv4Address (n2, nd2, "10.1.1.3", "255.255.255.0");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    84
  CsmaIpv4Topology::AddIpv4Address (n3, nd3, "10.1.1.4", "255.255.255.0");
1843
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
    85
//
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
    86
// Create the lan on the right side of the dumbbell.
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
    87
//
2230
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1843
diff changeset
    88
  Ptr<Node> n4 = CreateObject<InternetNode> ();
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1843
diff changeset
    89
  Ptr<Node> n5 = CreateObject<InternetNode> ();
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1843
diff changeset
    90
  Ptr<Node> n6 = CreateObject<InternetNode> ();
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1843
diff changeset
    91
  Ptr<Node> n7 = CreateObject<InternetNode> ();
1539
69d32521f6b8 tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 1529
diff changeset
    92
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    93
  Ptr<CsmaChannel> lan2 = 
1539
69d32521f6b8 tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 1529
diff changeset
    94
    CsmaTopology::CreateCsmaChannel (DataRate (10000000), MilliSeconds (2));
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    95
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    96
  uint32_t nd4 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n4, lan2, 
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    97
    "08:00:2e:00:00:04");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    98
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    99
  uint32_t nd5 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n5, lan2, 
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   100
    "08:00:2e:00:00:05");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   101
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   102
  uint32_t nd6 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n6, lan2, 
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   103
    "08:00:2e:00:00:06");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   104
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   105
  uint32_t nd7 = CsmaIpv4Topology::AddIpv4CsmaNetDevice (n7, lan2, 
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   106
    "08:00:2e:00:00:07");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   107
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   108
  CsmaIpv4Topology::AddIpv4Address (n4, nd4, "10.1.2.1", "255.255.255.0");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   109
  CsmaIpv4Topology::AddIpv4Address (n5, nd5, "10.1.2.2", "255.255.255.0");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   110
  CsmaIpv4Topology::AddIpv4Address (n6, nd6, "10.1.2.3", "255.255.255.0");
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   111
  CsmaIpv4Topology::AddIpv4Address (n7, nd7, "10.1.2.4", "255.255.255.0");
1843
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   112
//
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   113
// Create the point-to-point link to connect the two lans.
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   114
//
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   115
  Ptr<PointToPointChannel> link = PointToPointTopology::AddPointToPointLink (
1539
69d32521f6b8 tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents: 1529
diff changeset
   116
    n3, n4, DataRate (38400), MilliSeconds (20));
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   117
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   118
  PointToPointTopology::AddIpv4Addresses (link, n3, "10.1.3.1", 
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   119
    n4, "10.1.3.2");
1843
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   120
//
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   121
// Create data flows across the link:
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   122
//   n0 ==> n4 ==> n0
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   123
//   n1 ==> n5 ==> n1
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   124
//   n2 ==> n6 ==> n2
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   125
//   n3 ==> n7 ==> n3
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   126
//
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   127
  uint16_t port = 7;
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   128
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   129
  Ptr<UdpEchoClient> client0 = 
2600
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   130
    CreateObject<UdpEchoClient> ("RemoteIpv4", Ipv4Address ("10.1.2.1"),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   131
                                 "RemotePort", Uinteger (port),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   132
                                 "MaxPackets", Uinteger (100),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   133
                                 "Interval", Seconds (0.01),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   134
                                 "PacketSize", Uinteger (1024));
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   135
  n0->AddApplication (client0);
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   136
  Ptr<UdpEchoClient> client1 = 
2600
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   137
    CreateObject<UdpEchoClient> ("RemoteIpv4", Ipv4Address ("10.1.2.2"),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   138
                                 "RemotePort", Uinteger (port),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   139
                                 "MaxPackets", Uinteger (100),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   140
                                 "Interval", Seconds (0.01),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   141
                                 "PacketSize", Uinteger (1024));
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   142
  n1->AddApplication (client1);
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   143
  Ptr<UdpEchoClient> client2 = 
2600
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   144
    CreateObject<UdpEchoClient> ("RemoteIpv4", Ipv4Address ("10.1.2.3"),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   145
                                 "RemotePort", Uinteger (port),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   146
                                 "MaxPackets", Uinteger (100),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   147
                                 "Interval", Seconds (0.01),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   148
                                 "PacketSize", Uinteger (1024));
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   149
  n2->AddApplication (client2);
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   150
  Ptr<UdpEchoClient> client3 = 
2600
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   151
    CreateObject<UdpEchoClient> ("RemoteIpv4", Ipv4Address ("10.1.2.4"),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   152
                                 "RemotePort", Uinteger (port),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   153
                                 "MaxPackets", Uinteger (100),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   154
                                 "Interval", Seconds (0.01),
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   155
                                 "PacketSize", Uinteger (1024));
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   156
  n3->AddApplication (client3);
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   157
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   158
  Ptr<UdpEchoServer> server4 = 
2600
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   159
    CreateObject<UdpEchoServer> ("Port", Uinteger (port));
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   160
  n4->AddApplication (server4);
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   161
  Ptr<UdpEchoServer> server5 = 
2600
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   162
    CreateObject<UdpEchoServer> ("Port", Uinteger (port));
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   163
  n5->AddApplication (server5);
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   164
  Ptr<UdpEchoServer> server6 = 
2600
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   165
    CreateObject<UdpEchoServer> ("Port", Uinteger (port));
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   166
  n6->AddApplication (server6);
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   167
  Ptr<UdpEchoServer> server7 = 
2600
6c389d0c717d add Application::SetNode and NetDevice::SetNode, use them from Node::AddApplication and Node::AddDevice. kill useless "Node" attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
   168
    CreateObject<UdpEchoServer> ("Port", Uinteger (port));
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   169
  n7->AddApplication (server7);
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   170
1843
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   171
  server4->Start(Seconds(1.));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   172
  server5->Start(Seconds(1.));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   173
  server6->Start(Seconds(1.));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   174
  server7->Start(Seconds(1.));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   175
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   176
  client0->Start(Seconds(2.));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   177
  client1->Start(Seconds(2.1));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   178
  client2->Start(Seconds(2.2));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   179
  client3->Start(Seconds(2.3));
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   180
1843
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   181
  server4->Stop (Seconds(10.));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   182
  server5->Stop (Seconds(10.));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   183
  server6->Stop (Seconds(10.));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   184
  server7->Stop (Seconds(10.));
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   185
1843
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   186
  client0->Stop (Seconds(10.));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   187
  client1->Stop (Seconds(10.));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   188
  client2->Stop (Seconds(10.));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   189
  client3->Stop (Seconds(10.));
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   190
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   191
  AsciiTrace asciitrace ("tutorial.tr");
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   192
  asciitrace.TraceAllQueues ();
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   193
  asciitrace.TraceAllNetDeviceRx ();
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   194
1843
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1839
diff changeset
   195
  PcapTrace pcaptrace ("tutorial.pcap");
1529
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   196
  pcaptrace.TraceAllIp ();
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   197
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   198
  GlobalRouteManager::PopulateRoutingTables ();
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   199
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   200
  Simulator::Run ();
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   201
  Simulator::Destroy ();
042ae54d795c tutorial files
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   202
}