20 #include "ns3/mesh-interface-helper.h" |
20 #include "ns3/mesh-interface-helper.h" |
21 #include "dot11s-installer.h" |
21 #include "dot11s-installer.h" |
22 #include "peer-management-protocol.h" |
22 #include "peer-management-protocol.h" |
23 #include "hwmp-protocol.h" |
23 #include "hwmp-protocol.h" |
24 |
24 |
25 namespace ns3 { |
25 namespace ns3 |
|
26 { |
26 using namespace dot11s; |
27 using namespace dot11s; |
27 NS_OBJECT_ENSURE_REGISTERED (Dot11sStack); |
28 NS_OBJECT_ENSURE_REGISTERED (Dot11sStack); |
28 TypeId |
29 TypeId |
29 Dot11sStack::GetTypeId () |
30 Dot11sStack::GetTypeId () |
30 { |
31 { |
31 static TypeId tid = TypeId ("ns3::Dot11sStack") |
32 static TypeId tid = TypeId ("ns3::Dot11sStack") |
32 .SetParent<Object> () |
33 .SetParent<Object> () |
33 .AddConstructor<Dot11sStack> () |
34 .AddConstructor<Dot11sStack> (); |
34 ; |
|
35 return tid; |
35 return tid; |
36 } |
36 } |
37 Dot11sStack::Dot11sStack () |
37 Dot11sStack::Dot11sStack () |
38 {} |
38 { |
|
39 } |
39 Dot11sStack::~Dot11sStack () |
40 Dot11sStack::~Dot11sStack () |
40 {} |
41 { |
|
42 } |
41 void |
43 void |
42 Dot11sStack::DoDispose () |
44 Dot11sStack::DoDispose () |
43 { |
45 { |
44 } |
46 } |
45 void |
47 void |
46 Dot11sStack::SetRoot (Ptr<MeshPointDevice> mp) |
48 Dot11sStack::SetRoot (Ptr<MeshPointDevice> mp) |
47 { |
49 { |
48 Ptr <HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> (); |
50 Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> (); |
49 NS_ASSERT(hwmp != 0); |
51 NS_ASSERT (hwmp != 0); |
50 hwmp->SetRoot (); |
52 hwmp->SetRoot (); |
51 } |
53 } |
52 bool |
54 bool |
53 Dot11sStack::InstallStack (Ptr<MeshPointDevice> mp) |
55 Dot11sStack::InstallStack (Ptr<MeshPointDevice> mp) |
54 { |
56 { |
55 //Install Peer management protocol: |
57 //Install Peer management protocol: |
56 Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> (); |
58 Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> (); |
57 pmp->SetMeshId("mesh"); |
59 pmp->SetMeshId ("mesh"); |
58 bool install_ok = pmp->Install (mp); |
60 bool install_ok = pmp->Install (mp); |
59 if (!install_ok) |
61 if (!install_ok) |
60 { |
62 { |
61 return false; |
63 return false; |
62 } |
64 } |
66 if (!install_ok) |
68 if (!install_ok) |
67 { |
69 { |
68 return false; |
70 return false; |
69 } |
71 } |
70 //Install interaction between HWMP and Peer management protocol: |
72 //Install interaction between HWMP and Peer management protocol: |
71 pmp->SetPeerLinkStatusCallback (MakeCallback(&HwmpProtocol::PeerLinkStatus, hwmp)); |
73 pmp->SetPeerLinkStatusCallback (MakeCallback (&HwmpProtocol::PeerLinkStatus, hwmp)); |
72 hwmp->SetNeighboursCallback (MakeCallback(&PeerManagementProtocol::GetActiveLinks, pmp)); |
74 hwmp->SetNeighboursCallback (MakeCallback (&PeerManagementProtocol::GetActiveLinks, pmp)); |
73 return true; |
75 return true; |
74 } |
76 } |
75 void |
77 void |
76 Dot11sStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os) |
78 Dot11sStack::Report (const Ptr<MeshPointDevice> mp, std::ostream& os) |
77 { |
79 { |
78 mp->Report (os); |
80 mp->Report (os); |
79 |
81 |
80 std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces (); |
82 std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces (); |
81 for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i) |
83 for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i) |
82 { |
84 { |
83 Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> (); |
85 Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> (); |
84 NS_ASSERT (device != 0); |
86 NS_ASSERT (device != 0); |
85 MeshInterfaceHelper::Report (device, os); |
87 MeshInterfaceHelper::Report (device, os); |
86 } |
88 } |
87 Ptr <HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> (); |
89 Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> (); |
88 NS_ASSERT (hwmp != 0); |
90 NS_ASSERT (hwmp != 0); |
89 hwmp->Report (os); |
91 hwmp->Report (os); |
90 |
92 |
91 Ptr <PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> (); |
93 Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> (); |
92 NS_ASSERT (pmp != 0); |
94 NS_ASSERT (pmp != 0); |
93 pmp->Report (os); |
95 pmp->Report (os); |
94 } |
96 } |
95 void |
97 void |
96 Dot11sStack::ResetStats (const Ptr<MeshPointDevice> mp) |
98 Dot11sStack::ResetStats (const Ptr<MeshPointDevice> mp) |
97 { |
99 { |
98 mp->ResetStats (); |
100 mp->ResetStats (); |
99 |
101 |
100 std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces (); |
102 std::vector<Ptr<NetDevice> > ifaces = mp->GetInterfaces (); |
101 for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i) |
103 for (std::vector<Ptr<NetDevice> >::const_iterator i = ifaces.begin (); i != ifaces.end (); ++i) |
102 { |
104 { |
103 Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> (); |
105 Ptr<WifiNetDevice> device = (*i)->GetObject<WifiNetDevice> (); |
104 NS_ASSERT (device != 0); |
106 NS_ASSERT (device != 0); |
105 MeshInterfaceHelper::ResetStats (device); |
107 MeshInterfaceHelper::ResetStats (device); |
106 } |
108 } |
107 Ptr <HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> (); |
109 Ptr<HwmpProtocol> hwmp = mp->GetObject<HwmpProtocol> (); |
108 NS_ASSERT(hwmp != 0); |
110 NS_ASSERT (hwmp != 0); |
109 hwmp->ResetStats (); |
111 hwmp->ResetStats (); |
110 |
112 |
111 Ptr <PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> (); |
113 Ptr<PeerManagementProtocol> pmp = mp->GetObject<PeerManagementProtocol> (); |
112 NS_ASSERT(pmp != 0); |
114 NS_ASSERT (pmp != 0); |
113 pmp->ResetStats (); |
115 pmp->ResetStats (); |
114 } |
116 } |
115 } //namespace ns3 |
117 } //namespace ns3 |