|
|
| 7 |
|
7 |
|
| 8 |
using namespace ns3; |
8 |
using namespace ns3; |
| 9 |
|
9 |
|
| 10 |
static void |
|
|
| 11 |
CourseChange (ns3::TraceContext const&, Ptr<const MobilityModel> mobility) |
| 12 |
{ |
| 13 |
Vector pos = mobility->GetPosition (); |
| 14 |
Vector vel = mobility->GetVelocity (); |
| 15 |
std::cout << Simulator::Now () << ", model=" << mobility << ", POS: x=" << pos.x << ", y=" << pos.y |
| 16 |
<< ", z=" << pos.z << "; VEL:" << vel.x << ", y=" << vel.y |
| 17 |
<< ", z=" << vel.z << std::endl; |
| 18 |
} |
| 19 |
|
| 20 |
int main (int argc, char *argv[]) |
10 |
int main (int argc, char *argv[]) |
| 21 |
{ |
11 |
{ |
| 22 |
Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Mode", StringValue ("Time")); |
12 |
Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Mode", StringValue ("Time")); |
| 23 |
Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Time", StringValue ("2s")); |
13 |
Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Time", StringValue ("2s")); |
| 24 |
Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Speed", StringValue ("Constant:1.0")); |
14 |
Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Speed", StringValue ("Constant:1.0")); |
| 25 |
Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Bounds", StringValue ("0:200:0:100")); |
15 |
Config::SetDefault ("ns3::RandomWalk2dMobilityModel::Bounds", RectangleValue (Rectangle(0, 200, 0, 200))); |
| 26 |
|
16 |
|
| 27 |
CommandLine cmd; |
17 |
CommandLine cmd; |
| 28 |
cmd.Parse (argc, argv); |
18 |
cmd.Parse (argc, argv); |
|
|
| 40 |
"Mode", StringValue ("Time"), |
30 |
"Mode", StringValue ("Time"), |
| 41 |
"Time", StringValue ("2s"), |
31 |
"Time", StringValue ("2s"), |
| 42 |
"Speed", StringValue ("Constant:1.0"), |
32 |
"Speed", StringValue ("Constant:1.0"), |
| 43 |
"Bounds", StringValue ("0:200:0:100")); |
33 |
"Bounds", RectangleValue (Rectangle(0, 200, 0, 200))); |
| 44 |
mobility.InstallAll (); |
34 |
mobility.InstallAll (); |
| 45 |
Config::Connect ("/NodeList/*/$ns3::MobilityModelNotifier/CourseChange", |
|
|
| 46 |
MakeCallback (&CourseChange)); |
| 47 |
|
35 |
|
| 48 |
Simulator::StopAt (Seconds (100.0)); |
36 |
Simulator::StopAt (Seconds (100.0)); |
| 49 |
|
37 |
|