tutorial/tutorial-star.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 11 Mar 2008 13:30:12 -0700
changeset 2592 3ebf97150166
parent 2494 1c69ea12779c
child 2600 6c389d0c717d
permissions -rw-r--r--
get rid of CreateObjectWith
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1841
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
/*
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
 *
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
 * GNU General Public License for more details.
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
 *
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
 */
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    16
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
#include "ns3/log.h"
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    18
#include "ns3/ptr.h"
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    19
#include "ns3/internet-node.h"
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
#include "ns3/point-to-point-channel.h"
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
#include "ns3/mac48-address.h"
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    22
#include "ns3/point-to-point-net-device.h"
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    23
#include "ns3/udp-echo-client.h"
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
#include "ns3/udp-echo-server.h"
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
#include "ns3/simulator.h"
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    26
#include "ns3/nstime.h"
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    27
#include "ns3/ascii-trace.h"
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
#include "ns3/pcap-trace.h"
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    29
#include "ns3/global-route-manager.h"
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
    30
#include "ns3/inet-socket-address.h"
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
    31
#include "ns3/uinteger.h"
1841
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    32
1848
5dfaf1619279 move in topo
Craig Dowell <craigdo@ee.washington.edu>
parents: 1843
diff changeset
    33
#include "point-to-point-ipv4-topology.h"
5dfaf1619279 move in topo
Craig Dowell <craigdo@ee.washington.edu>
parents: 1843
diff changeset
    34
1843
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1842
diff changeset
    35
