#include <dsPolicy.h>
Inheritance diagram for PolicyClassifier:


Public Member Functions | |
| PolicyClassifier () | |
| void | addPolicyEntry (int argc, const char *const *argv) |
| void | addPolicerEntry (int argc, const char *const *argv) |
| void | updatePolicyRTT (int argc, const char *const *argv) |
| double | getCBucket (const char *const *argv) |
| int | mark (Packet *pkt) |
| void | printPolicyTable () |
| void | printPolicerTable () |
Public Attributes | |
| Policy * | policy_pool [MAX_POLICIES] |
Protected Member Functions | |
| policyTableEntry * | getPolicyTableEntry (nsaddr_t source, nsaddr_t dest) |
| policerTableEntry * | getPolicerTableEntry (int policy_index, int oldCodePt) |
Protected Attributes | |
| policyTableEntry | policyTable [MAX_POLICIES] |
| int | policyTableSize |
| policerTableEntry | policerTable [MAX_CP] |
| int | policerTableSize |
|
|
Definition at line 67 of file dsPolicy.cc. References MAX_POLICIES, policerTableSize, policy_pool, and policyTableSize.
00067 {
00068 int i;
00069
00070 policyTableSize = 0;
00071 policerTableSize = 0;
00072
00073 for (i = 0; i < MAX_POLICIES; i++)
00074 policy_pool[i] = NULL;
00075 }
|
|
||||||||||||
|
Definition at line 229 of file dsPolicy.cc. References DUMB, dumbPolicer, EWP, EWPolicer, MAX_CP, policerTable, policerTableSize, policy_pool, SFD, SFDPolicer, SRTCM, srTCMPolicer, TB, tokenBucketPolicer, TRTCM, trTCMPolicer, TSW2CM, TSW2CMPolicer, TSW3CM, and TSW3CMPolicer. Referenced by edgeQueue::command().
00229 {
00230 //int cur_policy;
00231
00232
00233 if (policerTableSize == MAX_CP)
00234 printf("ERROR: Policer Table size limit exceeded.\n");
00235 else {
00236 if (strcmp(argv[2], "Dumb") == 0) {
00237 if(!policy_pool[DUMB])
00238 policy_pool[DUMB] = new DumbPolicy;
00239 policerTable[policerTableSize].policer = dumbPolicer;
00240 policerTable[policerTableSize].policy_index = DUMB;
00241 } else if (strcmp(argv[2], "TSW2CM") == 0) {
00242 if(!policy_pool[TSW2CM])
00243 policy_pool[TSW2CM] = new TSW2CMPolicy;
00244 policerTable[policerTableSize].policer = TSW2CMPolicer;
00245 policerTable[policerTableSize].policy_index = TSW2CM;
00246 } else if (strcmp(argv[2], "TSW3CM") == 0) {
00247 if(!policy_pool[TSW3CM])
00248 policy_pool[TSW3CM] = new TSW3CMPolicy;
00249 policerTable[policerTableSize].policer = TSW3CMPolicer;
00250 policerTable[policerTableSize].policy_index = TSW3CM;
00251 } else if (strcmp(argv[2], "TokenBucket") == 0) {
00252 if(!policy_pool[TB])
00253 policy_pool[TB] = new TBPolicy;
00254 policerTable[policerTableSize].policer = tokenBucketPolicer;
00255 policerTable[policerTableSize].policy_index = TB;
00256 } else if (strcmp(argv[2], "srTCM") == 0) {
00257 if(!policy_pool[SRTCM])
00258 policy_pool[SRTCM] = new SRTCMPolicy;
00259 policerTable[policerTableSize].policer = srTCMPolicer;
00260 policerTable[policerTableSize].policy_index = SRTCM;
00261 } else if (strcmp(argv[2], "trTCM") == 0){
00262 if(!policy_pool[TRTCM])
00263 policy_pool[TRTCM] = new TRTCMPolicy;
00264 policerTable[policerTableSize].policer = trTCMPolicer;
00265 policerTable[policerTableSize].policy_index = TRTCM;
00266 } else if (strcmp(argv[2], "SFD") == 0) {
00267 if(!policy_pool[SFD])
00268 policy_pool[SFD] = new SFDPolicy;
00269 policerTable[policerTableSize].policer = SFDPolicer;
00270 policerTable[policerTableSize].policy_index = SFD;
00271 } else if (strcmp(argv[2], "EW") == 0) {
00272 if(!policy_pool[EWP])
00273 policy_pool[EWP] = new EWPolicy;
00274 policerTable[policerTableSize].policer = EWPolicer;
00275 policerTable[policerTableSize].policy_index = EWP;
00276 } else {
00277 printf("No applicable policer specified, exit!!!\n");
00278 exit(-1);
00279 }
00280 };
00281
00282 policerTable[policerTableSize].initialCodePt = atoi(argv[3]);
00283 policerTable[policerTableSize].downgrade1 = atoi(argv[4]);
00284 if (argc == 6)
00285 policerTable[policerTableSize].downgrade2 = atoi(argv[5]);
00286 policerTableSize++;
00287 }
|
|
||||||||||||
|
Definition at line 95 of file dsPolicy.cc. References DUMB, dumbMeter, dumbPolicer, EWP, EWPolicer, ewTagger, init(), MAX_POLICIES, policy_pool, policyTable, policyTableSize, SFD, SFDPolicer, sfdTagger, SRTCM, srTCMMeter, srTCMPolicer, TB, tokenBucketMeter, tokenBucketPolicer, TRTCM, trTCMMeter, trTCMPolicer, TSW2CM, TSW2CMPolicer, TSW3CM, TSW3CMPolicer, and tswTagger. Referenced by edgeQueue::command().
00095 {
00096 if (policyTableSize == MAX_POLICIES)
00097 printf("ERROR: Policy Table size limit exceeded.\n");
00098 else {
00099 policyTable[policyTableSize].sourceNode = atoi(argv[2]);
00100 policyTable[policyTableSize].destNode = atoi(argv[3]);
00101 policyTable[policyTableSize].codePt = atoi(argv[5]);
00102 policyTable[policyTableSize].arrivalTime = 0;
00103 policyTable[policyTableSize].winLen = 1.0;
00104
00105 if (strcmp(argv[4], "Dumb") == 0) {
00106 if(!policy_pool[DUMB])
00107 policy_pool[DUMB] = new DumbPolicy;
00108 policyTable[policyTableSize].policy_index = DUMB;
00109 policyTable[policyTableSize].policer = dumbPolicer;
00110 policyTable[policyTableSize].meter = dumbMeter;
00111 } else if (strcmp(argv[4], "TSW2CM") == 0) {
00112 if(!policy_pool[TSW2CM])
00113 policy_pool[TSW2CM] = new TSW2CMPolicy;
00114 policyTable[policyTableSize].policy_index = TSW2CM;
00115 policyTable[policyTableSize].policer = TSW2CMPolicer;
00116 policyTable[policyTableSize].meter = tswTagger;
00117
00118 policyTable[policyTableSize].cir =
00119 policyTable[policyTableSize].avgRate = (double) atof(argv[6]) / 8.0;
00120 if (argc == 8) policyTable[policyTableSize].winLen = (double) atof(argv[7]);/* mb */
00121 } else if (strcmp(argv[4], "TSW3CM") == 0) {
00122 if(!policy_pool[TSW3CM])
00123 policy_pool[TSW3CM] = new TSW3CMPolicy;
00124 policyTable[policyTableSize].policy_index = TSW3CM;
00125 policyTable[policyTableSize].policer = TSW3CMPolicer;
00126 policyTable[policyTableSize].meter = tswTagger;
00127
00128 policyTable[policyTableSize].cir =
00129 policyTable[policyTableSize].avgRate = (double) atof(argv[6]) / 8.0;
00130 policyTable[policyTableSize].pir = (double) atof(argv[7]) / 8.0;
00131 } else if (strcmp(argv[4], "TokenBucket") == 0) {
00132 if(!policy_pool[TB])
00133 policy_pool[TB] = (Policy *) new TBPolicy;
00134 policyTable[policyTableSize].policy_index = TB;
00135 policyTable[policyTableSize].policer = tokenBucketPolicer;
00136 policyTable[policyTableSize].meter = tokenBucketMeter;
00137
00138 policyTable[policyTableSize].cir =
00139 policyTable[policyTableSize].avgRate = (double) atof(argv[6]) / 8.0;
00140 policyTable[policyTableSize].cbs =
00141 policyTable[policyTableSize].cBucket = (double) atof(argv[7]);
00142 } else if (strcmp(argv[4], "srTCM") == 0) {
00143 if(!policy_pool[SRTCM])
00144 policy_pool[SRTCM] = new SRTCMPolicy;
00145 policyTable[policyTableSize].policy_index = SRTCM;
00146 policyTable[policyTableSize].policer = srTCMPolicer;
00147 policyTable[policyTableSize].meter = srTCMMeter;
00148
00149 policyTable[policyTableSize].cir =
00150 policyTable[policyTableSize].avgRate = (double) atof(argv[6]) / 8.0;
00151 policyTable[policyTableSize].cbs =
00152 policyTable[policyTableSize].cBucket = (double) atof(argv[7]);
00153 policyTable[policyTableSize].ebs =
00154 policyTable[policyTableSize].eBucket = (double) atof(argv[8]);
00155 } else if (strcmp(argv[4], "trTCM") == 0) {
00156 if(!policy_pool[TRTCM])
00157 policy_pool[TRTCM] = new TRTCMPolicy;
00158 policyTable[policyTableSize].policy_index = TRTCM;
00159 policyTable[policyTableSize].policer = trTCMPolicer;
00160 policyTable[policyTableSize].meter = trTCMMeter;
00161
00162 policyTable[policyTableSize].cir =
00163 policyTable[policyTableSize].avgRate = (double) atof(argv[6]) / 8.0;
00164 policyTable[policyTableSize].cbs =
00165 policyTable[policyTableSize].cBucket = (double) atof(argv[7]);
00166 policyTable[policyTableSize].pir = (double) atof(argv[8]) / 8.0;
00167 policyTable[policyTableSize].pbs =
00168 policyTable[policyTableSize].pBucket = (double) atof(argv[9]);
00169 } else if (strcmp(argv[4], "SFD") == 0) {
00170 if(!policy_pool[SFD])
00171 policy_pool[SFD] = new SFDPolicy;
00172 policyTable[policyTableSize].policy_index = SFD;
00173 policyTable[policyTableSize].policer = SFDPolicer;
00174 policyTable[policyTableSize].meter = sfdTagger;
00175
00176 // Use cir as the transmission size threshold for the moment.
00177 policyTable[policyTableSize].cir = atoi(argv[6]);
00178 } else if (strcmp(argv[4], "EW") == 0) {
00179 if(!policy_pool[EWP])
00180 policy_pool[EWP] = new EWPolicy();
00181
00182 ((EWPolicy *)policy_pool[EWP])->
00183 init(atoi(argv[6]), atoi(argv[7]), atoi(argv[8]));
00184
00185 policyTable[policyTableSize].policy_index = EWP;
00186 policyTable[policyTableSize].policer = EWPolicer;
00187 policyTable[policyTableSize].meter = ewTagger;
00188 } else {
00189 printf("No applicable policy specified, exit!!!\n");
00190 exit(-1);
00191 }
00192 policyTableSize++;
00193 }
00194 }
|
Here is the call graph for this function:

