samples/main-random-walk.cc
author Florian Westphal <fw@strlen.de>
Wed, 03 Sep 2008 23:24:59 +0200
changeset 3595 693faf7f4e9b
parent 3174 efeb6e5c276d
child 6821 203367ae7433
permissions -rw-r--r--
nsc: Fix build problem if gtk config store is disabled gtk config store pulled in libdl.so for us, so things fail to link of the config store isn't enabled. This makes nsc pull in libdl itself when its enabled.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1554
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
2726
8ed5f77da0da use auto-generated per-module headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2700
diff changeset
     3
#include "ns3/core-module.h"
8ed5f77da0da use auto-generated per-module headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2700
diff changeset
     4
#include "ns3/helper-module.h"
8ed5f77da0da use auto-generated per-module headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2700
diff changeset
     5
#include "ns3/mobility-module.h"
2753
1f03a5531746 fallout from gustavo's header inclusion policy change.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2726
diff changeset
     6
#include "ns3/simulator-module.h"
1555
d3e9007db75b improve sample code, make it build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1554
diff changeset
     7
d3e9007db75b improve sample code, make it build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1554
diff changeset
     8
using namespace ns3;
d3e9007db75b improve sample code, make it build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1554
diff changeset
     9
d3e9007db75b improve sample code, make it build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1554
diff changeset
    10
static void 
3021
5b1479210da3 Removed TraceContext and TraceResolver references, removed MobilityModelNotifier class, and minor changes on samples/main-random-walk.cc.
tjkopena@cs.drexel.edu
parents: 2998
diff changeset
    11
CourseChange (std::string foo, Ptr<const MobilityModel> mobility)
1555
d3e9007db75b improve sample code, make it build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1554
diff changeset
    12
{
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
    13
  Vector pos = mobility->GetPosition ();
1818
fbdc8361dc77 GetSpeed -> GetVelocity
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1817
diff changeset
    14
  Vector vel = mobility->GetVelocity ();
1650
bcfb726651bb On course-change, print velocity in addition to position.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1649
diff changeset
    15
  std::cout << Simulator::Now () << ", model=" << mobility << ", POS: x=" << pos.x << ", y=" << pos.y
1817
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
    16
            << ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y
8b0520433350 replace Position and Speed by Vector
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1816
diff changeset
    17
            << ", z=" << vel.z << std::endl;
1555
d3e9007db75b improve sample code, make it build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1554
diff changeset
    18
}
1554
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
int main (int argc, char *argv[])
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
{
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2753
diff changeset
    22
  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Mode", StringValue ("Time"));
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2753
diff changeset
    23
  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Time", StringValue ("2s"));
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2753
diff changeset
    24
  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Speed", StringValue ("Constant:1.0"));
3021
5b1479210da3 Removed TraceContext and TraceResolver references, removed MobilityModelNotifier class, and minor changes on samples/main-random-walk.cc.
tjkopena@cs.drexel.edu
parents: 2998
diff changeset
    25
  Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Bounds", StringValue ("0|200|0|200"));
1554
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
2575
1aae382e65e2 rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2540
diff changeset
    27
  CommandLine cmd;
1aae382e65e2 rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2540
diff changeset
    28
  cmd.Parse (argc, argv);
1555
d3e9007db75b improve sample code, make it build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1554
diff changeset
    29
2700
c54fbae72e8f change signature of MobilityHelper::Layout and MobilityHelper::LayoutAll.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2614
diff changeset
    30
  NodeContainer c;
c54fbae72e8f change signature of MobilityHelper::Layout and MobilityHelper::LayoutAll.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2614
diff changeset
    31
  c.Create (100);
1612
0981e5bb0cec get rid of old buggy random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1583
diff changeset
    32
2399
fd9d94d518d2 convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2230
diff changeset
    33
  MobilityHelper mobility;
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2594
diff changeset
    34
  mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2753
diff changeset
    35
                                 "X", StringValue ("100.0"),
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2753
diff changeset
    36
                                 "Y", StringValue ("100.0"),
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2753
diff changeset
    37
                                 "Rho", StringValue ("Uniform:0:30"));
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2594
diff changeset
    38
  mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2753
diff changeset
    39
                             "Mode", StringValue ("Time"),
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2753
diff changeset
    40
                             "Time", StringValue ("2s"),
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2753
diff changeset
    41
                             "Speed", StringValue ("Constant:1.0"),
3021
5b1479210da3 Removed TraceContext and TraceResolver references, removed MobilityModelNotifier class, and minor changes on samples/main-random-walk.cc.
tjkopena@cs.drexel.edu
parents: 2998
diff changeset
    42
                             "Bounds", StringValue ("0|200|0|200"));
2998
b991704f870f Fix two nits that escaped checkin
Tom Henderson <tomh@tomh.org>
parents: 2997
diff changeset
    43
  mobility.InstallAll ();
3021
5b1479210da3 Removed TraceContext and TraceResolver references, removed MobilityModelNotifier class, and minor changes on samples/main-random-walk.cc.
tjkopena@cs.drexel.edu
parents: 2998
diff changeset
    44
  Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
2965
4b28e9740e3b get rid of Attribute class. Use AttributeValue subclasses directly.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2753
diff changeset
    45
                   MakeCallback (&CourseChange));
1612
0981e5bb0cec get rid of old buggy random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1583
diff changeset
    46
3174
efeb6e5c276d Make Application::Start/Stop times relative, Simulator::StopAt(time) renamed to Simulator::Stop(time) and time also made relative, to improve consistency of the API which uses relative times everywhere else. Closes bug #191.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 3021
diff changeset
    47
  Simulator::Stop (Seconds (100.0));
1555
d3e9007db75b improve sample code, make it build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1554
diff changeset
    48
d3e9007db75b improve sample code, make it build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1554
diff changeset
    49
  Simulator::Run ();
1554
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
  
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
  return 0;
76e781c120bb rework the notification mechanism to allow its optional use with every position model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
}