A Discrete-Event Network Simulator
API
ns3::OFSwitch13Controller Class Reference

OpenFlow 1.3 controller base class that can handle a collection of OpenFlow switches and provides the basic functionalities for controller implementation. More...

#include "ofswitch13-controller.h"

+ Inheritance diagram for ns3::OFSwitch13Controller:
+ Collaboration diagram for ns3::OFSwitch13Controller:

Classes

struct  BarrierInfo
 Structure to save barrier metadata used by the controller interface. More...
 
struct  EchoInfo
 Structure to save echo request metadata used by the controller interface. More...
 
class  PendingCommands
 Inner class to save pending commands waiting for handshake procedure. More...
 
class  RemoteSwitch
 Inner class to save information of a remote active OpenFlow switch connected to this controller. More...
 

Public Member Functions

 OFSwitch13Controller ()
 Default constructor. More...
 
 ~OFSwitch13Controller () override
 Dummy destructor, see DoDispose. More...
 
void DoDispose () override
 Destructor implementation. More...
 
int DpctlExecute (uint64_t dpId, const std::string textCmd)
 Execute a dpctl command to interact with the remote switch. More...
 
- Public Member Functions inherited from ns3::Application
 Application ()
 
 ~Application () override
 
Ptr< NodeGetNode () const
 
void SetNode (Ptr< Node > node)
 
void SetStartTime (Time start)
 Specify application start time. More...
 
void SetStopTime (Time stop)
 Specify application stop time. More...
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor. More...
 
 ~Object () override
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose ()
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one. More...
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object. More...
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object. More...
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object. More...
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
bool IsInitialized () const
 Check if the object has been initialized. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount () const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o[[maybe_unused]])
 Assignment operator. More...
 
void Ref () const
 Increment the reference count. More...
 
void Unref () const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 

Static Public Member Functions

static void DpctlSendAndPrint (struct vconn *vconn, struct ofl_msg_header *msg)
 Overriding BOFUSS dpctl_send_and_print and dpctl_transact_and_print weak functions from utilities/dpctl.c. More...
 
static TypeId GetTypeId ()
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::Application
static TypeId GetTypeId ()
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID. More...
 

Protected Member Functions

uint32_t GetNextXid ()
 
Ptr< const RemoteSwitchGetRemoteSwitch (uint64_t dpId) const
 Get the remote switch for this OpenFlow datapath ID. More...
 
virtual void HandshakeSuccessful (Ptr< const RemoteSwitch > swtch)
 Function invoked after a successfully handshake procedure between this controller and a remote switch. More...
 
void SendBarrierRequest (Ptr< const RemoteSwitch > swtch)
 Send a barrier request message to switch, and wait for a non-blocking reply. More...
 
void SendEchoRequest (Ptr< const RemoteSwitch > swtch, size_t payloadSize=0)
 Send an echo request message to switch, and wait for a non-blocking reply. More...
 
int SendToSwitch (Ptr< const RemoteSwitch > swtch, struct ofl_msg_header *msg, uint32_t xid=0)
 Send a OFLib message to a registered switch. More...
 
void StartApplication () override
 Application specific startup code. More...
 
void StopApplication () override
 Application specific shutdown code. More...
 
- Protected Member Functions inherited from ns3::Application
void DoInitialize () override
 Initialize() implementation. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes. More...
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed. More...
 

Socket callbacks

Handlers used as socket callbacks to TCP communication between this switch and the controller.

Parameters
socketThe TCP socket.
fromThe source Address
typedef std::map< uint32_t, EchoInfoEchoMsgMap_t
 Map to store echo information by transaction id. More...
 
typedef std::map< uint32_t, BarrierInfoBarrierMsgMap_t
 Map to store barrier information by transaction id. More...
 
typedef std::map< uint64_t, Ptr< PendingCommands > > DpIdCmdMap_t
 Map saving pair <datapath id / pending commands> More...
 
typedef std::map< Address, Ptr< RemoteSwitch > > AddrSwMap_t
 Map to store switch info by ip address. More...
 
typedef std::map< uint64_t, Ptr< RemoteSwitch > > DpIdSwMap_t
 Map to store switch info by datapath id. More...
 
