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
(
"Gateway"
,
Ipv4AddressValue
(gateway));
31
SetAttribute
(
"Mode"
,
EnumValue
(
TapBridge::CONFIGURE_LOCAL
));
32
}
33
34
void
35
TapBridgeHelper::SetAttribute
(std::string n1,
const
AttributeValue
& v1)
36
{
37
NS_LOG_FUNCTION
(n1 << &v1);
38
m_deviceFactory
.
Set
(n1, v1);
39
}
40
41
Ptr<NetDevice>
42
TapBridgeHelper::Install
(
Ptr<Node>
node,
Ptr<NetDevice>
nd,
const
AttributeValue
& v1)
43
{
44
NS_LOG_FUNCTION
(node << nd << &v1);
45
m_deviceFactory
.
Set
(
"DeviceName"
, v1);
46
return
Install
(node, nd);
47
}
48
49
Ptr<NetDevice>
50
TapBridgeHelper::Install
(
Ptr<Node>
node,
Ptr<NetDevice>
nd)
51
{
52
NS_LOG_FUNCTION
(node << nd);
53
NS_LOG_LOGIC
(
"Install TapBridge on node "
<< node->GetId() <<
" bridging net device "
<< nd);
54
55
Ptr<TapBridge>
bridge =
m_deviceFactory
.
Create
<
TapBridge
>();
56
node->AddDevice(bridge);
57
bridge->SetBridgedNetDevice(nd);
58
59
return
bridge;
60
}
61
62
Ptr<NetDevice>
63
TapBridgeHelper::Install
(std::string nodeName,
Ptr<NetDevice>
nd)
64
{
65
Ptr<Node>
node =
Names::Find<Node>
(nodeName);
66
return
Install
(node, nd);
67
}
68
69
Ptr<NetDevice>
70
TapBridgeHelper::Install
(
Ptr<Node>
node, std::string ndName)
71
{
72
Ptr<NetDevice>
nd =
Names::Find<NetDevice>
(ndName);
73
return
Install
(node, nd);
74
}
75
76
Ptr<NetDevice>
77
TapBridgeHelper::Install
(std::string nodeName, std::string ndName)
78
{
79
Ptr<Node>
node =
Names::Find<Node>
(nodeName);
80
Ptr<NetDevice>
nd =
Names::Find<NetDevice>
(ndName);
81
return
Install
(node, nd);
82
}
83
84
}
// 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::Ipv4AddressValue
Definition
ipv4-address.h:330
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:50
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:35
ns3::TapBridgeHelper::m_deviceFactory
ObjectFactory m_deviceFactory
Object factory.
Definition
tap-bridge-helper.h:120
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 Fri Nov 8 2024 13:59:06 for ns-3 by
1.11.0