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

A OpenFlow switch port, interconnecting the underlying NetDevice to the OpenFlow device through the OpenFlow receive callback. More...

#include "ofswitch13-port.h"

+ Inheritance diagram for ns3::OFSwitch13Port:
+ Collaboration diagram for ns3::OFSwitch13Port:

Public Member Functions

 OFSwitch13Port ()
 Default constructor. More...
 
 OFSwitch13Port (struct datapath *dp, Ptr< NetDevice > netDev, Ptr< OFSwitch13Device > openflowDev)
 Complete Constructor. More...
 
 ~OFSwitch13Port () override
 Dummy destructor, see DoDispose. More...
 
Ptr< NetDeviceGetPortDevice () const
 Get the NetDevice pointer from the underlying port. More...
 
uint32_t GetPortNo () const
 Get the OpenFlow port number for this port. More...
 
Ptr< OFSwitch13QueueGetPortQueue () const
 Get the OpenFlow queue for this port. More...
 
struct sw_port * GetPortStruct ()
 Get a pointer to the internal BOFUSS port structure. More...
 
Ptr< OFSwitch13DeviceGetSwitchDevice () const
 Get the OFSwitch13Device pointer from this port. More...
 
bool PortUpdateState ()
 Update the port state field based on NetDevice status, and notify the controller when changes occurs. More...
 
bool Send (Ptr< const Packet > packet, uint32_t queueNo=0, uint64_t tunnelId=0)
 Send a packet over this OpenFlow switch port. 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::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 DoDispose () override
 Destructor implementation. More...
 
void NotifyConstructionCompleted () override
 Notifier called once the ObjectBase is fully constructed. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void DoInitialize ()
 Initialize() implementation. 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...
 

Private Member Functions

uint32_t GetPortFeatures ()
 Create the bitmaps of OFPPF_* describing port features. More...
 