uint32_t m_xid
 Global transaction idx. More...
 
uint16_t m_port
 Local controller tcp port. More...
 
Ptr< Socketm_serverSocket
 Listening server socket. More...
 
EchoMsgMap_t m_echoMap
 Metadata for echo requests. More...
 
BarrierMsgMap_t m_barrierMap
 Metadata for barrier requests. More...
 
DpIdCmdMap_t m_commandsMap
 Commands scheduled for execution. More...
 
AddrSwMap_t m_addrSwMap
 Registered switches by address. More...
 
DpIdSwMap_t m_dpIdSwMap
 Registered switches by datapath id. More...
 
bool SocketRequest (Ptr< Socket > socket, const Address &from)
 TCP request from switch. More...
 
void SocketAccept (Ptr< Socket > socket, const Address &from)
 TCP handshake succeeded. More...
 
void SocketPeerClose (Ptr< Socket > socket)
 TCP connection closed. More...
 
void SocketPeerError (Ptr< Socket > socket)
 TCP connection error. More...
 

OpenFlow message handlers

Handlers used by HandleSwitchMsg to process each type of OpenFlow message received from the switch.

Some (non virtual) handlers can not be overwritten by derived class, as they must behave as already implemented. The current implementation of other virtual handler methods does nothing: just free the received message and returns 0. Derived controllers can override them as they wish to implement the desired control logic.

Note that for HandleMultipartReply there are several types of multipart messages. Derived controllers can filter by the type they wish.

