A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
bridge-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c)
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*/
17
18
#include "
bridge-helper.h
"
19
20
#include "ns3/bridge-net-device.h"
21
#include "ns3/log.h"
22
#include "ns3/names.h"
23
#include "ns3/node.h"
24
31
namespace
ns3
32
{
33
34
NS_LOG_COMPONENT_DEFINE
(
"BridgeHelper"
);
35
36
BridgeHelper::BridgeHelper
()
37
{
38
NS_LOG_FUNCTION_NOARGS
();
39
m_deviceFactory
.
SetTypeId
(
"ns3::BridgeNetDevice"
);
40
}
41
42
void
43
BridgeHelper::SetDeviceAttribute
(std::string n1,
const
AttributeValue
& v1)
44
{
45
NS_LOG_FUNCTION_NOARGS
();
46
m_deviceFactory
.
Set
(n1, v1);
47
}
48
49
NetDeviceContainer
50
BridgeHelper::Install
(
Ptr<Node>
node,
NetDeviceContainer
c)
51
{
52
NS_LOG_FUNCTION_NOARGS
();
53
NS_LOG_LOGIC
(
"**** Install bridge device on node "
<< node->
GetId
());
54
55
NetDeviceContainer
devs;
56
Ptr<BridgeNetDevice>
dev =
m_deviceFactory
.
Create
<
BridgeNetDevice
>();
57
devs.
Add
(dev);
58
node->
AddDevice
(dev);
59
60
for
(
auto
i = c.
Begin
(); i != c.
End
(); ++i)
61
{
62
NS_LOG_LOGIC
(
"**** Add BridgePort "
<< *i);
63
dev->AddBridgePort(*i);
64
}
65
return
devs;
66
}
67
68
NetDeviceContainer
69
BridgeHelper::Install
(std::string nodeName,
NetDeviceContainer
c)
70
{
71
NS_LOG_FUNCTION_NOARGS
();
72
Ptr<Node>
node = Names::Find<Node>(nodeName);
73
return
Install
(node, c);
74
}
75
76
}
// namespace ns3
bridge-helper.h
ns3::BridgeHelper declaration.
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:70
ns3::BridgeHelper::SetDeviceAttribute
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
Set an attribute on each ns3::BridgeNetDevice created by BridgeHelper::Install.
Definition:
bridge-helper.cc:43
ns3::BridgeHelper::m_deviceFactory
ObjectFactory m_deviceFactory
Object factory.
Definition:
bridge-helper.h:83
ns3::BridgeHelper::Install
NetDeviceContainer Install(Ptr< Node > node, NetDeviceContainer c)
This method creates an ns3::BridgeNetDevice with the attributes configured by BridgeHelper::SetDevice...
Definition:
bridge-helper.cc:50
ns3::BridgeHelper::BridgeHelper
BridgeHelper()
Definition:
bridge-helper.cc:36
ns3::BridgeNetDevice
a virtual net device that bridges multiple LAN segments
Definition:
bridge-net-device.h:74
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition:
net-device-container.h:43
ns3::NetDeviceContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
Definition:
net-device-container.cc:49
ns3::NetDeviceContainer::Add
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Definition:
net-device-container.cc:73
ns3::NetDeviceContainer::End
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
Definition:
net-device-container.cc:55
ns3::Node::AddDevice
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition:
node.cc:138
ns3::Node::GetId
uint32_t GetId() const
Definition:
node.cc:117
ns3::ObjectFactory::Create
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
Definition:
object-factory.cc:93
ns3::ObjectFactory::Set
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Definition:
object-factory.h:220
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition:
object-factory.cc:42
ns3::Ptr< Node >
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition:
log.h:282
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log-macros-enabled.h:206
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
bridge
helper
bridge-helper.cc
Generated on Sun Mar 3 2024 17:10:54 for ns-3 by
1.9.1