00001
00002
00003
00004
00005
00006
00007 #ifndef _Q
00008 #define _Q
00009
00010 #ifdef __cplusplus
00011 extern "C" {
00012 #endif
00013
00014 #include "nm.h"
00015 #include "pkt.h"
00016
00017
00018
00019
00020
00021
00022 typedef enum
00023 {
00024 QDrr_c
00025 } QTypes_c;
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 struct Q_Cos_t
00040 {
00041 int numClasses;
00042 lsList *packetQueueArray;
00043
00044
00045
00046 int numPktsInQueue;
00047 };
00048
00049 typedef struct Q_Cos_t Q_Cos_t;
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 struct Q_Drr_t
00062 {
00063 st_table *flowToQueueTable;
00064 lsList qOfFlows;
00065 int numPktsInQueue;
00066 int numBytesInQueue;
00067 };
00068
00069 typedef struct Q_Drr_t Q_Drr_t;
00070
00071
00072
00073
00074
00075
00076
00077 struct Q_Flow_t
00078 {
00079 lsList queue;
00080 unsigned int numBytes;
00081 unsigned int numPkts;
00082 double rate;
00083 util_timing_t startOfCurrentWindow;
00084 double numBytesExitedInWindow;
00085
00086 };
00087
00088 typedef struct Q_Flow_t Q_Flow_t;
00089
00090
00091
00092
00093
00094
00095
00096
00097 typedef enum
00098 {
00099 Q_DropTail_c,
00100 Q_DropRed_c
00101 } Q_DropMethods_t;
00102
00103
00104
00105
00106
00107 typedef enum
00108 {
00109 Q_QueueTypeUndef_c,
00110 Q_QueueTypeCos_c,
00111 Q_QueueTypeFlow_c
00112 } Q_QueueType_t;
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 struct Q_Q_t
00123 {
00124 char *name;
00125
00126
00127 Q_QueueType_t type;
00128
00129
00130 Pkt_FlowType_t flowType;
00131 int flowMaxRate;
00132 int maxFlows;
00133 int maxBytesPerFlow;
00134 Q_DropMethods_t flowDropMethod;
00135
00136 int maxRate;
00137
00138 double currentRate;
00139 util_timing_t lastEntryTime;
00140
00141 int currentPriority;
00142
00143 int assignedPriority;
00144
00145 int numPktsInQueue;
00146 double numPktsProcessed;
00147
00148 int numBytesInQueue;
00149 int maxAllowedBytes;
00150 double numBytesEntered;
00151 double numBytesExited;
00152
00153 Q_DropMethods_t dropMethod;
00154
00155
00156 int numClasses;
00157 Q_Cos_t *cosQ;
00158
00159
00160 Q_Drr_t *flowQ;
00161
00162 double timeWindowDuration;
00163 double numBytesExitedInWindow;
00164 util_timing_t startOfCurrentWindow;
00165
00166 };
00167
00168 typedef struct Q_Q_t Q_Q_t;
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 extern Q_Cos_t *Q_CosAlloc (int);
00179 extern int Q_CosFree (Q_Cos_t *);
00180 extern Q_Drr_t
00181 *Q_DrrAlloc (int (*flowCmp) (Pkt_EthernetHdr_t *, Pkt_EthernetHdr_t *),
00182 int (*flowHash) (Pkt_EthernetHdr_t *, int));
00183 extern int Q_DrrFree (Q_Drr_t * aDrrStruct);
00184 extern int Q_CosInsertPpBegin( Q_Cos_t *cosStruct, Pkt_ProcessPkt_t *anEthFrame, int classIndex );
00185 extern int Q_CosInsertPpEnd (Q_Cos_t *, Pkt_ProcessPkt_t *, int);
00186 extern int Q_CosInsertPpBeginEnd (Q_Cos_t *, Pkt_ProcessPkt_t *, int, int );
00187 extern Pkt_ProcessPkt_t *Q_CosReadPp (Q_Cos_t * cosStruct);
00188 extern Pkt_ProcessPkt_t *Q_CosReadHead (Q_Cos_t * cosStruct, int *classPtr);
00189 extern Pkt_ProcessPkt_t *Q_CosHead (Q_Cos_t * cosStruct, int *classPtr);
00190 extern Pkt_ProcessPkt_t *Q_CosHeadClass (Q_Cos_t * cosStruct, int classIndex);
00191 extern int Q_CosNumClasses (Q_Cos_t * cosStruct);
00192 extern int Q_DrrTestIsEmpty (Q_Drr_t * flowQueue);
00193 extern int Q_CosTestIsEmpty (Q_Cos_t * cosStruct);
00194 extern int Q_DrrInsertPpBegin (Q_Drr_t * drrStruct, Pkt_ProcessPkt_t * pp);
00195 extern int Q_DrrInsertPpEnd (Q_Drr_t * drrStruct, Pkt_ProcessPkt_t * pp);
00196 extern int Q_DrrInsertPpBeginEnd (Q_Drr_t * drrStruct, Pkt_ProcessPkt_t * pp,
00197 int insertAtEnd);
00198 extern Q_Flow_t *Q_DrrReadFlow (Q_Drr_t * drrStruct, Pkt_EthernetHdr_t * pkt);
00199 extern Pkt_ProcessPkt_t *Q_DrrHead (Q_Drr_t * drrStruct);
00200 extern Pkt_ProcessPkt_t *Q_DrrReadHead (Q_Drr_t * drrStruct);
00201 extern st_table *Q_DrrReadFlowToQueueTable (Q_Drr_t * drrStruct);
00202 extern int Q_DrrNumFlows (Q_Drr_t * drrStruct);
00203 extern void Q_CosPrint (Q_Cos_t * cosData);
00204 extern void Q_DrrPrint (Q_Drr_t * drrData);
00205 extern Q_Flow_t *Q_AllocFlow ();
00206 extern double Q_ComputeRate (util_timing_t startOfWindow,
00207 double timeWindowDuration,
00208 int numBytesExitedInWindow, int pktLength);
00209 extern double Q_ComputeRateOld (util_timing_t lastTime,
00210 Pkt_EthernetHdr_t * pkt);
00211 extern Q_Q_t *Q_AllocQ (char *name);
00212
00213
00214 #ifdef __cplusplus
00215 }
00216 #endif
00217
00218 #endif