bool Receive (Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
 Called when a packet is received on this OpenFlow switch port by the underlying NetDevice. More...
 

Private Attributes

uint64_t m_dpId
 OpenFlow datapath ID. More...
 
ObjectFactory m_factQueue
 Factory for port queue. More...
 
Ptr< NetDevicem_netDev
 Underlying NetDevice. More...
 
Ptr< OFSwitch13Devicem_openflowDev
 OpenFlow device. More...
 
uint32_t m_portNo
 Port number. More...
 
Ptr< OFSwitch13Queuem_portQueue
 OpenFlow port Queue. More...
 
TracedCallback< Ptr< const Packet > > m_rxTrace
 Trace source fired when a packet arrives at this switch port. More...
 
struct sw_port * m_swPort
 BOFUSS port structure. More...
 
TracedCallback< Ptr< const Packet > > m_txTrace
 Trace source fired when a packet will be sent over this switch port. More...
 

Additional Inherited Members

Detailed Description

A OpenFlow switch port, interconnecting the underlying NetDevice to the OpenFlow device through the OpenFlow receive callback.

Introspection did not find any typical Config paths.

This class handles the BOFUSS internal sw_port structure.

See also
BOFUSS udatapath/dp_ports.h
Attention
Each underlying NetDevice used as port must only be assigned a MAC Address. Adding an Ipv4/IPv6 layer to it may cause error.


Attributes

TraceSources

Size of this type is 160 bytes (on a 64-bit architecture).

Definition at line 50 of file ofswitch13-port.h.

Constructor & Destructor Documentation

◆ OFSwitch13Port() [1/2]

ns3::OFSwitch13Port::OFSwitch13Port ( )

Default constructor.

Definition at line 51 of file ofswitch13-port.cc.

References NS_LOG_FUNCTION.

◆ ~OFSwitch13Port()

ns3::OFSwitch13Port::~OFSwitch13Port ( )
override

Dummy destructor, see DoDispose.

Definition at line 61 of file ofswitch13-port.cc.

References NS_LOG_FUNCTION.

◆ OFSwitch13Port() [2/2]

ns3::OFSwitch13Port::OFSwitch13Port ( struct datapath *  dp,
Ptr< NetDevice netDev,
Ptr< OFSwitch13Device openflowDev 
)

Complete Constructor.

Create and populate a new datapath port, notifying the controller of this new port.

See also
ofsoftswitch new_port () at udatapath/dp_ports.c
Parameters
dpThe datapath.
netDevThe underlying NetDevice.
openflowDevThe OpenFlow device.

Definition at line 118 of file ofswitch13-port.cc.

References m_dpId, m_portNo, m_swPort, and NS_LOG_FUNCTION.

Member Function Documentation

◆ DoDispose()

void ns3::OFSwitch13Port::DoDispose ( )
overrideprotectedvirtual

Destructor implementation.

Reimplemented from ns3::Object.

Definition at line 67 of file ofswitch13-port.cc.

References m_netDev, m_openflowDev, m_portQueue, m_swPort, and NS_LOG_FUNCTION.

◆ GetPortDevice()

Ptr< NetDevice > ns3::OFSwitch13Port::GetPortDevice ( ) const

Get the NetDevice pointer from the underlying port.

Returns
A pointer to the corresponding underlying NetDevice.

Definition at line 218 of file ofswitch13-port.cc.

References m_netDev.

◆ GetPortFeatures()

uint32_t ns3::OFSwitch13Port::GetPortFeatures ( )
private

Create the bitmaps of OFPPF_* describing port features.

See also
ofsoftswitch netdev_get_features () at lib/netdev.c
Returns
Port features bitmap.

Definition at line 269 of file ofswitch13-port.cc.

References third::channel, m_netDev, and NS_LOG_FUNCTION.

Referenced by NotifyConstructionCompleted().

+ Here is the caller graph for this function:

◆ GetPortNo()

uint32_t ns3::OFSwitch13Port::GetPortNo ( ) const

Get the OpenFlow port number for this port.

Returns
The port number.

Definition at line 224 of file ofswitch13-port.cc.

References m_portNo.

Referenced by ns3::OFSwitch13Device::AddSwitchPort().

+ Here is the caller graph for this function:

◆ GetPortQueue()

Ptr< OFSwitch13Queue > ns3::OFSwitch13Port::GetPortQueue ( ) const

Get the OpenFlow queue for this port.

Returns
The port queue.

Definition at line 230 of file ofswitch13-port.cc.

References m_portQueue.

◆ GetPortStruct()

struct sw_port * ns3::OFSwitch13Port::GetPortStruct ( )

Get a pointer to the internal BOFUSS port structure.

Returns
The requested pointer.

Definition at line 418 of file ofswitch13-port.cc.

References m_swPort.

◆ GetSwitchDevice()

Ptr< OFSwitch13Device > ns3::OFSwitch13Port::GetSwitchDevice ( ) const

Get the OFSwitch13Device pointer from this port.

Returns
A pointer to the corresponding OFSwitch13Device.

Definition at line 236 of file ofswitch13-port.cc.

References m_openflowDev.

◆ GetTypeId()

TypeId ns3::OFSwitch13Port::GetTypeId ( )
static

◆ NotifyConstructionCompleted()

void ns3::OFSwitch13Port::NotifyConstructionCompleted ( )
overrideprotectedvirtual

Notifier called once the ObjectBase is fully constructed.

This method is invoked once all member attributes have been initialized. Subclasses can override this method to be notified of this event but if they do this, they must chain up to their parent's NotifyConstructionCompleted method.

Reimplemented from ns3::ObjectBase.

Definition at line 139 of file ofswitch13-port.cc.

References ns3::ObjectFactory::Create(), GetPortFeatures(), m_factQueue, m_netDev, m_portNo, m_portQueue, m_swPort, ns3::MakeCallback(), NS_ABORT_MSG_IF, NS_ASSERT, NS_LOG_FUNCTION, ns3::PeekPointer(), Receive(), and time_msec().

+ Here is the call graph for this function:

◆ PortUpdateState()

bool ns3::OFSwitch13Port::PortUpdateState ( )

Update the port state field based on NetDevice status, and notify the controller when changes occurs.

Returns
true if the state of the port has changed, false otherwise.

Definition at line 242 of file ofswitch13-port.cc.

References m_netDev, m_swPort, and NS_LOG_INFO.

◆ Receive()

bool ns3::OFSwitch13Port::Receive ( Ptr< NetDevice device,
Ptr< const Packet packet,
uint16_t  protocol,
const Address from,
const Address to,
NetDevice::PacketType  packetType 
)
private

Called when a packet is received on this OpenFlow switch port by the underlying NetDevice.

It will check port configuration, update counter and send the packet to the OpenFlow pipeline.

See also
BOFUSS function dp_ports_run () at udatapath/dp_ports.c
Parameters
deviceUnderlying ns-3 network device.
packetThe received packet.
protocolNext protocol header value.
fromAddress of the correspondant.
toAddress of the destination.
packetTypeType of the packet.
Returns
true.

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

References ns3::Packet::Copy(), ns3::Packet::GetSize(), ns3::TunnelIdTag::GetTunnelId(), ns3::Packet::GetUid(), m_openflowDev, m_portNo, m_rxTrace, m_swPort, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_WARN, and ns3::Packet::PeekPacketTag().

Referenced by NotifyConstructionCompleted().

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

◆ Send()

bool ns3::OFSwitch13Port::Send ( Ptr< const Packet packet,
uint32_t  queueNo = 0,
uint64_t  tunnelId = 0 
)

Send a packet over this OpenFlow switch port.

It will check port configuration, update counters and send the packet to the underlying device.

See also
BOFUSS function dp_ports_run () at udatapath/dp_ports.c
Parameters
packetThe Packet to send.
queueNoThe queue to use.
tunnelIdThe metadata associated with a logical port.
Returns
true if the packet was sent successfully, false otherwise.

Definition at line 364 of file ofswitch13-port.cc.

References ns3::Packet::Copy(), ns3::EthernetHeader::GetDestination(), ns3::EthernetHeader::GetLengthType(), ns3::Packet::GetSize(), ns3::EthernetHeader::GetSource(), ns3::Packet::GetUid(), m_netDev, m_swPort, m_txTrace, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_WARN, ns3::Packet::RemoveHeader(), ns3::Packet::RemoveTrailer(), and ns3::Packet::ReplacePacketTag().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_dpId

uint64_t ns3::OFSwitch13Port::m_dpId
private

OpenFlow datapath ID.

Definition at line 166 of file ofswitch13-port.h.

Referenced by OFSwitch13Port().

◆ m_factQueue

ObjectFactory ns3::OFSwitch13Port::m_factQueue
private

Factory for port queue.

Definition at line 171 of file ofswitch13-port.h.

Referenced by GetTypeId(), and NotifyConstructionCompleted().

◆ m_netDev

Ptr<NetDevice> ns3::OFSwitch13Port::m_netDev
private

◆ m_openflowDev

Ptr<OFSwitch13Device> ns3::OFSwitch13Port::m_openflowDev
private

OpenFlow device.

Definition at line 172 of file ofswitch13-port.h.

Referenced by DoDispose(), GetSwitchDevice(), and Receive().

◆ m_portNo

uint32_t ns3::OFSwitch13Port::m_portNo
private

Port number.

Definition at line 167 of file ofswitch13-port.h.

Referenced by OFSwitch13Port(), GetPortNo(), NotifyConstructionCompleted(), and Receive().

◆ m_portQueue

Ptr<OFSwitch13Queue> ns3::OFSwitch13Port::m_portQueue
private

OpenFlow port Queue.

Definition at line 170 of file ofswitch13-port.h.

Referenced by DoDispose(), GetPortQueue(), GetTypeId(), and NotifyConstructionCompleted().

◆ m_rxTrace

TracedCallback<Ptr<const Packet> > ns3::OFSwitch13Port::m_rxTrace
private

Trace source fired when a packet arrives at this switch port.

Definition at line 161 of file ofswitch13-port.h.

Referenced by GetTypeId(), and Receive().

◆ m_swPort

struct sw_port* ns3::OFSwitch13Port::m_swPort
private

BOFUSS port structure.

Definition at line 168 of file ofswitch13-port.h.

Referenced by OFSwitch13Port(), DoDispose(), GetPortStruct(), NotifyConstructionCompleted(), PortUpdateState(), Receive(), and Send().

◆ m_txTrace

TracedCallback<Ptr<const Packet> > ns3::OFSwitch13Port::m_txTrace
private

Trace source fired when a packet will be sent over this switch port.

Definition at line 164 of file ofswitch13-port.h.

Referenced by GetTypeId(), and Send().


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