Attention
Handlers MUST free received msg when everything is ok.
Parameters
msgThe OpenFlow received message.
swtchThe remote switch metadata.
xidThe transaction id from the request message.
Returns
0 if everything's ok, otherwise an error number.
ofl_err HandleEchoRequest (struct ofl_msg_echo *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
ofl_err HandleEchoReply (struct ofl_msg_echo *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
ofl_err HandleBarrierReply (struct ofl_msg_header *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
ofl_err HandleHello (struct ofl_msg_header *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
ofl_err HandleFeaturesReply (struct ofl_msg_features_reply *msg, Ptr< RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
virtual ofl_err HandlePacketIn (struct ofl_msg_packet_in *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
virtual ofl_err HandleError (struct ofl_msg_error *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
virtual ofl_err HandleGetConfigReply (struct ofl_msg_get_config_reply *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
virtual ofl_err HandleFlowRemoved (struct ofl_msg_flow_removed *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
virtual ofl_err HandlePortStatus (struct ofl_msg_port_status *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
virtual ofl_err HandleAsyncReply (struct ofl_msg_async_config *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
virtual ofl_err HandleMultipartReply (struct ofl_msg_multipart_reply_header *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
virtual ofl_err HandleRoleReply (struct ofl_msg_role_request *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
virtual ofl_err HandleQueueGetConfigReply (struct ofl_msg_queue_get_config_reply *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
ofl_err HandleSwitchMsg (struct ofl_msg_header *msg, Ptr< RemoteSwitch > swtch, uint32_t xid)
 Called when an OpenFlow message is received from a switch. More...
 
void ReceiveFromSwitch (Ptr< Packet > packet, Address from)
 Receive an OpenFlow packet from switch. More...
 
Ptr< RemoteSwitchGetRemoteSwitch (Address address)
 Get the remote switch for this address. More...
 

Additional Inherited Members

- Public Types inherited from ns3::Application
typedef void(* DelayAddressCallback) (const Time &delay, const Address &from)
 Common callback signature for packet delay and address. More...
 
typedef void(* StateTransitionCallback) (const std::string &oldState, const std::string &newState)
 Common signature used by callbacks to application's state transition trace source. More...
 
- Protected Attributes inherited from ns3::Application
Ptr< Nodem_node
 The node that this application is installed on. More...
 
EventId m_startEvent
 The event that will fire at m_startTime to start the application. More...
 
Time m_startTime
 The simulation time that the application will start. More...
 
EventId m_stopEvent
 The event that will fire at m_stopTime to end the application. More...
 
Time m_stopTime
 The simulation time that the application will end. More...
 

Detailed Description

OpenFlow 1.3 controller base class that can handle a collection of OpenFlow switches and provides the basic functionalities for controller implementation.

Introspection did not find any typical Config paths.

For constructing OpenFlow configuration messages and sending them to the switches, this class uses the DpctlCommand function, which relies on command-line syntax from the dpctl utility. For OpenFlow messages coming from the switches, this class provides a collection of internal handlers to deal with the different types of messages.


Attributes

  • Port: Port number to listen for incoming packets.
    • Set with class: ns3::UintegerValue
    • Underlying type: uint16_t 0:65535
    • Initial value: 6653
    • Flags: constructwriteread

No TraceSources are defined for this type.
Size of this type is 360 bytes (on a 64-bit architecture).

Definition at line 44 of file ofswitch13-controller.h.

Member Typedef Documentation

◆ AddrSwMap_t

Map to store switch info by ip address.

Definition at line 386 of file ofswitch13-controller.h.

◆ BarrierMsgMap_t

typedef std::map<uint32_t, BarrierInfo> ns3::OFSwitch13Controller::BarrierMsgMap_t
private

Map to store barrier information by transaction id.

Definition at line 380 of file ofswitch13-controller.h.

◆ DpIdCmdMap_t

typedef std::map<uint64_t, Ptr<PendingCommands> > ns3::OFSwitch13Controller::DpIdCmdMap_t
private

Map saving pair <datapath id / pending commands>

Definition at line 383 of file ofswitch13-controller.h.

◆ DpIdSwMap_t

typedef std::map<uint64_t, Ptr<RemoteSwitch> > ns3::OFSwitch13Controller::DpIdSwMap_t
private

Map to store switch info by datapath id.

Definition at line 389 of file ofswitch13-controller.h.

◆ EchoMsgMap_t

typedef std::map<uint32_t, EchoInfo> ns3::OFSwitch13Controller::EchoMsgMap_t
private

Map to store echo information by transaction id.

Definition at line 377 of file ofswitch13-controller.h.

Constructor & Destructor Documentation

◆ OFSwitch13Controller()

ns3::OFSwitch13Controller::OFSwitch13Controller ( )

Default constructor.

Definition at line 34 of file ofswitch13-controller.cc.

References m_xid, and NS_LOG_FUNCTION.

◆ ~OFSwitch13Controller()

ns3::OFSwitch13Controller::~OFSwitch13Controller ( )
override

Dummy destructor, see DoDispose.

Definition at line 42 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ DoDispose()

void ns3::OFSwitch13Controller::DoDispose ( )
overridevirtual

Destructor implementation.

Reimplemented from ns3::Application.

Reimplemented in ns3::OFSwitch13LearningController.

Definition at line 63 of file ofswitch13-controller.cc.

References ns3::Application::DoDispose(), m_addrSwMap, m_barrierMap, m_commandsMap, m_dpIdSwMap, m_echoMap, m_serverSocket, and NS_LOG_FUNCTION.

Referenced by ns3::TunnelController::DoDispose().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DpctlExecute()

int ns3::OFSwitch13Controller::DpctlExecute ( uint64_t  dpId,
const std::string  textCmd 
)

Execute a dpctl command to interact with the remote switch.

Parameters
dpIdThe OpenFlow datapath ID.
textCmdThe dpctl command to execute.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 78 of file ofswitch13-controller.cc.

References second::cmd, GetRemoteSwitch(), m_commandsMap, NS_LOG_DEBUG, NS_LOG_ERROR, NS_LOG_FUNCTION, and ns3::PeekPointer().

Referenced by QosController::ConfigureAggregationSwitch(), QosController::ConfigureBorderSwitch(), QosController::HandleConnectionRequest(), HandleFeaturesReply(), ns3::TunnelController::HandlePacketIn(), and ns3::TunnelController::HandshakeSuccessful().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DpctlSendAndPrint()

void ns3::OFSwitch13Controller::DpctlSendAndPrint ( struct vconn *  vconn,
struct ofl_msg_header *  msg 
)
static

Overriding BOFUSS dpctl_send_and_print and dpctl_transact_and_print weak functions from utilities/dpctl.c.

Send a message from controller to switch.

Parameters
vconnThe RemoteSwitch pointer, sent from controller to dpctl_exec_ns3_command function and get back here to proper identify the controller object.
msgThe OFLib message to send.

Definition at line 119 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION_NOARGS.

Referenced by dpctl_send_and_print(), and dpctl_transact_and_print().

+ Here is the caller graph for this function:

◆ GetNextXid()

uint32_t ns3::OFSwitch13Controller::GetNextXid ( )
protected
Returns
The next (in sequence) transaction ID for this controller.

Definition at line 175 of file ofswitch13-controller.cc.

References m_xid.

Referenced by SendBarrierRequest(), SendEchoRequest(), and SendToSwitch().

+ Here is the caller graph for this function:

◆ GetRemoteSwitch() [1/2]

Ptr< OFSwitch13Controller::RemoteSwitch > ns3::OFSwitch13Controller::GetRemoteSwitch ( Address  address)
private

Get the remote switch for this address.

Parameters
addressThe socket address.
Returns
The remote switch.

Definition at line 625 of file ofswitch13-controller.cc.

References first::address, m_addrSwMap, NS_ABORT_MSG, and NS_LOG_FUNCTION.

◆ GetRemoteSwitch() [2/2]

Ptr< const OFSwitch13Controller::RemoteSwitch > ns3::OFSwitch13Controller::GetRemoteSwitch ( uint64_t  dpId) const
protected

Get the remote switch for this OpenFlow datapath ID.

Parameters
dpIdThe OpenFlow datapath ID.
Returns
The remote switch.

Definition at line 187 of file ofswitch13-controller.cc.

References m_dpIdSwMap, and NS_LOG_FUNCTION.

Referenced by DpctlExecute(), and ReceiveFromSwitch().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::OFSwitch13Controller::GetTypeId ( )
static

Register this type.

Returns
The object TypeId.

Definition at line 48 of file ofswitch13-controller.cc.

References m_port, ns3::MakeUintegerAccessor(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ HandleAsyncReply()

ofl_err ns3::OFSwitch13Controller::HandleAsyncReply ( struct ofl_msg_async_config *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protectedvirtual

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 467 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION.

Referenced by HandleSwitchMsg().

+ Here is the caller graph for this function:

◆ HandleBarrierReply()

ofl_err ns3::OFSwitch13Controller::HandleBarrierReply ( struct ofl_msg_header *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protected

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 326 of file ofswitch13-controller.cc.

References m_barrierMap, NS_LOG_FUNCTION, NS_LOG_INFO, and NS_LOG_WARN.

Referenced by HandleSwitchMsg().

+ Here is the caller graph for this function:

◆ HandleEchoReply()

ofl_err ns3::OFSwitch13Controller::HandleEchoReply ( struct ofl_msg_echo *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protected

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 300 of file ofswitch13-controller.cc.

References m_echoMap, ns3::Time::MS, ns3::Simulator::Now(), NS_LOG_FUNCTION, NS_LOG_INFO, and NS_LOG_WARN.

Referenced by HandleSwitchMsg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleEchoRequest()

ofl_err ns3::OFSwitch13Controller::HandleEchoRequest ( struct ofl_msg_echo *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protected

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 283 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION, and SendToSwitch().

Referenced by HandleSwitchMsg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleError()

ofl_err ns3::OFSwitch13Controller::HandleError ( struct ofl_msg_error *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protectedvirtual

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 419 of file ofswitch13-controller.cc.

References NS_LOG_ERROR, and NS_LOG_FUNCTION.

Referenced by HandleSwitchMsg().

+ Here is the caller graph for this function:

◆ HandleFeaturesReply()

ofl_err ns3::OFSwitch13Controller::HandleFeaturesReply ( struct ofl_msg_features_reply *  msg,
Ptr< RemoteSwitch swtch,
uint32_t  xid 
)
protected

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 367 of file ofswitch13-controller.cc.

References DpctlExecute(), HandshakeSuccessful(), ns3::OFSwitch13Controller::RemoteSwitch::m_auxiliaryId, ns3::OFSwitch13Controller::RemoteSwitch::m_capabilities, m_commandsMap, ns3::OFSwitch13Controller::RemoteSwitch::m_dpId, m_dpIdSwMap, ns3::OFSwitch13Controller::RemoteSwitch::m_nBuffers, ns3::OFSwitch13Controller::RemoteSwitch::m_nTables, ns3::OFSwitch13Controller::PendingCommands::m_queue, NS_LOG_ERROR, and NS_LOG_FUNCTION.

Referenced by HandleSwitchMsg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleFlowRemoved()

ofl_err ns3::OFSwitch13Controller::HandleFlowRemoved ( struct ofl_msg_flow_removed *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protectedvirtual

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Reimplemented in ns3::OFSwitch13LearningController.

Definition at line 445 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION.

Referenced by HandleSwitchMsg().

+ Here is the caller graph for this function:

◆ HandleGetConfigReply()

ofl_err ns3::OFSwitch13Controller::HandleGetConfigReply ( struct ofl_msg_get_config_reply *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protectedvirtual

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 434 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION.

Referenced by HandleSwitchMsg().

+ Here is the caller graph for this function:

◆ HandleHello()

ofl_err ns3::OFSwitch13Controller::HandleHello ( struct ofl_msg_header *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protected

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 348 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION, SendBarrierRequest(), and SendToSwitch().

Referenced by HandleSwitchMsg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleMultipartReply()

ofl_err ns3::OFSwitch13Controller::HandleMultipartReply ( struct ofl_msg_multipart_reply_header *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protectedvirtual

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 478 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION.

Referenced by HandleSwitchMsg().

+ Here is the caller graph for this function:

◆ HandlePacketIn()

ofl_err ns3::OFSwitch13Controller::HandlePacketIn ( struct ofl_msg_packet_in *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protectedvirtual

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Reimplemented in ns3::OFSwitch13LearningController, QosController, and ns3::TunnelController.

Definition at line 408 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION.

Referenced by HandleSwitchMsg().

+ Here is the caller graph for this function:

◆ HandlePortStatus()

ofl_err ns3::OFSwitch13Controller::HandlePortStatus ( struct ofl_msg_port_status *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protectedvirtual

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 456 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION.

Referenced by HandleSwitchMsg().

+ Here is the caller graph for this function:

◆ HandleQueueGetConfigReply()

ofl_err ns3::OFSwitch13Controller::HandleQueueGetConfigReply ( struct ofl_msg_queue_get_config_reply *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protectedvirtual

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 501 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION.

Referenced by HandleSwitchMsg().

+ Here is the caller graph for this function:

◆ HandleRoleReply()

ofl_err ns3::OFSwitch13Controller::HandleRoleReply ( struct ofl_msg_role_request *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
protectedvirtual

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 490 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION.

Referenced by HandleSwitchMsg().

+ Here is the caller graph for this function:

◆ HandleSwitchMsg()

ofl_err ns3::OFSwitch13Controller::HandleSwitchMsg ( struct ofl_msg_header *  msg,
Ptr< RemoteSwitch swtch,
uint32_t  xid 
)
private

Called when an OpenFlow message is received from a switch.

Dispatches control messages to appropriate handler functions.

Parameters
msgThe OFLib message received.
swtchThe remote switch the message was received from.
xidThe transaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 516 of file ofswitch13-controller.cc.

References HandleAsyncReply(), HandleBarrierReply(), HandleEchoReply(), HandleEchoRequest(), HandleError(), HandleFeaturesReply(), HandleFlowRemoved(), HandleGetConfigReply(), HandleHello(), HandleMultipartReply(), HandlePacketIn(), HandlePortStatus(), HandleQueueGetConfigReply(), HandleRoleReply(), and NS_LOG_FUNCTION.

Referenced by ReceiveFromSwitch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandshakeSuccessful()

void ns3::OFSwitch13Controller::HandshakeSuccessful ( Ptr< const RemoteSwitch swtch)
protectedvirtual

Function invoked after a successfully handshake procedure between this controller and a remote switch.

Derived classes can override this function to implement any relevant logic, as sending initial configuration messages to the switch.

Parameters
swtchThe remote switch.

Reimplemented in ns3::OFSwitch13LearningController, QosController, Controller1, Controller0, and ns3::TunnelController.

Definition at line 181 of file ofswitch13-controller.cc.

References NS_LOG_FUNCTION.

Referenced by HandleFeaturesReply().

+ Here is the caller graph for this function:

◆ ReceiveFromSwitch()

void ns3::OFSwitch13Controller::ReceiveFromSwitch ( Ptr< Packet packet,
Address  from 
)
private

Receive an OpenFlow packet from switch.

Parameters
packetThe packet with the OpenFlow message.
fromThe packet sender address.

Definition at line 583 of file ofswitch13-controller.cc.

References ns3::BufferFromPacket(), ns3::OFSwitch13Controller::RemoteSwitch::GetDpId(), ns3::OFSwitch13Controller::RemoteSwitch::GetIpv4(), GetRemoteSwitch(), ns3::Packet::GetSize(), HandleSwitchMsg(), NS_LOG_DEBUG, NS_LOG_ERROR, and NS_LOG_FUNCTION.

Referenced by SocketAccept().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendBarrierRequest()

void ns3::OFSwitch13Controller::SendBarrierRequest ( Ptr< const RemoteSwitch swtch)
protected

Send a barrier request message to switch, and wait for a non-blocking reply.

Note that current OpenFlow device implementation is single-threaded and messages are processed in the same order that are received from the controller, so a barrier request will simply be replied by the switch.

Parameters
swtchThe remote switch to receive the message.

Definition at line 260 of file ofswitch13-controller.cc.

References GetNextXid(), m_barrierMap, NS_LOG_ERROR, NS_LOG_FUNCTION, and SendToSwitch().

Referenced by HandleHello().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendEchoRequest()

void ns3::OFSwitch13Controller::SendEchoRequest ( Ptr< const RemoteSwitch swtch,
size_t  payloadSize = 0 
)
protected

Send an echo request message to switch, and wait for a non-blocking reply.

Parameters
swtchThe remote switch to receive the message.
payloadSizeThe ammount of dummy bytes in echo message.

Definition at line 222 of file ofswitch13-controller.cc.

References GetNextXid(), m_echoMap, NS_LOG_ERROR, NS_LOG_FUNCTION, and SendToSwitch().

+ Here is the call graph for this function:

◆ SendToSwitch()

int ns3::OFSwitch13Controller::SendToSwitch ( Ptr< const RemoteSwitch swtch,
struct ofl_msg_header *  msg,
uint32_t  xid = 0 
)
protected

Send a OFLib message to a registered switch.

Parameters
swtchThe remote switch to receive the message.
msgThe OFLib message to send.
xidThe transaction id to use.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 200 of file ofswitch13-controller.cc.

References GetNextXid(), NS_LOG_DEBUG, NS_LOG_FUNCTION, and ns3::PacketFromMsg().

Referenced by ns3::TunnelController::HandleArpPacketIn(), QosController::HandleArpPacketIn(), QosController::HandleConnectionRequest(), HandleEchoRequest(), HandleHello(), SendBarrierRequest(), SendEchoRequest(), and SocketAccept().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SocketAccept()

void ns3::OFSwitch13Controller::SocketAccept ( Ptr< Socket socket,
const Address from 
)
private

◆ SocketPeerClose()

void ns3::OFSwitch13Controller::SocketPeerClose ( Ptr< Socket socket)
private

TCP connection closed.

Definition at line 689 of file ofswitch13-controller.cc.

References NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::Socket::ShutdownRecv(), and ns3::Socket::ShutdownSend().

Referenced by StartApplication().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SocketPeerError()

void ns3::OFSwitch13Controller::SocketPeerError ( Ptr< Socket socket)
private

TCP connection error.

Definition at line 699 of file ofswitch13-controller.cc.

References NS_LOG_ERROR, NS_LOG_FUNCTION, ns3::Socket::ShutdownRecv(), and ns3::Socket::ShutdownSend().

Referenced by StartApplication().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SocketRequest()

bool ns3::OFSwitch13Controller::SocketRequest ( Ptr< Socket socket,
const Address from 
)
private

TCP request from switch.

Definition at line 638 of file ofswitch13-controller.cc.

References ns3::InetSocketAddress::ConvertFrom(), ns3::InetSocketAddress::GetIpv4(), ns3::InetSocketAddress::GetPort(), ns3::InetSocketAddress::IsMatchingType(), NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_INFO, and port.

Referenced by StartApplication().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StartApplication()

void ns3::OFSwitch13Controller::StartApplication ( )
overrideprotectedvirtual

Application specific startup code.

The StartApplication method is called at the start time specified by Start This method should be overridden by all or most application subclasses.

Reimplemented from ns3::Application.

Definition at line 130 of file ofswitch13-controller.cc.

References ns3::Socket::Bind(), ns3::Socket::CreateSocket(), ns3::Ipv4Address::GetAny(), ns3::Application::GetNode(), ns3::Socket::Listen(), ns3::TypeId::LookupByName(), m_port, m_serverSocket, ns3::MakeCallback(), NS_LOG_FUNCTION, ns3::Socket::SetAcceptCallback(), ns3::ObjectBase::SetAttribute(), ns3::Socket::SetCloseCallbacks(), SocketAccept(), SocketPeerClose(), SocketPeerError(), and SocketRequest().

+ Here is the call graph for this function:

◆ StopApplication()

void ns3::OFSwitch13Controller::StopApplication ( )
overrideprotectedvirtual

Application specific shutdown code.

The StopApplication method is called at the stop time specified by Stop This method should be overridden by all or most application subclasses.

Reimplemented from ns3::Application.

Definition at line 151 of file ofswitch13-controller.cc.

References ns3::Socket::Close(), m_addrSwMap, m_barrierMap, m_commandsMap, m_dpIdSwMap, m_echoMap, ns3::OFSwitch13Controller::RemoteSwitch::m_handler, m_port, m_serverSocket, ns3::MakeNullCallback(), NS_LOG_FUNCTION, and ns3::Socket::SetRecvCallback().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_addrSwMap

AddrSwMap_t ns3::OFSwitch13Controller::m_addrSwMap
private

Registered switches by address.

Definition at line 398 of file ofswitch13-controller.h.

Referenced by DoDispose(), GetRemoteSwitch(), SocketAccept(), and StopApplication().

◆ m_barrierMap

BarrierMsgMap_t ns3::OFSwitch13Controller::m_barrierMap
private

Metadata for barrier requests.

Definition at line 396 of file ofswitch13-controller.h.

Referenced by DoDispose(), HandleBarrierReply(), SendBarrierRequest(), and StopApplication().

◆ m_commandsMap

DpIdCmdMap_t ns3::OFSwitch13Controller::m_commandsMap
private

Commands scheduled for execution.

Definition at line 397 of file ofswitch13-controller.h.

Referenced by DoDispose(), DpctlExecute(), HandleFeaturesReply(), and StopApplication().

◆ m_dpIdSwMap

DpIdSwMap_t ns3::OFSwitch13Controller::m_dpIdSwMap
private

Registered switches by datapath id.

Definition at line 399 of file ofswitch13-controller.h.

Referenced by DoDispose(), GetRemoteSwitch(), HandleFeaturesReply(), and StopApplication().

◆ m_echoMap

EchoMsgMap_t ns3::OFSwitch13Controller::m_echoMap
private

Metadata for echo requests.

Definition at line 395 of file ofswitch13-controller.h.

Referenced by DoDispose(), HandleEchoReply(), SendEchoRequest(), and StopApplication().

◆ m_port

uint16_t ns3::OFSwitch13Controller::m_port
private

Local controller tcp port.

Definition at line 392 of file ofswitch13-controller.h.

Referenced by GetTypeId(), StartApplication(), and StopApplication().

◆ m_serverSocket

Ptr<Socket> ns3::OFSwitch13Controller::m_serverSocket
private

Listening server socket.

Definition at line 393 of file ofswitch13-controller.h.

Referenced by DoDispose(), StartApplication(), and StopApplication().

◆ m_xid

uint32_t ns3::OFSwitch13Controller::m_xid
private

Global transaction idx.

Definition at line 391 of file ofswitch13-controller.h.

Referenced by OFSwitch13Controller(), and GetNextXid().


The documentation for this class was generated from the following files: