20 #ifndef OFSWITCH13_CONTROLLER_H
21 #define OFSWITCH13_CONTROLLER_H
26 #include <ns3/application.h>
27 #include <ns3/socket.h>
83 enum ofp_controller_role
m_role;
184 int DpctlExecute(uint64_t dpId,
const std::string textCmd);
196 struct ofl_msg_header* msg);
231 struct ofl_msg_header* msg,
293 virtual ofl_err
HandleError(
struct ofl_msg_error* msg,
314 struct ofl_msg_multipart_reply_header* msg,
323 struct ofl_msg_queue_get_config_reply* msg,
a polymophic address class
The base class for all ns3 applications.
Ipv4 addresses are stored in host order in this class.
Inner class to save pending commands waiting for handshake procedure.
PendingCommands()
Default (empty) constructor.
std::queue< std::string > m_queue
Queue of pending dpctl commands.
Inner class to save information of a remote active OpenFlow switch connected to this controller.
uint32_t m_capabilities
Bitmap of support ofp_capabilities.
RemoteSwitch()
Default (empty) constructor.
Ipv4Address GetIpv4() const
Get the IP from socket connection address.
Ptr< OFSwitch13Controller > m_ctrlApp
Controller application.
uint8_t m_auxiliaryId
Identify auxiliary connections.
Address m_address
Switch connection address.
enum ofp_controller_role m_role
Controller role over switch.
Ptr< OFSwitch13SocketHandler > m_handler
Socket handler.
uint16_t GetPort() const
Get the port from socket connection address.
uint32_t m_nBuffers
Switch features informed to the controller during handshake procedure.
uint64_t GetDpId() const
Get the datapath ID.
uint64_t m_dpId
OpenFlow datapath ID.
uint8_t m_nTables
Number of tables supported by datapath.
OpenFlow 1.3 controller base class that can handle a collection of OpenFlow switches and provides the...
std::map< uint32_t, EchoInfo > EchoMsgMap_t
Map to store echo information by transaction id.
void StopApplication() override
Application specific shutdown code.
OFSwitch13Controller()
Default constructor.
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.
std::map< Address, Ptr< RemoteSwitch > > AddrSwMap_t
Map to store switch info by ip address.
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.
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.
virtual void HandshakeSuccessful(Ptr< const RemoteSwitch > swtch)
Function invoked after a successfully handshake procedure between this controller and a remote switch...
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.
void SocketPeerError(Ptr< Socket > socket)
TCP connection error.
AddrSwMap_t m_addrSwMap
Registered switches by address.
void SocketAccept(Ptr< Socket > socket, const Address &from)
TCP handshake succeeded.
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.
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.
void StartApplication() override
Application specific startup code.
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/dpc...
void SocketPeerClose(Ptr< Socket > socket)
TCP connection closed.
uint32_t m_xid
Global transaction idx.
~OFSwitch13Controller() override
Dummy destructor, see DoDispose.
void ReceiveFromSwitch(Ptr< Packet > packet, Address from)
Receive an OpenFlow packet from switch.
std::map< uint64_t, Ptr< PendingCommands > > DpIdCmdMap_t
Map saving pair <datapath id / pending commands>
void SendEchoRequest(Ptr< const RemoteSwitch > swtch, size_t payloadSize=0)
Send an echo request message to switch, and wait for a non-blocking reply.
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.
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.
Ptr< Socket > m_serverSocket
Listening server socket.
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.
bool SocketRequest(Ptr< Socket > socket, const Address &from)
TCP request from switch.
uint16_t m_port
Local controller tcp port.
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.
ofl_err HandleSwitchMsg(struct ofl_msg_header *msg, Ptr< RemoteSwitch > swtch, uint32_t xid)
Called when an OpenFlow message is received from a switch.
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.
static TypeId GetTypeId()
Register this type.
int SendToSwitch(Ptr< const RemoteSwitch > swtch, struct ofl_msg_header *msg, uint32_t xid=0)
Send a OFLib message to a registered switch.
void SendBarrierRequest(Ptr< const RemoteSwitch > swtch)
Send a barrier request message to switch, and wait for a non-blocking reply.
EchoMsgMap_t m_echoMap
Metadata for echo requests.
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.
Ptr< const RemoteSwitch > GetRemoteSwitch(uint64_t dpId) const
Get the remote switch for this OpenFlow datapath ID.
std::map< uint32_t, BarrierInfo > BarrierMsgMap_t
Map to store barrier information by transaction id.
BarrierMsgMap_t m_barrierMap
Metadata for barrier requests.
DpIdCmdMap_t m_commandsMap
Commands scheduled for execution.
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.
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.
int DpctlExecute(uint64_t dpId, const std::string textCmd)
Execute a dpctl command to interact with the remote switch.
std::map< uint64_t, Ptr< RemoteSwitch > > DpIdSwMap_t
Map to store switch info by datapath id.
void DoDispose() override
Destructor implementation.
DpIdSwMap_t m_dpIdSwMap
Registered switches by datapath id.
Smart pointer class similar to boost::intrusive_ptr.
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure to save barrier metadata used by the controller interface.
Ptr< const RemoteSwitch > m_swtch
Remote switch.
bool m_waiting
True when waiting for reply.
BarrierInfo(Ptr< const RemoteSwitch > swtch)
Complete constructor, with remote switch.
Structure to save echo request metadata used by the controller interface.
Time m_recv
Received time.
bool m_waiting
True when waiting for reply.
Ptr< const RemoteSwitch > m_swtch
Remote switch.
Time GetRtt() const
Compute the echo RTT time.
EchoInfo(Ptr< const RemoteSwitch > swtch)
Complete constructor, with remote switch.