NS_LOG_COMPONENT_DEFINE ("StarSimulation");
1841
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    36
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
using namespace ns3;
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    38
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    39
// Network topology
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    40
//
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    41
//                  n3    n2
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    42
//                   |   /
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    43
//                    | /
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    44
//              n4 --- n0 --- n1
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    45
//                    /  |
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    46
//                   /    |
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    47
//                  n5    n6
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    48
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    49
int 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    50
main (int argc, char *argv[])
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    51
{
1843
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1842
diff changeset
    52
  LogComponentEnable ("StarSimulation", LOG_LEVEL_INFO);
1841
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    53
1843
1267bcc23b04 tutorial topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1842
diff changeset
    54
  NS_LOG_INFO ("Star Topology Simulation");
1841
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    55
2230
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1848
diff changeset
    56
  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: 1848
diff changeset
    57
  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: 1848
diff changeset
    58
  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: 1848
diff changeset
    59
  Ptr<Node> n3 = CreateObject<InternetNode> ();
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1848
diff changeset
    60
  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: 1848
diff changeset
    61
  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: 1848
diff changeset
    62
  Ptr<Node> n6 = CreateObject<InternetNode> ();
1841
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    63
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    64
  Ptr<PointToPointChannel> link01 = 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    65
    PointToPointIpv4Topology::CreateChannel (DataRate (38400), 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
    MilliSeconds (20));
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    67
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    68
  uint32_t nd01 = PointToPointIpv4Topology::AddNetDevice (n0,
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
    link01);
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    70
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    71
  Ptr<PointToPointChannel> link02 = 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
    PointToPointIpv4Topology::CreateChannel (DataRate (38400), 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    73
    MilliSeconds (20));
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    74
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
  uint32_t nd02 = PointToPointIpv4Topology::AddNetDevice (n0,
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    76
    link02);
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    77
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    78
  Ptr<PointToPointChannel> link03 = 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
    PointToPointIpv4Topology::CreateChannel (DataRate (38400), 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    80
    MilliSeconds (20));
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    81
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    82
  uint32_t nd03 = PointToPointIpv4Topology::AddNetDevice (n0,
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    83
    link03);
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    84
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    85
  Ptr<PointToPointChannel> link04 = 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    86
    PointToPointIpv4Topology::CreateChannel (DataRate (38400), 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    87
    MilliSeconds (20));
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    88
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    89
  uint32_t nd04 = PointToPointIpv4Topology::AddNetDevice (n0, 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    90
    link04);
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    91
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    92
  Ptr<PointToPointChannel> link05 = 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    93
    PointToPointIpv4Topology::CreateChannel (DataRate (38400), 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    94
    MilliSeconds (20));
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    95
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    96
  uint32_t nd05 = PointToPointIpv4Topology::AddNetDevice (n0,
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    97
    link05);
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    98
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    99
  Ptr<PointToPointChannel> link06 = 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   100
    PointToPointIpv4Topology::CreateChannel (DataRate (38400), 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   101
    MilliSeconds (20));
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   102
1842
a6b327e4b547 topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1841
diff changeset
   103
  uint32_t nd06 = PointToPointIpv4Topology::AddNetDevice (n0, link06);
1841
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   104
1842
a6b327e4b547 topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1841
diff changeset
   105
  uint32_t nd1 = PointToPointIpv4Topology::AddNetDevice (n1, link01);
a6b327e4b547 topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1841
diff changeset
   106
  uint32_t nd2 = PointToPointIpv4Topology::AddNetDevice (n2, link02);
a6b327e4b547 topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1841
diff changeset
   107
  uint32_t nd3 = PointToPointIpv4Topology::AddNetDevice (n3, link03);
a6b327e4b547 topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1841
diff changeset
   108
  uint32_t nd4 = PointToPointIpv4Topology::AddNetDevice (n4, link04);
a6b327e4b547 topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1841
diff changeset
   109
  uint32_t nd5 = PointToPointIpv4Topology::AddNetDevice (n5, link05);
a6b327e4b547 topologies
Craig Dowell <craigdo@ee.washington.edu>
parents: 1841
diff changeset
   110
  uint32_t nd6 = PointToPointIpv4Topology::AddNetDevice (n6, link06);
1841
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   111
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   112
  PointToPointIpv4Topology::AddAddress (n0, nd01, "10.1.1.1", 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   113
    "255.255.255.252");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   114
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   115
  PointToPointIpv4Topology::AddAddress (n1, nd1, "10.1.1.2", 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   116
    "255.255.255.252");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   117
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   118
  PointToPointIpv4Topology::AddAddress (n0, nd02, "10.1.2.1", 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   119
    "255.255.255.252");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   120
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   121
  PointToPointIpv4Topology::AddAddress (n2, nd2, "10.1.2.2", 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   122
    "255.255.255.252");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   123
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   124
  PointToPointIpv4Topology::AddAddress (n0, nd03, "10.1.3.1", 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   125
    "255.255.255.252");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   126
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   127
  PointToPointIpv4Topology::AddAddress (n3, nd3, "10.1.2.2", 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   128
    "255.255.255.252");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   129
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   130
  PointToPointIpv4Topology::AddAddress (n0, nd04, "10.1.4.1", 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   131
    "255.255.255.252");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   132
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   133
  PointToPointIpv4Topology::AddAddress (n4, nd4, "10.1.4.2", 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   134
    "255.255.255.252");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   135
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   136
  PointToPointIpv4Topology::AddAddress (n0, nd05, "10.1.5.1", 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   137
    "255.255.255.252");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   138
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   139
  PointToPointIpv4Topology::AddAddress (n5, nd5, "10.1.5.2", 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   140
    "255.255.255.252");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   141
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   142
  PointToPointIpv4Topology::AddAddress (n0, nd06, "10.1.6.1", 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   143
    "255.255.255.252");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   144
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   145
  PointToPointIpv4Topology::AddAddress (n6, nd6, "10.1.6.2", 
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   146
    "255.255.255.252");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   147
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   148
  uint16_t port = 7;
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   149
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   150
  Ptr<UdpEchoClient> client = 
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   151
    CreateObject<UdpEchoClient> ("Node", n0, 
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   152
                                     "RemoteIpv4", Ipv4Address ("10.1.1.2"),
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   153
                                     "RemotePort", Uinteger (port), 
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   154
                                     "MaxPackets", Uinteger (1), 
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   155
                                     "Interval", Seconds(1.), 
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   156
                                     "PacketSize", Uinteger (1024));
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   157
  n0->AddApplication (client);
1841
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   158
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   159
  Ptr<UdpEchoServer> server = 
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2494
diff changeset
   160
    CreateObject<UdpEchoServer> ("Node", n1, 
2494
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   161
                                     "Port", Uinteger (port));
1c69ea12779c port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2311
diff changeset
   162
  n1->AddApplication (server);
1841
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   163
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   164
  server->Start(Seconds(1.));
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   165
  client->Start(Seconds(2.));
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   166
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   167
  server->Stop (Seconds(10.));
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   168
  client->Stop (Seconds(10.));
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   169
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   170
  AsciiTrace asciitrace ("tutorial.tr");
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   171
  asciitrace.TraceAllQueues ();
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   172
  asciitrace.TraceAllNetDeviceRx ();
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   173
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   174
  Simulator::Run ();
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   175
  Simulator::Destroy ();
afa9089bcab4 support for star network, example in tutorial
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   176
}