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-channel.cc
Go to the documentation of this file.
1
/*
2
* SPDX-License-Identifier: GPL-2.0-only
3
*
4
* Author: Gustavo Carneiro <gjc@inescporto.pt>
5
*/
6
7
#include "
bridge-channel.h
"
8
9
#include "ns3/log.h"
10
11
/**
12
* \file
13
* \ingroup bridge
14
* ns3::BridgeChannel implementation.
15
*/
16
17
namespace
ns3
18
{
19
20
NS_LOG_COMPONENT_DEFINE
(
"BridgeChannel"
);
21
22
NS_OBJECT_ENSURE_REGISTERED
(BridgeChannel);
23
24
TypeId
25
BridgeChannel::GetTypeId
()
26
{
27
static
TypeId
tid =
TypeId
(
"ns3::BridgeChannel"
)
28
.
SetParent
<
Channel
>()
29
.SetGroupName(
"Bridge"
)
30
.AddConstructor<
BridgeChannel
>();
31
return
tid;
32
}
33
34
BridgeChannel::BridgeChannel
()
35
:
Channel
()
36
{
37
NS_LOG_FUNCTION_NOARGS
();
38
}
39
40
BridgeChannel::~BridgeChannel
()
41
{
42
NS_LOG_FUNCTION_NOARGS
();
43
44
for
(
auto
iter =
m_bridgedChannels
.begin(); iter !=
m_bridgedChannels
.end(); iter++)
45
{
46
*iter =
nullptr
;
47
}
48
m_bridgedChannels
.clear();
49
}
50
51
void
52
BridgeChannel::AddChannel
(
Ptr<Channel>
bridgedChannel)
53
{
54
m_bridgedChannels
.push_back(bridgedChannel);
55
}
56
57
std::size_t
58
BridgeChannel::GetNDevices
()
const
59
{
60
uint32_t
ndevices = 0;
61
for
(
auto
iter =
m_bridgedChannels
.begin(); iter !=
m_bridgedChannels
.end(); iter++)
62
{
63
ndevices += (*iter)->GetNDevices();
64
}
65
return
ndevices;
66
}
67
68
Ptr<NetDevice>
69
BridgeChannel::GetDevice
(std::size_t i)
const
70
{
71
std::size_t ndevices = 0;
72
for
(
auto
iter =
m_bridgedChannels
.begin(); iter !=
m_bridgedChannels
.end(); iter++)
73
{
74
if
((i - ndevices) < (*iter)->GetNDevices())
75
{
76
return
(*iter)->GetDevice(i - ndevices);
77
}
78
ndevices += (*iter)->GetNDevices();
79
}
80
return
nullptr
;
81
}
82
83
}
// namespace ns3
bridge-channel.h
ns3::BridgeChannel declaration.
ns3::BridgeChannel
Virtual channel implementation for bridges (BridgeNetDevice).
Definition
bridge-channel.h:33
ns3::BridgeChannel::BridgeChannel
BridgeChannel()
Definition
bridge-channel.cc:34
ns3::BridgeChannel::~BridgeChannel
~BridgeChannel() override
Definition
bridge-channel.cc:40
ns3::BridgeChannel::AddChannel
void AddChannel(Ptr< Channel > bridgedChannel)
Adds a channel to the bridged pool.
Definition
bridge-channel.cc:52
ns3::BridgeChannel::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
bridge-channel.cc:25
ns3::BridgeChannel::m_bridgedChannels
std::vector< Ptr< Channel > > m_bridgedChannels
pool of bridged channels
Definition
bridge-channel.h:58
ns3::BridgeChannel::GetNDevices
std::size_t GetNDevices() const override
Definition
bridge-channel.cc:58
ns3::BridgeChannel::GetDevice
Ptr< NetDevice > GetDevice(std::size_t i) const override
Definition
bridge-channel.cc:69
ns3::Channel
Abstract Channel Base Class.
Definition
channel.h:34
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
uint32_t
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition
log-macros-enabled.h:195
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
bridge
model
bridge-channel.cc
Generated on Fri Nov 1 2024 09:20:36 for ns-3 by
1.11.0