#include <ew.h>
Inheritance diagram for EWPolicy:


Public Member Functions | |
| EWPolicy () | |
| ~EWPolicy () | |
| void | init (int, int, int) |
| void | applyMeter (policyTableEntry *policy, Packet *pkt) |
| int | applyPolicer (policyTableEntry *policy, policerTableEntry *policer, Packet *pkt) |
| int | dropPacket (Packet *) |
| void | detect (Packet *pkt) |
| void | detectPr () |
| void | detectPr (int) |
| void | detectPr (int, int) |
| void | detectBr () |
| void | detectBr (int) |
| void | detectBr (int, int) |
| void | limitPr () |
| void | limitPr (double) |
| void | limitBr () |
| void | limitBr (double) |
| void | coupleEW (EWPolicy *) |
| void | coupleEW (EWPolicy *, double) |
Public Attributes | |
| EWdetectorB * | ewB |
| EWdetectorB * | cewB |
| EWdetectorP * | ewP |
| EWdetectorP * | cewP |
| TBrateLimitor * | rlP |
| TBrateLimitor * | rlB |
Private Attributes | |
| double | now |
| int | ew_adj |
| int | qsrc |
| int | qdst |
| int | max_p |
| int | max_b |
| int | alarm |
| int | pre_alarm |
| int | change |
|
|
Definition at line 941 of file ew.cc. References alarm, cewB, cewP, change, ewB, ewP, max_b, max_p, pre_alarm, rlB, and rlP.
|
|
|
Definition at line 955 of file ew.cc. References cewB, cewP, ewB, and ewP.
|
|
||||||||||||
|
Implements Policy. Definition at line 979 of file ew.cc.
00979 {
00980 return;
00981 }
|
|
||||||||||||||||
|
Implements Policy. Definition at line 986 of file ew.cc. References hdr_cmn::access(), Scheduler::clock(), policerTableEntry::downgrade1, dropPacket(), ewB, ewP, policerTableEntry::initialCodePt, Scheduler::instance(), now, PKT_ARRIVAL, PKT_DEPT, PKT_DROP, PT_ACK, hdr_cmn::ptype(), EWdetector::run(), and EWdetectorP::updateStats().
00986 {
00987 //printf("enter applyPolicer ");
00988
00989 // can't count/penalize ACKs:
00990 // with resp: may cause inaccurate calculation with TSW(??)
00991 // with req: may cause resp retransmission.
00992 // just pass them through
00993 hdr_cmn *th = hdr_cmn::access(pkt);
00994 if (th->ptype() == PT_ACK)
00995 return(policer->initialCodePt);
00996
00997 // for other packets...
00998
00999 // Get time
01000 now = Scheduler::instance().clock();
01001
01002 // keep arrival packet stats
01003 if (ewP)
01004 ewP->updateStats(PKT_ARRIVAL);
01005
01006 // For other packets:
01007 if (dropPacket(pkt)) {
01008 // keep packet stats
01009 if (ewP)
01010 ewP->updateStats(PKT_DROP);
01011
01012 //printf("downgrade!\n");
01013 return(policer->downgrade1);
01014 } else {
01015 // keep packet stats
01016 if (ewP)
01017 ewP->updateStats(PKT_DEPT);
01018
01019 // conduct EW detection
01020 if (ewP)
01021 ewP->run(pkt);
01022
01023 if (ewB)
01024 ewB->run(pkt);
01025
01026 //printf("initial!\n");
01027 return(policer->initialCodePt);
01028 }
01029 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1193 of file ew.cc. References cewB, ewB, and limitPr().
|
Here is the call graph for this function:

|
|
Definition at line 1188 of file ew.cc. Referenced by edgeQueue::command().
01188 {
01189 coupleEW(ewpc, 0);
01190 }
|
|
|
Definition at line 1032 of file ew.cc. References alarm, cewB, change, EW_UNCHANGE, ewP, pre_alarm, EWdetector::resetChange(), and EWdetector::testAlarm(). Referenced by dropPacket().
01032 {
01033 int alarm_b, alarm_p;
01034
01035 alarm_b = alarm_p = 0;
01036
01037 if (!ewP || ! cewB)
01038 return;
01039
01040 alarm_b = cewB->testAlarm();
01041 alarm_p = ewP->testAlarm();
01042
01043
01044 if (alarm_p == EW_UNCHANGE || alarm_b == EW_UNCHANGE)
01045 return;
01046
01047 // Need to get info from both parts to make a decision
01048 // Reset change flags
01049 ewP->resetChange();
01050 cewB->resetChange();
01051
01052 change = 1;
01053 // keep the old value of alarm
01054 pre_alarm = alarm;
01055
01056 // As long as alarm_b is 0, reset the alarm
01057 if (alarm_b == 0)
01058 alarm = 0;
01059 else if (alarm_p == 0)
01060 alarm = 0;
01061 else
01062 alarm = 1;
01063
01064 printf("ALARM %d %d\n", pre_alarm, alarm);
01065 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1149 of file ew.cc. References ew_adj, ewB, EWdetectorB::init(), qdst, qsrc, EWdetector::setDb(), EWdetector::setDt(), and EWdetector::setLink().
|
Here is the call graph for this function:

|
|
Definition at line 1157 of file ew.cc. References detectBr().
01157 {
01158 detectBr(dt_inv, dt_inv);
01159 }
|
Here is the call graph for this function:

|
|
Definition at line 1161 of file ew.cc. References EW_DB_INV, and EW_DT_INV. Referenced by edgeQueue::command(), and detectBr().
01161 {
01162 detectBr(EW_DT_INV, EW_DB_INV);
01163 }
|
|
||||||||||||
|
Definition at line 1133 of file ew.cc. References ewP, qdst, qsrc, EWdetector::setDb(), EWdetector::setDt(), and EWdetector::setLink().
|
Here is the call graph for this function:

|
|
Definition at line 1140 of file ew.cc. References detectPr().
01140 {
01141 detectPr(dt_inv, dt_inv);
01142 }
|
Here is the call graph for this function:

|
|
Definition at line 1144 of file ew.cc. References EW_DB_INV, and EW_DT_INV. Referenced by edgeQueue::command(), and detectPr().
01144 {
01145 detectPr(EW_DT_INV, EW_DB_INV);
01146 }
|
|
|
Definition at line 1068 of file ew.cc. References hdr_tcp::access(), TBrateLimitor::adjustRate(), TBrateLimitor::adjustScore(), alarm, cewB, change, detect(), ewP, hdr_tcp::flags(), EWdetectorP::getRate(), pre_alarm, TBrateLimitor::resetScore(), rlP, TBrateLimitor::run(), TBrateLimitor::setRate(), and TH_SYN. Referenced by applyPolicer().
01068 {
01069 // 1. arrival stats is measured in meter (departure and drops here)
01070 // 2. No penalty to response traffic!!
01071 // 3. need to protect existing connections
01072
01073 // pass EW if there is any
01074 if (cewB && ewP) {
01075 // protecting existing connections
01076 // drop requests for new connection (SYN packet)
01077 // if (cewB->exFlow(pkt))
01078 hdr_tcp *tcph = hdr_tcp::access(pkt);
01079 // Protecting non-SYN packets: existing connections
01080 if ((tcph->flags() & TH_SYN) == 0) {
01081 //return(0);
01082 }
01083
01084 // Check alarm
01085 detect(pkt);
01086
01087 if (change) {
01088 // for new incoming requests:
01089 // use EW measurement to adjust the rate limit (to current Rq)
01090 // see if the alarm should be reset
01091
01092 if (pre_alarm) {
01093 if (alarm) {
01094 // The rate is not right:
01095 // too low: too few connection admitted;
01096 // too high: congestion in response
01097 // Adjustment is needed.
01098 if (rlP)
01099 rlP->adjustRate();
01100 } else {
01101 // the current rate is ok, award the current choice
01102 if (rlP)
01103 rlP->adjustScore(1);
01104 }
01105 } else {
01106 if (alarm) {
01107 if (rlP) {
01108 // Start a new round
01109 rlP->resetScore();
01110 // Use current request rate as the rate limit
01111 rlP->setRate(ewP->getRate());
01112 }
01113 } else {
01114 // the current rate is ok
01115 }
01116 }
01117
01118 change = 0;
01119 }
01120 }
01121
01122 // Passing rate limitor if there is any
01123 if (rlP) {
01124 // rate limiting
01125 return(rlP->run(1));
01126 };
01127
01128 // through by default
01129 return(0);
01130 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 970 of file ew.cc. References ew_adj, qdst, and qsrc.
|
|
|
Definition at line 1172 of file ew.cc. References rlB.
01172 {
01173 //printf("BR %d\n", rate);
01174 rlB = new TBrateLimitor(rate);
01175 };
|
|
|
Definition at line 1183 of file ew.cc. References DEFAULT_TB_RATE_B. Referenced by edgeQueue::command().
01183 {
01184 limitBr(DEFAULT_TB_RATE_B);
01185 };
|
|
|
Definition at line 1166 of file ew.cc. References rlP.
01166 {
01167 //printf("PR %d\n", rate);
01168 rlP = new TBrateLimitor(rate);
01169 };
|
|
|
Definition at line 1178 of file ew.cc. References DEFAULT_TB_RATE_P. Referenced by edgeQueue::command(), and coupleEW().
01178 {
01179 limitPr(DEFAULT_TB_RATE_P);
01180 };
|
|
|
Definition at line 390 of file ew.h. Referenced by detect(), dropPacket(), and EWPolicy(). |
|
|
Definition at line 374 of file ew.h. Referenced by coupleEW(), detect(), dropPacket(), EWPolicy(), and ~EWPolicy(). |
|
|
Definition at line 375 of file ew.h. Referenced by EWPolicy(), and ~EWPolicy(). |
|
|
Definition at line 391 of file ew.h. Referenced by detect(), dropPacket(), and EWPolicy(). |
|
|
Definition at line 384 of file ew.h. Referenced by detectBr(), and init(). |
|
|
Definition at line 374 of file ew.h. Referenced by applyPolicer(), coupleEW(), detectBr(), EWPolicy(), and ~EWPolicy(). |
|
|
Definition at line 375 of file ew.h. Referenced by applyPolicer(), detect(), detectPr(), dropPacket(), EWPolicy(), and ~EWPolicy(). |
|
|
Definition at line 387 of file ew.h. Referenced by EWPolicy(). |
|
|
Definition at line 387 of file ew.h. Referenced by EWPolicy(). |
|
|
Definition at line 381 of file ew.h. Referenced by applyPolicer(). |
|
|
Definition at line 390 of file ew.h. Referenced by detect(), dropPacket(), and EWPolicy(). |
|
|
Definition at line 384 of file ew.h. Referenced by detectBr(), detectPr(), and init(). |
|
|
Definition at line 384 of file ew.h. Referenced by detectBr(), detectPr(), and init(). |
|
|
Definition at line 377 of file ew.h. Referenced by EWPolicy(), and limitBr(). |
|
|
Definition at line 377 of file ew.h. Referenced by dropPacket(), EWPolicy(), and limitPr(). |
1.3.3