A Discrete-Event Network Simulator
API
QosController Class Reference

An border OpenFlow 1.3 controller. More...

#include "qos-controller.h"

+ Inheritance diagram for QosController:
+ Collaboration diagram for QosController:

Public Member Functions

 QosController ()
 Default constructor. More...
 
 ~QosController () override
 Dummy destructor. More...
 
void DoDispose () override
 Destructor implementation. More...
 
ofl_err HandlePacketIn (struct ofl_msg_packet_in *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid) override
 Handle a packet in message sent by the switch to this controller. More...
 
- Public Member Functions inherited from ns3::OFSwitch13Controller
 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 TypeId GetTypeId ()
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::OFSwitch13Controller
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

void HandshakeSuccessful (Ptr< const RemoteSwitch > swtch) override
 Function invoked after a successfully handshake procedure between this controller and a remote switch. More...
 
- Protected Member Functions inherited from ns3::OFSwitch13Controller
uint32_t GetNextXid ()
 
Ptr< const RemoteSwitchGetRemoteSwitch (uint64_t dpId) const
 Get the remote switch for this OpenFlow datapath ID. 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...
 
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 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...
 
- 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...
 

Private Types

typedef std::map< Ipv4Address, Mac48AddressIpMacMap_t
 Map saving <IPv4 address / MAC address> More...
 

Private Member Functions

void ConfigureAggregationSwitch (Ptr< const RemoteSwitch > swtch)
 Configure the aggregation switch. More...
 
void ConfigureBorderSwitch (Ptr< const RemoteSwitch > swtch)
 Configure the border switch. More...
 
Ptr< PacketCreateArpReply (Mac48Address srcMac, Ipv4Address srcIp, Mac48Address dstMac, Ipv4Address dstIp)
 Create an ARP reply packet, encapsulated inside of an Ethernet frame. More...
 
Ptr< PacketCreateArpRequest (Mac48Address srcMac, Ipv4Address srcIp, Ipv4Address dstIp)
 Create an ARP request packet, encapsulated inside of an Ethernet frame. More...
 
Ipv4Address ExtractIpv4Address (uint32_t oxm_of, struct ofl_match *match)
 Extract an IPv4 address from packet match. More...
 
Mac48Address GetArpEntry (Ipv4Address ip)
 Perform an ARP resolution. More...
 
