author | Tom Henderson <tomh@tomh.org> |
Sun, 13 Apr 2008 15:46:17 -0700 | |
changeset 2995 | b72805b3ca69 |
parent 2753 | 1f03a5531746 |
child 2997 | caf9d364c6fc |
permissions | -rw-r--r-- |
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 |
1650
bcfb726651bb
On course-change, print velocity in addition to position.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1649
diff
changeset
|
11 |
CourseChange (ns3::TraceContext const&, 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 |
{ |
2614
5efb372326be
more ns3:: prefix fixes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
22 |
Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Mode", String ("Time")); |
5efb372326be
more ns3:: prefix fixes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
23 |
Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Time", String ("2s")); |
5efb372326be
more ns3:: prefix fixes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
24 |
Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Speed", String ("Constant:1.0")); |
5efb372326be
more ns3:: prefix fixes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
25 |
Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Bounds", String ("0:200:0:100")); |
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; |
fd9d94d518d2
convert Mobility subsystem to Value framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
34 |
mobility.EnableNotifier (); |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2594
diff
changeset
|
35 |
mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator", |
2502
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
36 |
"X", String ("100.0"), |
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
37 |
"Y", String ("100.0"), |
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
38 |
"Rho", String ("Uniform:0:30")); |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2594
diff
changeset
|
39 |
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", |
2502
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
40 |
"Mode", String ("Time"), |
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
41 |
"Time", String ("2s"), |
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
42 |
"Speed", String ("Constant:1.0"), |
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2402
diff
changeset
|
43 |
"Bounds", String ("0:200:0:100")); |
2995
b72805b3ca69
Align helper API use of Install()
Tom Henderson <tomh@tomh.org>
parents:
2753
diff
changeset
|
44 |
mobility.InstallAll (); |
2614
5efb372326be
more ns3:: prefix fixes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2602
diff
changeset
|
45 |
Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange", |
2540
4e9ba43f7b9e
use Config-based trace system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
46 |
MakeCallback (&CourseChange)); |
1612
0981e5bb0cec
get rid of old buggy random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1583
diff
changeset
|
47 |
|
0981e5bb0cec
get rid of old buggy random walk model
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1583
diff
changeset
|
48 |
Simulator::StopAt (Seconds (100.0)); |
1555
d3e9007db75b
improve sample code, make it build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1554
diff
changeset
|
49 |
|
d3e9007db75b
improve sample code, make it build
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1554
diff
changeset
|
50 |
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
|
51 |
|
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 |
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
|
53 |
} |