20 #ifndef OFSWITCH13_DEVICE_H
21 #define OFSWITCH13_DEVICE_H
26 #include <ns3/inet-socket-address.h>
27 #include <ns3/socket.h>
28 #include <ns3/string.h>
29 #include <ns3/tcp-header.h>
30 #include <ns3/traced-value.h>
31 #include <ns3/uinteger.h>
128 bool HasId(uint64_t
id);
233 uint64_t tunnelId = 0);
271 struct remote* remote);
306 struct meter_entry* entry);
421 uint64_t cookie = 0);
434 uint32_t queueNo = 0);
444 uint64_t tunnelId = 0);
477 struct ofpbuf* buffer,
478 struct sender* senderCtrl);
520 struct meter_entry* entry);
529 struct flow_table* table);
573 struct remote* remote);
611 typedef std::vector<Ptr<OFSwitch13Device::RemoteController>>
CtrlList_t;
a polymophic address class
Class for representing data rates.
Inner class to save information of a remote active controller connected to this OpenFlow switch.
RemoteController()
Default (empty) constructor.
struct remote * m_remote
Library remote struct.
Ptr< OFSwitch13SocketHandler > m_handler
Socket handler.
Address m_address
Controller address.
Ptr< Socket > m_socket
TCP socket to controller.
An OpenFlow 1.3 device that switches multiple CSMA segments via OpenFlow protocol.
CtrlList_t m_controllers
Collection of active controllers.
struct datapath * GetDatapathStruct()
Get a pointer to the internal BOFUSS datapath structure.
Ptr< OFSwitch13Port > GetSwitchPort(uint32_t no) const
Get the OFSwitch13Port pointer from its number.
std::vector< Ptr< OFSwitch13Port > > PortList_t
Structure to save the list of ports in this datapath.
static void BufferSaveCallback(struct packet *pkt, time_t timeout)
Callback fired when a packet is saved into buffer.
void SocketCtrlFailed(Ptr< Socket > socket)
Socket callback fired when a TCP connection to controller fail.
double GetCpuUsage() const
TracedCallback signature for packets dropped by meter bands.
std::string m_libLog
The BOFUSS library log level.
uint32_t GetBufferEntries() const
TracedCallback signature for packets dropped by meter bands.
uint32_t m_numPipeTabs
Number of pipeline flow tables.
uint64_t m_cpuConsumed
CPU processing tokens consumed.
uint32_t GetGroupTableSize() const
TracedCallback signature for packets dropped by meter bands.
IdPacketMap_t m_bufferPkts
Packets saved in switch buffer.
TracedCallback< Ptr< const Packet > > m_pipePacketTrace
Trace source fired when a packet is sent to pipeline.
uint32_t GetFlowTableEntries(uint8_t tableId) const
TracedCallback signature for packets dropped by meter bands.
TracedValue< DataRate > m_cpuLoad
Average CPU processing load.
uint32_t GetMeterTableSize() const
TracedCallback signature for packets dropped by meter bands.
void SetFlowTableSize(uint8_t tableId, uint32_t value)
Structure to save the list of ports in this datapath.
void DoDispose() override
TracedCallback signature for packets dropped by meter bands.
uint32_t GetNSwitchPorts() const
TracedCallback signature for packets dropped by meter bands.
static void PacketDestroyCallback(struct packet *pkt)
Callback fired when a packet is destroyed.
double GetBufferUsage() const
TracedCallback signature for packets dropped by meter bands.
PipelinePacket m_pipePkt
Packet under switch pipeline.
Ptr< OFSwitch13Device::RemoteController > GetRemoteController(Ptr< Socket > socket)
Get the remote controller for this socket.
void SendToPipeline(Ptr< Packet > packet, uint32_t portNo, uint64_t tunnelId=0)
Send the packet to the OpenFlow BOFUSS pipeline.
void NotifyPacketDroppedByMeter(struct packet *pkt, struct meter_entry *entry)
Notify this device of a packet dropped by OpenFlow meter band.
double GetFlowTableUsage(uint8_t tableId) const
TracedCallback signature for packets dropped by meter bands.
void DatapathTimeout(struct datapath *dp)
Check if any flow in any table is timed out and update port status.
void SocketCtrlSucceeded(Ptr< Socket > socket)
Socket callback fired when a TCP connection to controller succeed.
uint64_t GetFlowModCounter() const
TracedCallback< Ptr< const OFSwitch13Device > > m_datapathTimeoutTrace
Trace source fired when the datapath timeout operation is completed.
Time GetDatapathTimeout() const
TracedCallback signature for packets dropped by meter bands.
void ReceiveFromSwitchPort(Ptr< Packet > packet, uint32_t portNo, uint64_t tunnelId=0)
Called when a packet is received on one of the switch's ports.
void ReceiveFromController(Ptr< Packet > packet, Address from)
Receive an OpenFlow packet from controller.
uint32_t GetNControllers() const
TracedCallback signature for packets dropped by meter bands.
static Ptr< OFSwitch13Device > GetDevice(uint64_t id)
Retrieve and existing OpenFlow device object by its datapath ID.
TracedCallback< Ptr< const Packet >, uint8_t > m_tableDropTrace
Trace source fired when an unmatched packet is dropped by flow table.
static void MeterCreatedCallback(struct meter_entry *entry)
Callback fired when a new meter entry is created at meter table.
OFSwitch13Device()
Default constructor.
double GetMeterTableUsage() const
TracedCallback signature for packets dropped by meter bands.
PortList_t m_ports
List of switch ports.
double GetGroupTableUsage() const
TracedCallback signature for packets dropped by meter bands.
void BufferPacketSave(uint64_t packetId, time_t timeout)
Notify this device of a packet saved into buffer.
void NotifyMeterEntryCreated(struct meter_entry *entry)
Notify this device of a new meter entry created at meter table.
void NotifyPacketCloned(struct packet *pkt, struct packet *clone)
Notify this device of a packet cloned by the OpenFlow pipeline.
static void RegisterDatapath(uint64_t id, Ptr< OFSwitch13Device > dev)
Insert a new OpenFlow device in global map.
uint32_t GetGroupTableEntries() const
TracedCallback signature for packets dropped by meter bands.
Time m_timeout
Datapath timeout interval.
static uint64_t m_globalDpId
Global counter for datapath IDs.
DataRate GetCpuLoad() const
TracedCallback signature for packets dropped by meter bands.
TracedValue< uint32_t > m_groupEntries
Number of entries in group table.
TracedCallback< Ptr< const Packet > > m_bufferSaveTrace
Trace source fired when a packet is saved into buffer.
void StartControllerConnection(Address ctrlAddr)
Starts the TCP connection between this switch and the target controller indicated by the address para...
void NotifyPacketDestroyed(struct packet *pkt)
Notify this device of a packet destroyed by the OpenFlow pipeline.
TracedCallback< Ptr< const Packet > > m_loadDropTrace
Trace source fired when a packet is dropped due to overloaded switch.
void BufferPacketRetrieve(uint64_t packetId)
Notify this device of a packet retrieved from buffer.
Ptr< OFSwitch13Port > AddSwitchPort(Ptr< NetDevice > portDevice)
Add a 'port' to the switch device.
uint64_t m_cGroupMod
Pipeline group mod counter.
static uint64_t m_globalPktId
Global counter for packets IDs.
uint64_t m_cPacketIn
Pipeline packet in counter.
DataRate GetCpuCapacity() const
TracedCallback signature for packets dropped by meter bands.
Time m_tcamDelay
Flow Table TCAM lookup delay.
uint32_t m_meterTabSize
Meter table maximum entries.
int SendPacketInMessage(struct packet *pkt, uint8_t tableId, uint8_t reason, uint16_t maxLength, uint64_t cookie=0)
Create an OpenFlow packet in message and send the packet to all controllers with open connections.
void SetGroupTableSize(uint32_t value)
Structure to save the list of ports in this datapath.
static void BufferRetrieveCallback(struct packet *pkt)
Callback fired when a packet is retrieved from buffer.
TracedValue< uint32_t > m_sumFlowEntries
Sum of entries in all flow tables.
uint32_t GetMeterTableEntries() const
TracedCallback signature for packets dropped by meter bands.
void(* DeviceTracedCallback)(Ptr< const OFSwitch13Device > dev)
TracedCallback signature for OpenFlow switch device.
void NotifyPacketDroppedByTable(struct packet *pkt, struct flow_table *table)
Notify this device of an unmatched packet dropped by OpenFlow flow table without a table-miss entry.
struct datapath * DatapathNew()
Creates a new datapath.
static void MeterDropCallback(struct packet *pkt, struct meter_entry *entry)
Callback fired when a packet is dropped by meter band.
static void UnregisterDatapath(uint64_t id)
Remove an existing OpenFlow device from global map.
static void TableDropCallback(struct packet *pkt, struct flow_table *table)
Callback fired when an unmatched packet is dropped by a flow table without a table-miss entry.
struct datapath * m_datapath
BOFUSS datapath structure.
uint64_t m_cMeterMod
Pipeline meter mod counter.
static uint64_t GetNewPacketId()
Increase the global packet ID counter and return a new packet ID.
~OFSwitch13Device() override
Dummy destructor, see DoDispose.
uint64_t GetPacketInCounter() const
TracedValue< Time > m_pipeDelay
Average delay for pipeline packet processing.
uint64_t GetDatapathId() const
Get the OpenFlow datapath ID.
void NotifyConstructionCompleted() override
TracedCallback signature for packets dropped by meter bands.
uint64_t m_cFlowMod
Pipeline flow mod counter.
int ReplyWithErrorMessage(ofl_err error, struct ofpbuf *buffer, struct sender *senderCtrl)
Create an OpenFlow error message and send it back to the sender controller.
uint32_t m_flowTabSize
Flow table maximum entries.
uint64_t GetPacketOutCounter() const
uint32_t m_groupTabSize
Group table maximum entries.
static bool CopyTags(Ptr< const Packet > srcPkt, Ptr< const Packet > dstPkt)
Copy all tags (packet and byte) from srcPkt packet to dstPkt packet.
static void DpActionsOutputPort(struct packet *pkt, uint32_t outPort, uint32_t outQueue, uint16_t maxLength, uint64_t cookie)
Overriding BOFUSS dp_actions_output_port weak function from udatapath/dp_actions.c.
static int SendOpenflowBufferToRemote(struct ofpbuf *buffer, struct remote *remote)
Overriding BOFUSS send_openflow_buffer_to_remote weak function from udatapath/datapath....
std::map< uint64_t, Ptr< OFSwitch13Device > > DpIdDevMap_t
Structure to map datapath id to OpenFlow device.
std::vector< Ptr< OFSwitch13Device::RemoteController > > CtrlList_t
Structure to save the list of active controllers.
uint32_t m_bufferSize
Buffer size in terms of packets.
static TypeId GetTypeId()
Register this type.
void(* TableDropTracedCallback)(Ptr< const Packet > packet, uint8_t tableId)
TracedCallback signature for unmatched packets dropped by flow tables without table-miss entries.
void BufferPacketDelete(uint64_t packetId)
Delete the ns-3 packet from buffer map.
uint64_t m_cPacketOut
Pipeline packet out counter.
void SetMeterTableSize(uint32_t value)
Structure to save the list of ports in this datapath.
uint64_t GetDpId() const
Alias for the GetDatapathId () method.
uint64_t m_cpuTokens
CPU processing tokens available.
std::map< uint64_t, Ptr< Packet > > IdPacketMap_t
Structure to save packets, indexed by its id.
int SendToController(Ptr< Packet > packet, Ptr< OFSwitch13Device::RemoteController > remoteCtrl)
Send a packet to the controller node.
Time m_lastTimeout
Datapath last timeout.
bool SendToSwitchPort(struct packet *pkt, uint32_t portNo, uint32_t queueNo=0)
Send a message over a specific switch port.
TracedCallback< Ptr< const Packet > > m_bufferRetrieveTrace
Trace source fired when a packet is retrieved from buffer.
uint64_t GetGroupModCounter() const
TracedCallback< Ptr< const Packet > > m_bufferExpireTrace
Trace source fired when a packet in buffer expires.
static void SendPacketToController(struct pipeline *pl, struct packet *pkt, uint8_t tableId, uint8_t reason)
Overriding BOFUSS send_packet_to_controller weak function from udatapath/pipeline....
uint32_t GetNPipelineTables() const
TracedCallback signature for packets dropped by meter bands.
uint32_t GetSumFlowEntries() const
TracedCallback signature for packets dropped by meter bands.
static DpIdDevMap_t m_globalSwitchMap
As the integration of BOFUSS and ns-3 involve overriding some C functions, we are using a global map ...
TracedCallback< Ptr< const Packet >, uint32_t > m_meterDropTrace
Trace source fired when a packet is dropped by a meter band.
uint64_t m_dpId
This datapath id.
uint32_t GetDftFlowTableSize() const
TracedCallback signature for packets dropped by meter bands.
static void PacketCloneCallback(struct packet *pkt, struct packet *clone)
Callback fired when a packet is cloned.
uint32_t GetBufferSize() const
TracedCallback signature for packets dropped by meter bands.
TracedValue< uint32_t > m_meterEntries
Number of entries in meter table.
uint64_t GetMeterModCounter() const
uint32_t GetFlowTableSize(uint8_t tableId) const
TracedCallback signature for packets dropped by meter bands.
Time GetPipelineDelay() const
TracedCallback signature for packets dropped by meter bands.
void SetDftFlowTableSize(uint32_t value)
Structure to save the list of ports in this datapath.
DataRate m_cpuCapacity
CPU processing capacity.
void(* MeterDropTracedCallback)(Ptr< const Packet > packet, uint32_t meterId)
TracedCallback signature for packets dropped by meter bands.
A base class which provides memory management and object aggregation.
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Forward calls to a chain of Callback.
a unique identifier for an interface.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure to save packet metadata while it is under OpenFlow pipeline.
void SetPacket(uint64_t id, Ptr< Packet > packet)
Save packet metadata.
bool DelCopy(uint64_t id)
Delete an existing copy for this packet.
Ptr< Packet > m_packet
Packet pointer.
Ptr< Packet > GetPacket() const
PipelinePacket()
Default (empty) constructor.
bool HasId(uint64_t id)
Check for packet id in the internal list of IDs for this packet.
void Invalidate()
Invalidate packet metatada.
bool IsValid() const
Check for valid packet metadata.
void NewCopy(uint64_t id)
Notify a new copy for this packet, with a new unique ID.
std::list< uint64_t > m_ids
Internal list of IDs for this packet.