A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
bridge-channel.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License version 2 as
5
* published by the Free Software Foundation;
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
*
16
* Author: Gustavo Carneiro <gjc@inescporto.pt>
17
*/
18
19
#include "ns3/log.h"
20
#include "
bridge-channel.h
"
21
28
namespace
ns3
{
29
30
NS_LOG_COMPONENT_DEFINE
(
"BridgeChannel"
);
31
32
NS_OBJECT_ENSURE_REGISTERED
(BridgeChannel);
33
34
TypeId
35
BridgeChannel::GetTypeId
(
void
)
36
{
37
static
TypeId
tid =
TypeId
(
"ns3::BridgeChannel"
)
38
.
SetParent
<
Channel
> ()
39
.SetGroupName(
"Bridge"
)
40
.AddConstructor<
BridgeChannel
> ()
41
;
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
(std::vector<
Ptr<Channel>
>::iterator iter =
m_bridgedChannels
.begin ();
56
iter !=
m_bridgedChannels
.end (); iter++)
57
{
58
*iter = 0;
59
}
60
m_bridgedChannels
.clear ();
61
}
62
63
64
void
65
BridgeChannel::AddChannel
(
Ptr<Channel>
bridgedChannel)
66
{
67
m_bridgedChannels
.push_back (bridgedChannel);
68
}
69
70
std::size_t
71
BridgeChannel::GetNDevices
(
void
)
const
72
{
73
uint32_t ndevices = 0;
74
for
(std::vector<
Ptr<Channel>
>::const_iterator iter =
m_bridgedChannels
.begin ();
75
iter !=
m_bridgedChannels
.end (); iter++)
76
{
77
ndevices += (*iter)->GetNDevices ();
78
}
79
return
ndevices;
80
}
81
82
83
Ptr<NetDevice>
84
BridgeChannel::GetDevice
(std::size_t i)
const
85
{
86
std::size_t ndevices = 0;
87
for
(std::vector<
Ptr<Channel>
>::const_iterator iter =
m_bridgedChannels
.begin ();
88
iter !=
m_bridgedChannels
.end (); iter++)
89
{
90
if
((i - ndevices) < (*iter)->GetNDevices ())
91
{
92
return
(*iter)->GetDevice (i - ndevices);
93
}
94
ndevices += (*iter)->GetNDevices ();
95
}
96
return
NULL;
97
}
98
99
100
}
// namespace ns3
bridge-channel.h
ns3::BridgeChannel declaration.
ns3::BridgeChannel
Virtual channel implementation for bridges (BridgeNetDevice).
Definition:
bridge-channel.h:43
ns3::BridgeChannel::~BridgeChannel
virtual ~BridgeChannel()
Definition:
bridge-channel.cc:51
ns3::BridgeChannel::BridgeChannel
BridgeChannel()
Definition:
bridge-channel.cc:45
ns3::BridgeChannel::GetNDevices
virtual std::size_t GetNDevices(void) const
Definition:
bridge-channel.cc:71
ns3::BridgeChannel::m_bridgedChannels
std::vector< Ptr< Channel > > m_bridgedChannels
pool of bridged channels
Definition:
bridge-channel.h:68
ns3::BridgeChannel::AddChannel
void AddChannel(Ptr< Channel > bridgedChannel)
Adds a channel to the bridged pool.
Definition:
bridge-channel.cc:65
ns3::BridgeChannel::GetDevice
virtual Ptr< NetDevice > GetDevice(std::size_t i) const
Definition:
bridge-channel.cc:84
ns3::BridgeChannel::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition:
bridge-channel.cc:35
ns3::Channel
Abstract Channel Base Class.
Definition:
channel.h:44
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:922
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition:
log-macros-enabled.h:209
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition:
object-base.h:45
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
bridge
model
bridge-channel.cc
Generated on Tue Feb 6 2024 19:21:15 for ns-3 by
1.9.1