Azinix

q.c File Reference

Queueing code. More...

#include "q.h"

Go to the source code of this file.

Functions

Q_Cos_tQ_CosAlloc (int N)
 Allocate and initialize the class of service structure.
int Q_CosFree (Q_Cos_t *aCosStructure)
 Free the class of service structure.
Q_Drr_tQ_DrrAlloc (int(*flowCmp)(Pkt_EthernetHdr_t *, Pkt_EthernetHdr_t *), int(*flowHash)(Pkt_EthernetHdr_t *, int))
 Allocate and initialize the Drr structure. Pass in the function used to hash the packet.
int Q_DrrFree (Q_Drr_t *aDrrStruct)
 Free the Drr structure.
int Q_CosInsertPpBegin (Q_Cos_t *cosStruct, Pkt_ProcessPkt_t *anEthFrame, int classIndex)
 Insert an Ethernet frame into the Cos structure Return 1 on succ, 0 on failure.
int Q_CosInsertPpEnd (Q_Cos_t *cosStruct, Pkt_ProcessPkt_t *anEthFrame, int classIndex)
 Insert an Ethernet frame into the Cos structure Return 1 on succ, 0 on failure.
int Q_CosInsertPpBeginEnd (Q_Cos_t *cosStruct, Pkt_ProcessPkt_t *anEthFrame, int classIndex, int insertAtEnd)
 Insert an Ethernet frame into the Cos structure Return 1 on succ, 0 on failure.
Pkt_ProcessPkt_tQ_CosReadPp (Q_Cos_t *cosStruct)
 Read an ethernet frame from the Cos structure.
Pkt_ProcessPkt_tQ_CosReadHead (Q_Cos_t *cosStruct, int *classPtr)
 Read the head of the queue - queue IS NOT updated.
Pkt_ProcessPkt_tQ_CosHead (Q_Cos_t *cosStruct, int *classPtr)
 Return the head of the queue - queue IS updated.
Pkt_ProcessPkt_tQ_CosHeadClass (Q_Cos_t *cosStruct, int classIndex)
 Return the head of the i-th queue - queue is updated.
int Q_CosNumClasses (Q_Cos_t *cosStruct)
 Read the number of classes in a cosStruct.
int Q_DrrTestIsEmpty (Q_Drr_t *flowQueue)
 Return 1 if the queue is emtpy, 0 otherwise.
int Q_CosTestIsEmpty (Q_Cos_t *cosStruct)
 Return 1 if the queue is emtpy, 0 otherwise.
int Q_DrrInsertPpBegin (Q_Drr_t *drrStruct, Pkt_ProcessPkt_t *pp)
 Insert a Pkt_ProcessPkt_t * into a drrStruct, add to beginning.
int Q_DrrInsertPpEnd (Q_Drr_t *drrStruct, Pkt_ProcessPkt_t *pp)
 Insert a Pkt_ProcessPkt_t * into a drrStruct, add to end.
int Q_DrrInsertPpBeginEnd (Q_Drr_t *drrStruct, Pkt_ProcessPkt_t *pp, int insertAtEnd)
 Insert a Pkt_ProcessPkt_t * into a drrStruct.
Q_Flow_tQ_DrrReadFlow (Q_Drr_t *drrStruct, Pkt_EthernetHdr_t *pkt)
 Get flow associated with pkt.
Pkt_ProcessPkt_tQ_DrrHead (Q_Drr_t *drrStruct)
 Get the head from the Drr structure.
Pkt_ProcessPkt_tQ_DrrReadHead (Q_Drr_t *drrStruct)
 Read the head from the Drr structure. Does not change the state of the queue.
st_tableQ_DrrReadFlowToQueueTable (Q_Drr_t *drrStruct)
 Read the flowToQueue table for a given Drr structure.
int Q_DrrNumFlows (Q_Drr_t *drrStruct)
 Return the number of flows currently in the drr struct.
void Q_CosPrint (Q_Cos_t *cosData)
 Print elementary data about a COS structure.
void Q_DrrPrint (Q_Drr_t *drrData)
 Print elementary data about a DRR structure.
Q_Flow_tQ_AllocFlow ()
 Allocate a flow structure.
double Q_ComputeRate (util_timing_t startOfWindow, double timeWindowDuration, int numBytesExitedInWindow, int pktLength)
 Get the new rate - uses a windowing approach.
double Q_ComputeRateOld (util_timing_t lastTime, Pkt_EthernetHdr_t *pkt)
 Get the new rate for this flow - uses an IIR averaging approach.
Q_Q_tQ_AllocQ (char *name)
 Allocate a Q_Q_t structure.


Detailed Description

Queueing code.

Definition in file q.c.


Function Documentation

Q_Flow_t* Q_AllocFlow (  ) 

Allocate a flow structure.

Definition at line 612 of file q.c.

Q_Q_t* Q_AllocQ ( char *  name  ) 

Allocate a Q_Q_t structure.

Definition at line 754 of file q.c.

double Q_ComputeRate ( util_timing_t  startOfWindow,
double  timeWindowDuration,
int  numBytesExitedInWindow,
int  pktLength 
)

Get the new rate - uses a windowing approach.

Definition at line 631 of file q.c.

double Q_ComputeRateOld ( util_timing_t  lastTime,
Pkt_EthernetHdr_t pkt 
)

Get the new rate for this flow - uses an IIR averaging approach.

Definition at line 659 of file q.c.

Q_Cos_t* Q_CosAlloc ( int   ) 

Allocate and initialize the class of service structure.

AutomaticStart

Definition at line 32 of file q.c.

int Q_CosFree ( Q_Cos_t aCosStructure  ) 

Free the class of service structure.

