A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
openflow-switch-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 Blake Hurd
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Blake Hurd <naimorai@gmail.com>
7 */
8
10
11#include "ns3/log.h"
12#include "ns3/names.h"
13#include "ns3/node.h"
14#include "ns3/openflow-interface.h"
15#include "ns3/openflow-switch-net-device.h"
16
17namespace ns3
18{
19
20NS_LOG_COMPONENT_DEFINE("OpenFlowSwitchHelper");
21
27
28void
34
39{
41 NS_LOG_INFO("**** Install switch device on node " << node->GetId());
42
45 devs.Add(dev);
46 node->AddDevice(dev);
47
48 NS_LOG_INFO("**** Set up Controller");
49 dev->SetController(controller);
50
51 for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i)
52 {
53 NS_LOG_INFO("**** Add SwitchPort " << *i);
54 dev->AddSwitchPort(*i);
55 }
56 return devs;
57}
58
61{
63 NS_LOG_INFO("**** Install switch device on node " << node->GetId());
64
67 devs.Add(dev);
68 node->AddDevice(dev);
69
70 for (NetDeviceContainer::Iterator i = c.Begin(); i != c.End(); ++i)
71 {
72 NS_LOG_INFO("**** Add SwitchPort " << *i);
73 dev->AddSwitchPort(*i);
74 }
75 return devs;
76}
77
80{
82 Ptr<Node> node = Names::Find<Node>(nodeName);
83 return Install(node, c);
84}
85
86} // namespace ns3
Hold a value for an Attribute.
Definition attribute.h:59
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
holds a vector of ns3::NetDevice pointers
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
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.
NetDeviceContainer Install(Ptr< Node > node, NetDeviceContainer c, Ptr< ns3::ofi::Controller > controller)
This method creates an ns3::OpenFlowSwitchNetDevice with the attributes configured by OpenFlowSwitchH...
ObjectFactory m_deviceFactory
Object factory.
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
Set an attribute on each ns3::OpenFlowSwitchNetDevice created by OpenFlowSwitchHelper::Install.
A net device that switches multiple LAN segments via an OpenFlow-compatible flow table.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition log.h:264
Every class exported by the ns3 library is enclosed in the ns3 namespace.