24 #include <ns3/ofswitch13-learning-controller.h>
32 class OFSwitch13Controller;
47 static TypeId tid = TypeId(
"ns3::OFSwitch13InternalHelper")
49 .SetGroupName(
"OFSwitch13")
69 NS_LOG_INFO(
"Attach all switches and controllers to the same "
73 Ptr<CsmaChannel> csmaChannel = CreateObjectWithAttributes<CsmaChannel>(
78 NetDeviceContainer switchDevices;
79 Ipv4InterfaceContainer controllerAddrs;
86 UintegerValue portValue;
87 for (uint32_t ctIdx = 0; ctIdx < controllerAddrs.GetN(); ctIdx++)
90 InetSocketAddress addr(controllerAddrs.GetAddress(ctIdx),
98 << (*ofDev)->GetDatapathId() <<
" to controller "
99 << addr.GetIpv4() <<
" port " << addr.GetPort());
127 StringValue(
"65536p"));
130 StringValue(
"65536p"));
133 UintegerValue portValue;
144 NetDeviceContainer pairDevs =
Connect(ctNode, swNode);
146 Ipv4InterfaceContainer pairIfaces =
151 InetSocketAddress addr(pairIfaces.GetAddress(0),
155 << ofDev->GetDatapathId() <<
" to controller "
156 << addr.GetIpv4() <<
" port " << addr.GetPort());
172 Ptr<OFSwitch13Controller>
175 Ptr<OFSwitch13Controller> controller)
179 NS_LOG_INFO(
"Installing OpenFlow controller on node " << cNode->GetId());
183 if (!cNode->GetObject<Ipv4>())
189 controller->SetStartTime(
Seconds(0));
190 cNode->AddApplication(controller);
210 NodeContainer pairNodes(ctrl, swtch);
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
void SetQueue(std::string type, Ts &&... args)
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
AttributeValue implementation for DataRate.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Ipv4Address NewNetwork()
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
std::vector< Ptr< OFSwitch13Device > >::const_iterator Iterator
OFSwitch13Device container iterator.
Ptr< OFSwitch13Device > Get(uint32_t i) const
Get the Ptr<OFSwitch13Device> stored in this container at a given index.
Iterator Begin() const
Get an iterator which refers to the first OpenFlow device in the container.
Iterator End() const
Get an iterator which indicates past-the-last OpenFlow device in the container.
void StartControllerConnection(Address ctrlAddr)
Starts the TCP connection between this switch and the target controller indicated by the address para...
InternetStackHelper m_internet
Helper for TCP/IP stack.
DataRate m_channelDataRate
OF channel data rate.
@ DEDICATEDP2P
Uses individual P2P channels.
@ DEDICATEDCSMA
Uses individual CSMA channels.
@ SINGLECSMA
Uses a single shared CSMA channel.
void DoDispose() override
Destructor implementation.
PointToPointHelper m_p2pHelper
Helper for P2P links.
NetDeviceContainer m_controlDevs
OF channel ctrl devices.
CsmaHelper m_csmaHelper
Helper for CSMA links.
static Ipv4AddressHelper m_ipv4helper
Helper for IP address.
OFSwitch13DeviceContainer m_openFlowDevs
OF switch devices.
bool m_blocked
Block this helper.
ChannelType m_channelType
OF channel type.
OFSwitch13Helper()
Default constructor.
NodeContainer m_switchNodes
OF switch nodes.
NodeContainer m_controlNodes
OF controller nodes.
void CreateOpenFlowChannels() override
This virtual method must interconnect all switches to all controllers installed by this helper and st...
OFSwitch13InternalHelper()
Default constructor.
void DoDispose() override
Destructor implementation.
NetDeviceContainer Connect(Ptr< Node > ctrl, Ptr< Node > swtch)
Create an individual connection between the switch and the controller node, using the already configu...
ApplicationContainer m_controlApps
OF controller apps.
Ptr< OFSwitch13Controller > InstallController(Ptr< Node > cNode, Ptr< OFSwitch13Controller > controller=CreateObject< OFSwitch13LearningController >())
This method installs the given controller application into the given controller node.
~OFSwitch13InternalHelper() override
Dummy destructor, see DoDispose.
static TypeId GetTypeId()
Register this type.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void SetQueue(std::string type, Ts &&... args)
Each point to point net device must have a queue to pass packets through.
NetDeviceContainer Install(NodeContainer c)
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.