Definition at line 57 of file q.c.

Pkt_ProcessPkt_t* Q_CosHead ( Q_Cos_t cosStruct,
int *  classPtr 
)

Return the head of the queue - queue IS updated.

Definition at line 273 of file q.c.

Pkt_ProcessPkt_t* Q_CosHeadClass ( Q_Cos_t cosStruct,
int  classIndex 
)

Return the head of the i-th queue - queue is updated.

Useful when we have a set of independent queues.

Definition at line 306 of file q.c.

int Q_CosInsertPpBegin ( Q_Cos_t cosStruct,
Pkt_ProcessPkt_t anEthFrame,
int  classIndex 
)

Insert an Ethernet frame into the Cos structure Return 1 on succ, 0 on failure.

Definition at line 133 of file q.c.

int Q_CosInsertPpBeginEnd ( Q_Cos_t cosStruct,
Pkt_ProcessPkt_t anEthFrame,
int  classIndex,
int  insertAtEnd 
)

Insert an Ethernet frame into the Cos structure Return 1 on succ, 0 on failure.

The packet is specified via its pointer. We need its class of service, with 0 being the highest.

We can overload this operation to insert into a nonCOS queue, specifically a queue which is used logically to provide protection for one set of flows against another.

Definition at line 171 of file q.c.

int Q_CosInsertPpEnd ( Q_Cos_t cosStruct,
Pkt_ProcessPkt_t anEthFrame,
int  classIndex 
)

Insert an Ethernet frame into the Cos structure Return 1 on succ, 0 on failure.

Definition at line 146 of file q.c.

int Q_CosNumClasses ( Q_Cos_t cosStruct  ) 

Read the number of classes in a cosStruct.

Definition at line 323 of file q.c.

void Q_CosPrint ( Q_Cos_t cosData  ) 

Print elementary data about a COS structure.

Use more as a sanity check then for detailed statistics.

Definition at line 559 of file q.c.

Pkt_ProcessPkt_t* Q_CosReadHead ( Q_Cos_t cosStruct,
int *  classPtr 
)

Read the head of the queue - queue IS NOT updated.

Definition at line 240 of file q.c.

Pkt_ProcessPkt_t* Q_CosReadPp ( Q_Cos_t cosStruct  ) 

Read an ethernet frame from the Cos structure.

The packet returned is NIL if there are no packets; otherwise it's

Definition at line 209 of file q.c.

int Q_CosTestIsEmpty ( Q_Cos_t cosStruct  ) 

Return 1 if the queue is emtpy, 0 otherwise.

Definition at line 341 of file q.c.

Q_Drr_t* Q_DrrAlloc ( int(*)(Pkt_EthernetHdr_t *, Pkt_EthernetHdr_t *)  flowCmp,
int(*)(Pkt_EthernetHdr_t *, int)  flowHash 
)

Allocate and initialize the Drr structure. Pass in the function used to hash the packet.

See also:
Q_SrcIpHash

Q_DestIpHash

Q_DestIpHash

Q_SrcDestIpHash

Q_SrcDestTcpIpHash

Definition at line 84 of file q.c.

int Q_DrrFree ( Q_Drr_t aDrrStruct  ) 

Free the Drr structure.

Definition at line 107 of file q.c.

Pkt_ProcessPkt_t* Q_DrrHead ( Q_Drr_t drrStruct  ) 

Get the head from the Drr structure.

The packet returned is NIL if there are no packets. For now, we're simply implementing plain round robin, not deficit round robin.

We keep a queue of the next flow to service - head is current high priority, and is moved to the tail if it's nonempty. If it is empty we remove the corresponding entry from the hash table, then free the queue.

This is only RR, and to implement DRR, the qOfFlow's becomes a heap, with the heap value being the current deficit, calculated based on packet lengths.

Definition at line 447 of file q.c.

int Q_DrrInsertPpBegin ( Q_Drr_t drrStruct,
Pkt_ProcessPkt_t pp 
)

Insert a Pkt_ProcessPkt_t * into a drrStruct, add to beginning.

Definition at line 350 of file q.c.

int Q_DrrInsertPpBeginEnd ( Q_Drr_t drrStruct,
Pkt_ProcessPkt_t pp,
int  insertAtEnd 
)

Insert a Pkt_ProcessPkt_t * into a drrStruct.

Definition at line 368 of file q.c.

int Q_DrrInsertPpEnd ( Q_Drr_t drrStruct,
Pkt_ProcessPkt_t pp 
)

Insert a Pkt_ProcessPkt_t * into a drrStruct, add to end.

Definition at line 359 of file q.c.

int Q_DrrNumFlows ( Q_Drr_t drrStruct  ) 

Return the number of flows currently in the drr struct.

Definition at line 543 of file q.c.

void Q_DrrPrint ( Q_Drr_t drrData  ) 

Print elementary data about a DRR structure.

Definition at line 581 of file q.c.

Q_Flow_t* Q_DrrReadFlow ( Q_Drr_t drrStruct,
Pkt_EthernetHdr_t pkt 
)

Get flow associated with pkt.

Definition at line 416 of file q.c.

st_table* Q_DrrReadFlowToQueueTable ( Q_Drr_t drrStruct  ) 

Read the flowToQueue table for a given Drr structure.

Definition at line 531 of file q.c.

Pkt_ProcessPkt_t* Q_DrrReadHead ( Q_Drr_t drrStruct  ) 

Read the head from the Drr structure. Does not change the state of the queue.

Definition at line 502 of file q.c.

int Q_DrrTestIsEmpty ( Q_Drr_t flowQueue  ) 

Return 1 if the queue is emtpy, 0 otherwise.

Definition at line 332 of file q.c.