Browse code

sbc: introduced dynamic rate limiting

also changed the time-base parameter to milliseconds.

Raphael Coeffic authored on 26/07/2013 11:05:28 • Václav Kubart committed on 02/08/2013 12:59:10
Showing 1 changed files
... ...
@@ -5,38 +5,57 @@
5 5
 #include "atomic_types.h"
6 6
 #include <sys/types.h>
7 7
 
8
-class RateLimit
8
+class DynRateLimit
9 9
   : protected AmMutex
10 10
 {
11 11
   u_int32_t last_update;
12
-  int rate;
13
-  int peak;
14 12
   int counter;
15 13
 
16 14
   unsigned int time_base;
17 15
 
18
-  void update_limit();
16
+  void update_limit(int rate, int peak);
19 17
 
20 18
 public:
21
-  // rate: units/time_base
22
-  // peak: units/time_base
23
-  // time_base: seconds
24
-  RateLimit(unsigned int rate, unsigned int peak, 
25
-	    unsigned int time_base);
19
+  // time_base_ms: milliseconds
20
+  DynRateLimit(unsigned int time_base_ms);
26 21
 
27
-  virtual ~RateLimit() {}
22
+  virtual ~DynRateLimit() {}
28 23
 
29
-  int getRate() const { return rate; }
30
-  int getPeak() const { return peak; }
31 24
   unsigned int getTimeBase() const { return time_base; }
32 25
 
33 26
   /**
27
+   * rate: units/time_base
28
+   * peak: units/time_base
34 29
    * returns true if 'size' should be dropped
35 30
    */
36
-  bool limit(unsigned int size);
31
+  bool limit(unsigned int rate, unsigned int peak, unsigned int size);
37 32
 
38 33
   /** Get last update timestamp (wheeltimer::wallclock ticks) */
39 34
   u_int32_t getLastUpdate() { return last_update; }
40 35
 };
41 36
 
37
+class RateLimit
38
+  : protected DynRateLimit
39
+{
40
+  int rate;
41
+  int peak;
42
+
43
+public:
44
+  // time_base_ms: milliseconds
45
+  RateLimit(unsigned int rate, unsigned int peak, unsigned int time_base_ms)
46
+    : DynRateLimit(time_base_ms), rate(rate), peak(peak)
47
+  {}
48
+
49
+  int getRate() const { return rate; }
50
+  int getPeak() const { return peak; }
51
+  unsigned int getTimeBase() const { return DynRateLimit::getTimeBase(); }
52
+
53
+  /**
54
+   * returns true if 'size' should be dropped
55
+   */
56
+  bool limit(unsigned int size) {
57
+    return DynRateLimit::limit(rate,peak,size);
58
+  }
59
+};
60
+
42 61
 #endif
Browse code

sbc: added getter to RateLimit class.

Raphael Coeffic authored on 06/06/2013 13:03:03
Showing 1 changed files
... ...
@@ -26,6 +26,10 @@ public:
26 26
 
27 27
   virtual ~RateLimit() {}
28 28
 
29
+  int getRate() const { return rate; }
30
+  int getPeak() const { return peak; }
31
+  unsigned int getTimeBase() const { return time_base; }
32
+
29 33
   /**
30 34
    * returns true if 'size' should be dropped
31 35
    */
Browse code

added virtual destructor to RateLimit

Raphael Coeffic authored on 15/03/2013 16:45:11
Showing 1 changed files
... ...
@@ -24,6 +24,8 @@ public:
24 24
   RateLimit(unsigned int rate, unsigned int peak, 
25 25
 	    unsigned int time_base);
26 26
 
27
+  virtual ~RateLimit() {}
28
+
27 29
   /**
28 30
    * returns true if 'size' should be dropped
29 31
    */
Browse code

sbc: allows to check when a rate-limiter has been last updated.

Raphael Coeffic authored on 15/03/2013 12:52:16
Showing 1 changed files
... ...
@@ -28,6 +28,9 @@ public:
28 28
    * returns true if 'size' should be dropped
29 29
    */
30 30
   bool limit(unsigned int size);
31
+
32
+  /** Get last update timestamp (wheeltimer::wallclock ticks) */
33
+  u_int32_t getLastUpdate() { return last_update; }
31 34
 };
32 35
 
33 36
 #endif
Browse code

sbc: removed RateLimitRefCnt

Raphael Coeffic authored on 27/02/2013 13:00:51
Showing 1 changed files
... ...
@@ -30,19 +30,4 @@ public:
30 30
   bool limit(unsigned int size);
31 31
 };
32 32
 
33
-class RateLimitRefCnt
34
-  : public RateLimit,
35
-    public atomic_ref_cnt
36
-{
37
-public:
38
-  // rate: units/time_base
39
-  // peak: units/time_base
40
-  // time_base: seconds
41
-  RateLimitRefCnt(unsigned int rate, unsigned int peak, int time_base)
42
-    : RateLimit(rate,peak,time_base)
43
-  {}
44
-};
45
-
46
-typedef shared_ref_cnt<RateLimitRefCnt> SharedRateLimit;
47
-
48 33
 #endif
Browse code

sbc: added RTP relay rate limiting and counters

Raphael Coeffic authored on 25/02/2013 13:01:11
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,48 @@
1
+#ifndef _RateLimit_h_
2
+#define _RateLimit_h_
3
+
4
+#include "AmThread.h"
5
+#include "atomic_types.h"
6
+#include <sys/types.h>
7
+
8
+class RateLimit
9
+  : protected AmMutex
10
+{
11
+  u_int32_t last_update;
12
+  int rate;
13
+  int peak;
14
+  int counter;
15
+
16
+  unsigned int time_base;
17
+
18
+  void update_limit();
19
+
20
+public:
21
+  // rate: units/time_base
22
+  // peak: units/time_base
23
+  // time_base: seconds
24
+  RateLimit(unsigned int rate, unsigned int peak, 
25
+	    unsigned int time_base);
26
+
27
+  /**
28
+   * returns true if 'size' should be dropped
29
+   */
30
+  bool limit(unsigned int size);
31
+};
32
+
33
+class RateLimitRefCnt
34
+  : public RateLimit,
35
+    public atomic_ref_cnt
36
+{
37
+public:
38
+  // rate: units/time_base
39
+  // peak: units/time_base
40
+  // time_base: seconds
41
+  RateLimitRefCnt(unsigned int rate, unsigned int peak, int time_base)
42
+    : RateLimit(rate,peak,time_base)
43
+  {}
44
+};
45
+
46
+typedef shared_ref_cnt<RateLimitRefCnt> SharedRateLimit;
47
+
48
+#endif