A Discrete-Event Network Simulator
QKDNetSim v2.0 (NS-3 v3.41) @ (+)
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
v
w
Enumerator
a
b
c
d
e
f
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
Related Functions
:
a
b
c
d
e
g
h
i
j
l
m
n
o
p
q
r
s
t
u
w
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
Enumerator
c
e
i
l
o
r
s
t
v
Macros
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
bridge-channel.cc
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License version 2 as
4
* published by the Free Software Foundation;
5
*
6
* This program is distributed in the hope that it will be useful,
7
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
* GNU General Public License for more details.
10
*
11
* You should have received a copy of the GNU General Public License
12
* along with this program; if not, write to the Free Software
13
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14
*
15
* Author: Gustavo Carneiro <gjc@inescporto.pt>
16
*/
17
18
#include "
bridge-channel.h
"
19
20
#include "ns3/log.h"
21
28
namespace
ns3
29
{
30
31
NS_LOG_COMPONENT_DEFINE
(
"BridgeChannel"
);
32
33
NS_OBJECT_ENSURE_REGISTERED
(BridgeChannel);
34
35
TypeId
36
BridgeChannel::GetTypeId
()
37
{
38
static
TypeId
tid =
TypeId
(
"ns3::BridgeChannel"
)
39
.
SetParent
<
Channel
>()
40
.SetGroupName(
"Bridge"
)
41
.AddConstructor<
BridgeChannel
>();
42
return
tid;
43
}
44
45
BridgeChannel::BridgeChannel
()
46
:
Channel
()
47
{
48
NS_LOG_FUNCTION_NOARGS
();
49
}
50
51
BridgeChannel::~BridgeChannel
()
52
{
53
NS_LOG_FUNCTION_NOARGS
();
54
55
for
(
auto
iter =
m_bridgedChannels
.begin(); iter !=
m_bridgedChannels
.end(); iter++)
56
{
57
*iter =
nullptr
;
58
}
59
m_bridgedChannels
.clear();
60
}
61
62
void
63
BridgeChannel::AddChannel
(
Ptr<Channel>
bridgedChannel)
64
{
65
m_bridgedChannels
.push_back(bridgedChannel);
66
}
67
68
std::size_t
69
BridgeChannel::GetNDevices
()
const
70
{
71
uint32_t ndevices = 0;
72
for
(
auto
iter =
m_bridgedChannels
.begin(); iter !=
m_bridgedChannels
.end(); iter++)
73
{
74
ndevices += (*iter)->GetNDevices();
75
}
76
return
ndevices;
77
}
78
79
Ptr<NetDevice>
80
BridgeChannel::GetDevice
(std::size_t i)
const
81
{
82
std::size_t ndevices = 0;
83
for
(
auto
iter =
m_bridgedChannels
.begin(); iter !=
m_bridgedChannels
.end(); iter++)
84
{
85
if
((i - ndevices) < (*iter)->GetNDevices())
86
{
87
return
(*iter)->GetDevice(i - ndevices);
88
}
89
ndevices += (*iter)->GetNDevices();
90
}
91
return
nullptr
;
92
}
93
94
}
// namespace ns3
bridge-channel.h
ns3::BridgeChannel declaration.
ns3::BridgeChannel
Virtual channel implementation for bridges (BridgeNetDevice).
Definition:
bridge-channel.h:44
ns3::BridgeChannel::BridgeChannel
BridgeChannel()
Definition:
bridge-channel.cc:45
ns3::BridgeChannel::~BridgeChannel
~BridgeChannel() override
Definition:
bridge-channel.cc:51
ns3::BridgeChannel::AddChannel
void AddChannel(Ptr< Channel > bridgedChannel)
Adds a channel to the bridged pool.
Definition:
bridge-channel.cc:63
ns3::BridgeChannel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
bridge-channel.cc:36
ns3::BridgeChannel::m_bridgedChannels
std::vector< Ptr< Channel > > m_bridgedChannels
pool of bridged channels
Definition:
bridge-channel.h:69
ns3::BridgeChannel::GetNDevices
std::size_t GetNDevices() const override
Definition:
bridge-channel.cc:69
ns3::BridgeChannel::GetDevice
Ptr< NetDevice > GetDevice(std::size_t i) const override
Definition:
bridge-channel.cc:80
ns3::Channel
Abstract Channel Base Class.
Definition:
channel.h:45
ns3::Ptr< Channel >
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:931
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log-macros-enabled.h:206
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:46
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
bridge
model
bridge-channel.cc
Generated on Sun Mar 3 2024 17:10:54 for ns-3 by
1.9.1