A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
bridge-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17
18#include "bridge-helper.h"
19
20#include "ns3/bridge-net-device.h"
21#include "ns3/log.h"
22#include "ns3/names.h"
23#include "ns3/node.h"
24
31namespace ns3
32{
33
34NS_LOG_COMPONENT_DEFINE("BridgeHelper");
35
37{
39 m_deviceFactory.SetTypeId("ns3::BridgeNetDevice");
40}
41
42void
44{
46 m_deviceFactory.Set(n1, v1);
47}
48
51{
53 NS_LOG_LOGIC("**** Install bridge device on node " << node->GetId());
54
57 devs.Add(dev);
58 node->AddDevice(dev);
59
60 for (auto i = c.Begin(); i != c.End(); ++i)
61 {
62 NS_LOG_LOGIC("**** Add BridgePort " << *i);
63 dev->AddBridgePort(*i);
64 }
65 return devs;
66}
67
70{
72 Ptr<Node> node = Names::Find<Node>(nodeName);
73 return Install(node, c);
74}
75
76} // namespace ns3
ns3::BridgeHelper declaration.
Hold a value for an Attribute.
Definition: attribute.h:70
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
Set an attribute on each ns3::BridgeNetDevice created by BridgeHelper::Install.
ObjectFactory m_deviceFactory
Object factory.
Definition: bridge-helper.h:83
NetDeviceContainer Install(Ptr< Node > node, NetDeviceContainer c)
This method creates an ns3::BridgeNetDevice with the attributes configured by BridgeHelper::SetDevice...
a virtual net device that bridges multiple LAN segments
holds a vector of ns3::NetDevice pointers
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:282
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Every class exported by the ns3 library is enclosed in the ns3 namespace.