-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleBroadcastProtocolHelper.cc
54 lines (46 loc) · 1.36 KB
/
SimpleBroadcastProtocolHelper.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* SimpleBroadcastProtocolHelper.cc
*
* Created on: 07.05.2020
* Author: krassus
*/
#include "SimpleBroadcastProtocol.h"
#include "SimpleBroadcastProtocolHelper.h"
namespace ns3
{
NS_LOG_COMPONENT_DEFINE("SimpleBroadcastProtocolHelper");
SimpleBroadcastProtocolHelper::SimpleBroadcastProtocolHelper()
{
}
SimpleBroadcastProtocolHelper::~SimpleBroadcastProtocolHelper()
{
}
void SimpleBroadcastProtocolHelper::Install(Ptr<WifiNetDevice> device) const
{
ObjectFactory factory;
factory.SetTypeId("ns3::SimpleBroadcastProtocol");
Ptr<Object> protocol = factory.Create<Object>();
device->AggregateObject(protocol);
Ptr<SimpleBroadcastProtocol> sbp = device->GetObject<SimpleBroadcastProtocol>();
if (sbp != 0)
sbp->Install(device);
else
NS_FATAL_ERROR("Failed to install SimpleBroadcastProtocol on node " << device->GetNode()->GetId());
}
void SimpleBroadcastProtocolHelper::Install(NetDeviceContainer c) const
{
for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); i++)
{
Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice>(*i);
if (device != 0)
this->Install(device);
else
NS_LOG_ERROR("Failed to cast NetDevice to WifiNetDevice");
}
}
void SimpleBroadcastProtocolHelper::Install(std::string nodeName) const
{
Ptr<WifiNetDevice> node = Names::Find<WifiNetDevice>(nodeName);
this->Install(node);
}
}