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
tap-bridge-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 University of Washington
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*/
6
7
#include "
tap-bridge-helper.h
"
8
9
#include "ns3/enum.h"
10
#include "ns3/log.h"
11
#include "ns3/names.h"
12
#include "ns3/node.h"
13
#include "ns3/tap-bridge.h"
14
15
namespace
ns3
16
{
17
18
NS_LOG_COMPONENT_DEFINE
(
"TapBridgeHelper"
);
19
20
TapBridgeHelper::TapBridgeHelper
()
21
{
22
NS_LOG_FUNCTION_NOARGS
();
23
m_deviceFactory
.
SetTypeId
(
"ns3::TapBridge"
);
24
}
25
26
TapBridgeHelper::TapBridgeHelper
(
Ipv4Address
gateway)
27
{
28
NS_LOG_FUNCTION_NOARGS
();
29
m_deviceFactory
.
SetTypeId
(
"ns3::TapBridge"
);
30
SetAttribute
(
"Mode"
,
EnumValue
(
TapBridge::CONFIGURE_LOCAL
));
31
}
32
33
void
34
TapBridgeHelper::SetAttribute
(std::string n1,
const
AttributeValue
& v1)
35
{
36
NS_LOG_FUNCTION
(n1 << &v1);
37
m_deviceFactory
.
Set
(n1, v1);
38
}
39
40
Ptr<NetDevice>
41
TapBridgeHelper::Install
(
Ptr<Node>
node,
Ptr<NetDevice>
nd,
const
AttributeValue
& v1)
42
{
43
NS_LOG_FUNCTION
(node << nd << &v1);
44
m_deviceFactory
.
Set
(
"DeviceName"
, v1);
45
return
Install
(node, nd);
46
}
47
48
Ptr<NetDevice>
49
TapBridgeHelper::Install
(
Ptr<Node>
node,
Ptr<NetDevice>
nd)
50
{
51
NS_LOG_FUNCTION
(node << nd);
52
NS_LOG_LOGIC
(
"Install TapBridge on node "
<< node->GetId() <<
" bridging net device "
<< nd);
53
54
Ptr<TapBridge>
bridge =
m_deviceFactory
.
Create
<
TapBridge
>();
55
node->AddDevice(bridge);
56
bridge->SetBridgedNetDevice(nd);
57
58
return
bridge;
59
}
60
61
Ptr<NetDevice>
62
TapBridgeHelper::Install
(std::string nodeName,
Ptr<NetDevice>
nd)
63
{
64
Ptr<Node>
node =
Names::Find<Node>
(nodeName);
65
return
Install
(node, nd);
66
}
67
68
Ptr<NetDevice>
69
TapBridgeHelper::Install
(
Ptr<Node>
node, std::string ndName)
70
{
71
Ptr<NetDevice>
nd =
Names::Find<NetDevice>
(ndName);
72
return
Install
(node, nd);
73
}
74
75
Ptr<NetDevice>
76
TapBridgeHelper::Install
(std::string nodeName, std::string ndName)
77
{
78
Ptr<Node>
node =
Names::Find<Node>
(nodeName);
79
Ptr<NetDevice>
nd =
Names::Find<NetDevice>
(ndName);
80
return
Install
(node, nd);
81
}
82
83
}
// namespace ns3
ns3::AttributeValue
Hold a value for an Attribute.
Definition
attribute.h:59
ns3::EnumValue
Hold variables of type enum.
Definition
enum.h:52
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
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::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
ns3::TapBridgeHelper::Install
Ptr< NetDevice > Install(Ptr< Node > node, Ptr< NetDevice > nd)
This method installs a TapBridge on the specified Node and forms the bridge with the NetDevice specif...
Definition
tap-bridge-helper.cc:49
ns3::TapBridgeHelper::TapBridgeHelper
TapBridgeHelper()
Construct a TapBridgeHelper to make life easier for people wanting to have their simulations interact...
Definition
tap-bridge-helper.cc:20
ns3::TapBridgeHelper::SetAttribute
void SetAttribute(std::string n1, const AttributeValue &v1)
Set an attribute in the underlying TapBridge net device when these devices are automatically created.
Definition
tap-bridge-helper.cc:34
ns3::TapBridgeHelper::m_deviceFactory
ObjectFactory m_deviceFactory
Object factory.
Definition
tap-bridge-helper.h:121
ns3::TapBridge
A bridge to make it appear that a real host process is connected to an ns-3 net device.
Definition
tap-bridge.h:98
ns3::TapBridge::CONFIGURE_LOCAL
@ CONFIGURE_LOCAL
ns-3 creates and configures tap device
Definition
tap-bridge.h:113
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
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
tap-bridge-helper.h
src
tap-bridge
helper
tap-bridge-helper.cc
Generated on Thu Feb 13 2025 18:20:51 for ns-3 by
1.11.0