5 |
5 |
6 using namespace ns3; |
6 using namespace ns3; |
7 |
7 |
8 class MyModel { |
8 class MyModel { |
9 public: |
9 public: |
10 void start (void); |
10 void Start (void); |
11 private: |
11 private: |
12 void dealWithEvent (double eventValue); |
12 void DealWithEvent (double eventValue); |
13 }; |
13 }; |
14 |
14 |
15 void |
15 void |
16 MyModel::start (void) |
16 MyModel::Start (void) |
17 { |
17 { |
18 Simulator::schedule (Time::relS (10.0), |
18 Simulator::Schedule (Time::RelS (10.0), |
19 &MyModel::dealWithEvent, |
19 &MyModel::DealWithEvent, |
20 this, Simulator::now ().s ()); |
20 this, Simulator::Now ().S ()); |
21 } |
21 } |
22 void |
22 void |
23 MyModel::dealWithEvent (double value) |
23 MyModel::DealWithEvent (double value) |
24 { |
24 { |
25 std::cout << "Member method received event at " << Simulator::now ().s () << |
25 std::cout << "Member method received event at " << Simulator::Now ().S () << |
26 "s started at " << value << "s" << std::endl; |
26 "s started at " << value << "s" << std::endl; |
27 } |
27 } |
28 |
28 |
29 static void |
29 static void |
30 random_function (MyModel *model) |
30 random_function (MyModel *model) |
31 { |
31 { |
32 std::cout << "random function received event at " << |
32 std::cout << "random function received event at " << |
33 Simulator::now ().s () << "s" << std::endl; |
33 Simulator::Now ().S () << "s" << std::endl; |
34 model->start (); |
34 model->Start (); |
35 } |
35 } |
36 |
36 |
37 |
37 |
38 int main (int argc, char *argv[]) |
38 int main (int argc, char *argv[]) |
39 { |
39 { |
40 MyModel model; |
40 MyModel model; |
41 |
41 |
42 Simulator::schedule (Time::absS (10.0), &random_function, &model); |
42 Simulator::Schedule (Time::AbsS (10.0), &random_function, &model); |
43 |
43 |
44 Simulator::run (); |
44 Simulator::Run (); |
45 |
45 |
46 Simulator::destroy (); |
46 Simulator::Destroy (); |
47 } |
47 } |