|
|
Definition at line 363 of file dsPolicy.cc. References policyTableEntry::cBucket, getPolicyTableEntry(), policyTableEntry::policer, srTCMPolicer, tokenBucketPolicer, and trTCMPolicer. Referenced by edgeQueue::command().
00363 {
00364 policyTableEntry *policy;
00365
00366 policy = getPolicyTableEntry(atoi(argv[2]), atoi(argv[3]));
00367 if (policy == NULL) {
00368 printf("ERROR: cannot get bucket size; no existing policy found for Source %d-Desination %d.\n",
00369 atoi(argv[2]), atoi(argv[3]));
00370 return(-1);
00371 }
00372 else {
00373 if ((policy->policer == tokenBucketPolicer) || (policy->policer == srTCMPolicer) || (policy->policer == trTCMPolicer))
00374 return(policy->cBucket);
00375 else {
00376 printf("ERROR: cannot get bucket size; the Source %d-Desination %d Policy does not include a Committed Bucket.\n", atoi(argv[2]), atoi(argv[3]));
00377 return(-1);
00378 }
00379 }
00380 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 290 of file dsPolicy.cc. References policerTableEntry::initialCodePt, policerTable, policerTableSize, and policerTableEntry::policy_index. Referenced by mark().
00290 {
00291 for (int i = 0; i < policerTableSize; i++)
00292 if ((policerTable[i].policy_index == policy_index) &&
00293 (policerTable[i].initialCodePt == oldCodePt))
00294 return(&policerTable[i]);
00295
00296 printf("ERROR: No Policer Table entry found for initial code point %d.\n", oldCodePt);
00297 //printPolicerTable();
00298 return(NULL);
00299 }
|
|
||||||||||||
|
Definition at line 204 of file dsPolicy.cc. References ANY_HOST, policyTableEntry::destNode, policyTable, policyTableSize, printPolicyTable(), and policyTableEntry::sourceNode. Referenced by getCBucket(), mark(), and updatePolicyRTT().
00204 {
00205 for (int i = 0; i <= policyTableSize; i++) {
00206 if ((policyTable[i].sourceNode == source) || (policyTable[i].sourceNode == ANY_HOST)) {
00207 if ((policyTable[i].destNode == dest) || (policyTable[i].destNode == ANY_HOST))
00208 return(&policyTable[i]);
00209 }
00210 }
00211
00212 // !!! Could make a default code point for undefined flows:
00213 printf("ERROR: No Policy Table entry found for Source %d-Destination %d.\n", source, dest);
00214 printPolicyTable();
00215 return(NULL);
00216 }
|
Here is the call graph for this function:

|
|
Definition at line 307 of file dsPolicy.cc. References hdr_ip::access(), Policy::applyMeter(), Policy::applyPolicer(), policyTableEntry::codePt, hdr_ip::daddr(), hdr_ip::flowid(), getPolicerTableEntry(), getPolicyTableEntry(), policyTableEntry::policy_index, policy_pool, hdr_ip::prio_, and hdr_ip::saddr(). Referenced by edgeQueue::enque().
00307 {
00308 policyTableEntry *policy;
00309 policerTableEntry *policer;
00310 int policy_index;
00311 int codePt;
00312 hdr_ip* iph;
00313 int fid;
00314
00315 iph = hdr_ip::access(pkt);
00316 fid = iph->flowid();
00317 policy = getPolicyTableEntry(iph->saddr(), iph->daddr());
00318 if (policy) {
00319 codePt = policy->codePt;
00320 policy_index = policy->policy_index;
00321 policer = getPolicerTableEntry(policy_index, codePt);
00322
00323 // bug pointed by Jason Kenney <jason@linear.engmath.dal.ca>
00324 if (policy_pool[policy_index]) {
00325 policy_pool[policy_index]->applyMeter(policy, pkt);
00326 codePt = policy_pool[policy_index]->applyPolicer(policy, policer, pkt);
00327 }
00328 } else {
00329 printf("The policy object doesn't exist, ERROR!!!\n");
00330 exit(-1);
00331 }
00332
00333 iph->prio_ = codePt;
00334 return(codePt);
00335 }
|
Here is the call graph for this function:

|
|
Definition at line 447 of file dsPolicy.cc. References dumbPolicer, EWPolicer, policerTableEntry::policer, policerTable, policerTableSize, SFDPolicer, srTCMPolicer, tokenBucketPolicer, trTCMPolicer, TSW2CMPolicer, and TSW3CMPolicer. Referenced by edgeQueue::command().
00447 {
00448 bool threeColor;
00449
00450 printf("Policer Table:\n");
00451 for (int i = 0; i < policerTableSize; i++) {
00452 threeColor = false;
00453 switch (policerTable[i].policer) {
00454 case dumbPolicer:
00455 printf("Dumb ");
00456 break;
00457 case TSW2CMPolicer:
00458 printf("TSW2CM ");
00459 break;
00460 case TSW3CMPolicer:
00461 printf("TSW3CM ");
00462 threeColor = true;
00463 break;
00464 case tokenBucketPolicer:
00465 printf("Token Bucket ");
00466 break;
00467 case srTCMPolicer:
00468 printf("srTCM ");
00469 threeColor = true;
00470 break;
00471 case trTCMPolicer:
00472 printf("trTCM ");
00473 threeColor = true;
00474 break;
00475 case SFDPolicer:
00476 printf("SFD ");
00477 //printFlowTable();
00478 break;
00479 case EWPolicer:
00480 printf("EW ");
00481 break;
00482 default:
00483 printf("ERROR: Unknown policer type in Policer Table.");
00484 }
00485
00486 if (threeColor) {
00487 printf("policer code point %d is policed to yellow ",
00488 policerTable[i].initialCodePt);
00489 printf("code point %d and red code point %d.\n",
00490 policerTable[i].downgrade1,
00491 policerTable[i].downgrade2);
00492 } else
00493 printf("policer code point %d is policed to code point %d.\n",
00494 policerTable[i].initialCodePt,
00495 policerTable[i].downgrade1);
00496 }
00497 printf("\n");
00498 }
|
|
|
Definition at line 383 of file dsPolicy.cc. References dumbPolicer, EWPolicer, policyTableEntry::policer, policyTable, policyTableSize, SFDPolicer, srTCMPolicer, tokenBucketPolicer, trTCMPolicer, TSW2CMPolicer, and TSW3CMPolicer. Referenced by edgeQueue::command(), and getPolicyTableEntry().
00383 {
00384 printf("Policy Table(%d):\n",policyTableSize);
00385 for (int i = 0; i < policyTableSize; i++)
00386 {
00387 switch (policyTable[i].policer) {
00388 case dumbPolicer:
00389 printf("Flow (%d to %d): DUMB policer, ",
00390 policyTable[i].sourceNode,policyTable[i].destNode);
00391 printf("initial code point %d\n", policyTable[i].codePt);
00392 break;
00393 case TSW2CMPolicer:
00394 printf("Flow (%d to %d): TSW2CM policer, ",
00395 policyTable[i].sourceNode,policyTable[i].destNode);
00396 printf("initial code point %d, CIR %.1f bps.\n",
00397 policyTable[i].codePt, policyTable[i].cir * 8);
00398 break;
00399 case TSW3CMPolicer:
00400 printf("Flow (%d to %d): TSW3CM policer, initial code ",
00401 policyTable[i].sourceNode, policyTable[i].destNode);
00402 printf("point %d, CIR %.1f bps, PIR %.1f bytes.\n",
00403 policyTable[i].codePt, policyTable[i].cir * 8,
00404 policyTable[i].pir * 8);
00405 break;
00406 case tokenBucketPolicer:
00407 printf("Flow (%d to %d): Token Bucket policer, ",
00408 policyTable[i].sourceNode,policyTable[i].destNode);
00409 printf("initial code point %d, CIR %.1f bps, CBS %.1f bytes.\n",
00410 policyTable[i].codePt, policyTable[i].cir * 8,
00411 policyTable[i].cbs);
00412 break;
00413 case srTCMPolicer:
00414 printf("Flow (%d to %d): srTCM policer, initial code ",
00415 policyTable[i].sourceNode, policyTable[i].destNode);
00416 printf("point %d, CIR %.1f bps, CBS %.1f bytes, EBS %.1f bytes.\n",
00417 policyTable[i].codePt, policyTable[i].cir * 8,
00418 policyTable[i].cbs, policyTable[i].ebs);
00419 break;
00420 case trTCMPolicer:
00421 printf("Flow (%d to %d): trTCM policer, initial code ",
00422 policyTable[i].destNode, policyTable[i].sourceNode);
00423 printf("point %d, CIR %.1f bps, CBS %.1f bytes, PIR %.1f bps, ",
00424 policyTable[i].codePt, policyTable[i].cir * 8,
00425 policyTable[i].cbs, policyTable[i].pir * 8);
00426 printf("PBS %.1f bytes.\n", policyTable[i].pbs);
00427 break;
00428 case SFDPolicer:
00429 printf("Flow (%d to %d): SFD policer, ",
00430 policyTable[i].sourceNode,policyTable[i].destNode);
00431 printf("initial code point %d, TH %d bytes.\n",
00432 policyTable[i].codePt, (int)policyTable[i].cir);
00433 break;
00434 case EWPolicer:
00435 printf("Flow (%d to %d): EW policer, ",
00436 policyTable[i].sourceNode,policyTable[i].destNode);
00437 printf("initial code point %d.\n", policyTable[i].codePt);
00438 break;
00439 default:
00440 printf("ERROR: Unknown policer type in Policy Table.\n");
00441 }
00442 }
00443 printf("\n");
00444 }
|
|
||||||||||||
|
Definition at line 344 of file dsPolicy.cc. References getPolicyTableEntry(), and policyTableEntry::winLen.
00344 {
00345 policyTableEntry *policy;
00346
00347 policy = getPolicyTableEntry(atoi(argv[2]), atoi(argv[3]));
00348 if (policy == NULL)
00349 printf("ERROR: cannot update RTT; no existing policy found for Source %d-Desination %d.\n",
00350 atoi(argv[2]), atoi(argv[3]));
00351 else {
00352 policy->winLen = (double) atof(argv[4]);
00353 }
00354 }
|
Here is the call graph for this function:

|
|
Definition at line 113 of file dsPolicy.h. Referenced by addPolicerEntry(), getPolicerTableEntry(), and printPolicerTable(). |
|
|
Definition at line 114 of file dsPolicy.h. Referenced by addPolicerEntry(), getPolicerTableEntry(), PolicyClassifier(), and printPolicerTable(). |
|
|
Definition at line 106 of file dsPolicy.h. Referenced by addPolicerEntry(), addPolicyEntry(), edgeQueue::command(), mark(), and PolicyClassifier(). |
|
|
Definition at line 110 of file dsPolicy.h. Referenced by addPolicyEntry(), getPolicyTableEntry(), and printPolicyTable(). |
|
|
Definition at line 111 of file dsPolicy.h. Referenced by addPolicyEntry(), getPolicyTableEntry(), PolicyClassifier(), and printPolicyTable(). |
1.3.3