00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef ns_rate_limit_h
00038 #define ns_rate_limit_h
00039
00040 #include "node.h"
00041 #include "packet.h"
00042 #include "route.h"
00043
00044 #include "agg-spec.h"
00045 #include "rate-limit-strategy.h"
00046 #include "logging-data-struct.h"
00047
00048 class RateLimitSession {
00049
00050 public:
00051 int pushbackON_;
00052
00053 int origin_;
00054
00055
00056
00057
00058
00059
00060
00061 int localQID_;
00062 int remoteQID_;
00063
00064
00065 int localID_;
00066 int remoteID_;
00067
00068 AggSpec * aggSpec_;
00069
00070
00071 double lowerBound_;
00072 int merged_;
00073 int initialPhase_;
00074
00075
00076 int heightInPTree_;
00077 int depthInPTree_;
00078
00079 double startTime_;
00080 double expiryTime_;
00081 double refreshTime_;
00082 RateLimitSession * next_;
00083
00084 RateLimitStrategy * rlStrategy_;
00085 LoggingDataStruct * logData_;
00086
00087
00088 RateLimitSession(AggSpec * aggSpec, double estimate, int initial, double limit, int origin,
00089 int locQid,
00090 double delay, double lowerBound, Node *node, RouteLogic * rtLogic_);
00091
00092
00093 RateLimitSession(AggSpec * aggSpec, double limit, int originID, int locQid, int remQid,
00094 int remoteID, int depth, double delay, double lowerBound, Node *node, RouteLogic * rtLogic_);
00095
00096 ~RateLimitSession();
00097
00098 void setSucc(RateLimitSession * session) {next_ = session;}
00099 double log(Packet *p, int lowDemand);
00100 double getDropRate();
00101 void pushbackOn();
00102 void refreshed();
00103 void setAggSpec(AggSpec * aggSpec);
00104 void setLimit(double limit);
00105 double getArrivalRateForStatus();
00106 static RateLimitSession * merge(RateLimitSession *, RateLimitSession *, int bits);
00107
00108 private:
00109 static double pick4merge(double, double, int);
00110 };
00111
00112
00113 class RateLimitSessionList {
00114
00115 public:
00116 RateLimitSession * first_;
00117 int noSessions_;
00118
00119 int IDCounter_;
00120
00121 RateLimitSessionList(): first_(NULL), noSessions_(0), IDCounter_(0){};
00122 int insert(RateLimitSession * session);
00123 int filter(Packet * p, int lowDemand);
00124 int containsAggSpec(AggSpec *);
00125 RateLimitSession * containsLocalAggSpec(AggSpec * spec, int myID);
00126 void mergeSessions(int myID);
00127 int noMySessions(int myID);
00128 void endSession(RateLimitSession *);
00129 int getMySubsetCount(int prefix, int bits, int myID);
00130 void merge(int prefix, int bits, int myID);
00131 RateLimitSession * getSessionByLocalID(int localID);
00132 RateLimitSession * getSessionByRemoteID(int remoteID);
00133
00134
00135 int rankRate(int myID, double rate);
00136 int rankSession(int myID, RateLimitSession * session);
00137 };
00138
00139
00140 #endif