25 #include "ns3/object-vector.h"
26 #include "ns3/string.h"
28 #undef NS_LOG_APPEND_CONTEXT
29 #define NS_LOG_APPEND_CONTEXT \
30 std::clog << "[dp " << m_dpId << " port " << m_portNo << "] ";
42 TypeId(
"ns3::OFSwitch13Queue")
44 .SetGroupName(
"OFSwitch13")
45 .AddAttribute(
"QueueList",
46 "The list of internal queues.",
49 MakeObjectVectorChecker<Queue<Packet>>());
75 int queueId =
static_cast<int>(queueTag.
GetQueueId());
77 NS_LOG_DEBUG(
"Packet to be enqueued in queue " << queueId);
79 struct sw_queue* swQueue;
80 swQueue = dp_ports_lookup_queue(
m_swPort, queueId);
83 bool retval =
GetQueue(queueId)->Enqueue(packet);
86 swQueue->stats->tx_packets++;
87 swQueue->stats->tx_bytes += packet->
GetSize();
92 DoEnqueue(GetContainer().end(), packet);
96 NS_LOG_DEBUG(
"Packet enqueue dropped by internal queue " << queueId);
97 swQueue->stats->tx_errors++;
101 DropBeforeEnqueue(packet);
137 struct sw_queue* swQueue;
138 for (
int queueId = 0; queueId <
GetNQueues(); queueId++)
140 swQueue = &(
m_swPort->queues[queueId]);
141 free(swQueue->stats);
142 free(swQueue->props);
169 uint32_t queueId = (
m_swPort->num_queues)++;
170 struct sw_queue* swQueue = &(
m_swPort->queues[queueId]);
177 size_t oflQueueStatsSize =
sizeof(
struct ofl_queue_stats);
178 swQueue->stats = (
struct ofl_queue_stats*)xmalloc(oflQueueStatsSize);
179 memset(swQueue->stats, 0x00, oflQueueStatsSize);
180 swQueue->stats->port_no =
m_swPort->conf->port_no;
181 swQueue->stats->queue_id = queueId;
183 size_t oflPacketQueueSize =
sizeof(
struct ofl_packet_queue);
184 swQueue->props = (
struct ofl_packet_queue*)xmalloc(oflPacketQueueSize);
185 swQueue->props->queue_id = queueId;
186 swQueue->props->properties_num = 0;
202 for (
auto it = GetContainer().begin(); it != GetContainer().end(); it++)
210 NS_LOG_WARN(
"Packet was not found on this queue.");
220 for (
auto it = GetContainer().begin(); it != GetContainer().end(); it++)
228 NS_LOG_WARN(
"Packet was not found on this queue.");
static TypeId GetTypeId()
Register this type.
void NotifyRemove(Ptr< Packet > packet)
Notify the parent class of a packet removed from any internal queue.
uint32_t AddQueue(Ptr< Queue< Packet >> queue)
Add a new internal queue to this OpenFlow queue interface.
void NotifyDequeue(Ptr< Packet > packet)
Notify the parent class of a packet dequeued from any internal queue.
Ptr< Queue< Packet > > GetQueue(int queueId) const
Get a pointer to internal queue with specific id.
bool Enqueue(Ptr< Packet > packet) override
QueueList_t m_queues
List of internal queues.
void DoDispose() override
Destructor implementation.
int GetNQueues() const
Get the number of internal queues.
OFSwitch13Queue()
Default constructor.
struct sw_port * m_swPort
BOFUSS port structure.
void SetPortStruct(struct sw_port *port)
Set the pointer to the internal BOFUSS port structure.
void DoInitialize() override
uint64_t m_dpId
OpenFlow datapath ID.
~OFSwitch13Queue() override
Dummy destructor, see DoDispose.
uint32_t m_portNo
OpenFlow port number.
virtual void DoInitialize()
Initialize() implementation.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Template class for packet Queues.
void DoDispose() override
Destructor implementation.
Tag used to hold the queue id before enqueueing a packet into OFSwitch13Queue.
uint32_t GetQueueId() const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
ObjectPtrContainerValue ObjectVectorValue
ObjectVectorValue is an alias for ObjectPtrContainerValue.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_TEMPLATE_DEFINE(name)
Initialize a reference to a Log component.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
long long int time_msec(void)
Overriding BOFUSS time_msec weak function from timeval.c.