ofl_err HandleArpPacketIn (struct ofl_msg_packet_in *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Handle ARP request messages. More...
 
ofl_err HandleConnectionRequest (struct ofl_msg_packet_in *msg, Ptr< const RemoteSwitch > swtch, uint32_t xid)
 Handle TCP connection request. More...
 
void SaveArpEntry (Ipv4Address ipAddr, Mac48Address macAddr)
 Save the pair IP / MAC address in ARP table. More...
 

Private Attributes

IpMacMap_t m_arpTable
 ARP resolution table. More...
 
bool m_linkAggregation
 Enable link aggregation. More...
 
bool m_meterEnable
 Enable per-flow mettering. More...
 
DataRate m_meterRate
 Per-flow meter rate. More...
 
Address m_serverIpAddress
 Virtual server IP address. More...
 
Address m_serverMacAddress
 Border switch MAC address. More...
 
uint16_t m_serverTcpPort
 Virtual server TCP port. 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

An border OpenFlow 1.3 controller.

Definition at line 30 of file qos-controller.h.

Member Typedef Documentation

◆ IpMacMap_t

Map saving <IPv4 address / MAC address>

Definition at line 148 of file qos-controller.h.

Constructor & Destructor Documentation

◆ QosController()

QosController::QosController ( )

Default constructor.

Definition at line 28 of file qos-controller.cc.

References NS_LOG_FUNCTION.

◆ ~QosController()

QosController::~QosController ( )
override

Dummy destructor.

Definition at line 33 of file qos-controller.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ ConfigureAggregationSwitch()

void QosController::ConfigureAggregationSwitch ( Ptr< const RemoteSwitch swtch)
private

Configure the aggregation switch.

Parameters
swtchThe switch information.

Definition at line 206 of file qos-controller.cc.

References ns3::OFSwitch13Controller::DpctlExecute(), m_linkAggregation, and NS_LOG_FUNCTION.

Referenced by HandshakeSuccessful().

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

◆ ConfigureBorderSwitch()

void QosController::ConfigureBorderSwitch ( Ptr< const RemoteSwitch swtch)
private

Configure the border switch.

Parameters
swtchThe switch information.

Definition at line 141 of file qos-controller.cc.

References ns3::OFSwitch13Controller::DpctlExecute(), m_linkAggregation, and NS_LOG_FUNCTION.

Referenced by HandshakeSuccessful().

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

◆ CreateArpReply()

Ptr< Packet > QosController::CreateArpReply ( Mac48Address  srcMac,
Ipv4Address  srcIp,
Mac48Address  dstMac,
Ipv4Address  dstIp 
)
private

Create an ARP reply packet, encapsulated inside of an Ethernet frame.

Parameters
srcMacSource MAC address.
srcIpSource IP address.
dstMacDestination MAC address.
dstIpDestination IP address.
Returns
The ns3 Ptr<Packet> with the ARP reply.

Definition at line 511 of file qos-controller.cc.

References ns3::Packet::AddAtEnd(), ns3::Packet::AddHeader(), ns3::Packet::AddTrailer(), ns3::EthernetTrailer::CalcFcs(), ns3::EthernetTrailer::EnableFcs(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, ns3::EthernetHeader::SetDestination(), ns3::EthernetHeader::SetLengthType(), ns3::ArpHeader::SetReply(), and ns3::EthernetHeader::SetSource().

Referenced by HandleArpPacketIn().

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

◆ CreateArpRequest()

Ptr< Packet > QosController::CreateArpRequest ( Mac48Address  srcMac,
Ipv4Address  srcIp,
Ipv4Address  dstIp 
)
private

Create an ARP request packet, encapsulated inside of an Ethernet frame.

Parameters
srcMacSource MAC address.
srcIpSource IP address.
dstIpDestination IP address.
Returns
The ns3 Ptr<Packet> with the ARP request.

Definition at line 473 of file qos-controller.cc.

References ns3::Packet::AddAtEnd(), ns3::Packet::AddHeader(), ns3::Packet::AddTrailer(), ns3::EthernetTrailer::CalcFcs(), ns3::EthernetTrailer::EnableFcs(), ns3::Packet::GetSize(), NS_LOG_FUNCTION, ns3::EthernetHeader::SetDestination(), ns3::EthernetHeader::SetLengthType(), ns3::ArpHeader::SetRequest(), and ns3::EthernetHeader::SetSource().

Referenced by HandleConnectionRequest().

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

◆ DoDispose()

void QosController::DoDispose ( )
overridevirtual

Destructor implementation.

Reimplemented from ns3::Application.

Definition at line 39 of file qos-controller.cc.

References m_arpTable, and NS_LOG_FUNCTION.

◆ ExtractIpv4Address()

Ipv4Address QosController::ExtractIpv4Address ( uint32_t  oxm_of,
struct ofl_match *  match 
)
private

Extract an IPv4 address from packet match.

Parameters
oxm_ofThe OXM_IF_* IPv4 field.
matchThe ofl_match structure pointer.
Returns
The IPv4 address.

Definition at line 453 of file qos-controller.cc.

References NS_ABORT_MSG.

Referenced by HandleArpPacketIn(), and HandleConnectionRequest().

+ Here is the caller graph for this function:

◆ GetArpEntry()

Mac48Address QosController::GetArpEntry ( Ipv4Address  ip)
private

Perform an ARP resolution.

Parameters
ipThe Ipv4Address to search.
Returns
The MAC address for this ip.

Definition at line 565 of file qos-controller.cc.

References m_arpTable, NS_ABORT_MSG, and NS_LOG_INFO.

Referenced by HandleArpPacketIn().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId QosController::GetTypeId ( )
static

Register this type.

Returns
The object TypeId.

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

References m_linkAggregation, m_meterEnable, m_meterRate, m_serverIpAddress, m_serverMacAddress, m_serverTcpPort, ns3::MakeBooleanAccessor(), ns3::MakeBooleanChecker(), ns3::MakeUintegerAccessor(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ HandleArpPacketIn()

ofl_err QosController::HandleArpPacketIn ( struct ofl_msg_packet_in *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
private

Handle ARP request messages.

Parameters
msgThe packet-in message.
swtchThe switch information.
xidTransaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 244 of file qos-controller.cc.

References check-style-clang-format::action, ns3::Packet::CopyData(), ns3::Mac48Address::CopyFrom(), CreateArpReply(), ExtractIpv4Address(), GetArpEntry(), ns3::Packet::GetSize(), m_serverIpAddress, m_serverMacAddress, NS_ASSERT_MSG, NS_LOG_FUNCTION, and ns3::OFSwitch13Controller::SendToSwitch().

Referenced by HandlePacketIn().

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

◆ HandleConnectionRequest()

ofl_err QosController::HandleConnectionRequest ( struct ofl_msg_packet_in *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
private

Handle TCP connection request.

Parameters
msgThe packet-in message.
swtchThe switch information.
xidTransaction id.
Returns
0 if everything's ok, otherwise an error number.

Definition at line 327 of file qos-controller.cc.

References check-style-clang-format::action, ns3::Packet::CopyData(), ns3::Mac48Address::CopyFrom(), CreateArpRequest(), ns3::OFSwitch13Controller::DpctlExecute(), ExtractIpv4Address(), ns3::DataRate::GetBitRate(), ns3::Packet::GetSize(), m_meterEnable, m_meterRate, m_serverIpAddress, m_serverMacAddress, m_serverTcpPort, NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_INFO, SaveArpEntry(), and ns3::OFSwitch13Controller::SendToSwitch().

Referenced by HandlePacketIn().

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

◆ HandlePacketIn()

ofl_err QosController::HandlePacketIn ( struct ofl_msg_packet_in *  msg,
Ptr< const RemoteSwitch swtch,
uint32_t  xid 
)
overridevirtual

Handle a packet in message sent by the switch to this controller.

Note
Inherited from OFSwitch13Controller.
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.

Reimplemented from ns3::OFSwitch13Controller.

Definition at line 88 of file qos-controller.cc.

References HandleArpPacketIn(), HandleConnectionRequest(), NS_LOG_DEBUG, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ HandshakeSuccessful()

void QosController::HandshakeSuccessful ( Ptr< const RemoteSwitch swtch)
overrideprotectedvirtual

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 from ns3::OFSwitch13Controller.

Definition at line 124 of file qos-controller.cc.

References ConfigureAggregationSwitch(), ConfigureBorderSwitch(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ SaveArpEntry()

void QosController::SaveArpEntry ( Ipv4Address  ipAddr,
Mac48Address  macAddr 
)
private

Save the pair IP / MAC address in ARP table.

Parameters
ipAddrThe IPv4 address.
macAddrThe MAC address.

Definition at line 552 of file qos-controller.cc.

References m_arpTable, and NS_LOG_INFO.

Referenced by HandleConnectionRequest().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_arpTable

IpMacMap_t QosController::m_arpTable
private

ARP resolution table.

Definition at line 149 of file qos-controller.h.

Referenced by DoDispose(), GetArpEntry(), and SaveArpEntry().

◆ m_linkAggregation

bool QosController::m_linkAggregation
private

Enable link aggregation.

Definition at line 145 of file qos-controller.h.

Referenced by ConfigureAggregationSwitch(), ConfigureBorderSwitch(), and GetTypeId().

◆ m_meterEnable

bool QosController::m_meterEnable
private

Enable per-flow mettering.

Definition at line 143 of file qos-controller.h.

Referenced by GetTypeId(), and HandleConnectionRequest().

◆ m_meterRate

DataRate QosController::m_meterRate
private

Per-flow meter rate.

Definition at line 144 of file qos-controller.h.

Referenced by GetTypeId(), and HandleConnectionRequest().

◆ m_serverIpAddress

Address QosController::m_serverIpAddress
private

Virtual server IP address.

Definition at line 140 of file qos-controller.h.

Referenced by GetTypeId(), HandleArpPacketIn(), and HandleConnectionRequest().

◆ m_serverMacAddress

Address QosController::m_serverMacAddress
private

Border switch MAC address.

Definition at line 142 of file qos-controller.h.

Referenced by GetTypeId(), HandleArpPacketIn(), and HandleConnectionRequest().

◆ m_serverTcpPort

uint16_t QosController::m_serverTcpPort
private

Virtual server TCP port.

Definition at line 141 of file qos-controller.h.

Referenced by GetTypeId(), and HandleConnectionRequest().


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