A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
bridge-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c)
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*/
6
7
#include "
bridge-helper.h
"
8
9
#include "ns3/bridge-net-device.h"
10
#include "ns3/log.h"
11
#include "ns3/names.h"
12
#include "ns3/node.h"
13
14
/**
15
* \file
16
* \ingroup bridge
17
* ns3::BridgeHelper implementation.
18
*/
19
20
namespace
ns3
21
{
22
23
NS_LOG_COMPONENT_DEFINE
(
"BridgeHelper"
);
24
25
BridgeHelper::BridgeHelper
()
26
{
27
NS_LOG_FUNCTION_NOARGS
();
28
m_deviceFactory
.
SetTypeId
(
"ns3::BridgeNetDevice"
);
29
}
30
31
void
32
BridgeHelper::SetDeviceAttribute
(std::string n1,
const
AttributeValue
& v1)
33
{
34
NS_LOG_FUNCTION_NOARGS
();
35
m_deviceFactory
.
Set
(n1, v1);
36
}
37
38
NetDeviceContainer
39
BridgeHelper::Install
(
Ptr<Node>
node,
NetDeviceContainer
c)
40
{
41
NS_LOG_FUNCTION_NOARGS
();
42
NS_LOG_LOGIC
(
"**** Install bridge device on node "
<< node->GetId());
43
44
NetDeviceContainer
devs;
45
Ptr<BridgeNetDevice>
dev =
m_deviceFactory
.
Create
<
BridgeNetDevice
>();
46
devs.
Add
(dev);
47
node->AddDevice(dev);
48
49
for
(
auto
i = c.
Begin
(); i != c.
End
(); ++i)
50
{
51
NS_LOG_LOGIC
(
"**** Add BridgePort "
<< *i);
52
dev->AddBridgePort(*i);
53
}
54
return
devs;
55
}
56
57
NetDeviceContainer
58
BridgeHelper::Install
(std::string nodeName,
NetDeviceContainer
c)
59
{
60
NS_LOG_FUNCTION_NOARGS
();
61
Ptr<Node>
node =
Names::Find<Node>
(nodeName);
62
return
Install
(node, c);
63
}
64
65
}
// namespace ns3
bridge-helper.h
ns3::BridgeHelper declaration.
ns3::AttributeValue
Hold a value for an Attribute.
Definition
attribute.h:59
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:32
ns3::BridgeHelper::m_deviceFactory
ObjectFactory m_deviceFactory
Object factory.
Definition
bridge-helper.h:72
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:39
ns3::BridgeHelper::BridgeHelper
BridgeHelper()
Definition
bridge-helper.cc:25
ns3::BridgeNetDevice
a virtual net device that bridges multiple LAN segments
Definition
bridge-net-device.h:63
ns3::Names::Find
static Ptr< T > Find(std::string path)
Given a name path string, look to see if there's an object in the system with that associated to it.
Definition
names.h:443
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition
net-device-container.h:32
ns3::NetDeviceContainer::Begin
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
Definition
net-device-container.cc:38
ns3::NetDeviceContainer::Add
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Definition
net-device-container.cc:62
ns3::NetDeviceContainer::End
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
Definition
net-device-container.cc:44
ns3::ObjectFactory::Create
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
Definition
object-factory.cc:82
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:213
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Definition
object-factory.cc:31
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_LOGIC
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition
log.h:271
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition
log-macros-enabled.h:195
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
bridge
helper
bridge-helper.cc
Generated on Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0