blob: 29d9c8237b2b8cab2ee17ef6ecf3f5097f8141db [file] [log] [blame]
alshabibbc371962015-07-09 22:26:21 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
alshabibbc371962015-07-09 22:26:21 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
alshabib10c810b2015-08-18 16:59:04 -070016package org.onosproject.net.meter;
alshabibbc371962015-07-09 22:26:21 -070017
18/**
19 * Represents a band used within a meter.
20 */
21public interface Band {
22
Jayasree Ghoshe7a240c2016-09-10 14:45:15 +053023 short MIN_PRECEDENCE = 0;
24 short MAX_PRECEDENCE = 255;
25 String ERR_MSG = "Precedence out of range";
26
alshabibbc371962015-07-09 22:26:21 -070027 /**
28 * Specifies the type of band.
29 */
30 enum Type {
31 /**
32 * Simple rate limiter which drops packets
33 * when the rate is exceeded.
34 */
35 DROP,
36
37 /**
38 * defines a simple DiffServ policer that remark
Yuta HIGUCHI734e1e62016-09-07 09:12:20 -070039 * the drop precedence of the DSCP field in the
alshabibbc371962015-07-09 22:26:21 -070040 * IP header of the packets that exceed the band
41 * rate value.
42 */
Jordi Ortizaa8de492016-12-01 00:21:36 +010043 REMARK,
44
45 /**
46 * defines an experimental meter band.
47 */
48 EXPERIMENTAL
alshabibbc371962015-07-09 22:26:21 -070049 }
50
51 /**
52 * The rate at which this meter applies.
53 *
alshabibc7911792015-07-30 17:55:30 -070054 * @return the long value of the rate
alshabibbc371962015-07-09 22:26:21 -070055 */
alshabibc7911792015-07-30 17:55:30 -070056 long rate();
alshabibbc371962015-07-09 22:26:21 -070057
58 /**
59 * The burst size at which the meter applies.
60 *
alshabibc7911792015-07-30 17:55:30 -070061 * @return the long value of the size
alshabibbc371962015-07-09 22:26:21 -070062 */
Jian Li5c411232015-12-16 15:29:16 -080063 Long burst();
alshabibc7911792015-07-30 17:55:30 -070064
65 /**
66 * Only meaningful in the case of a REMARK band type.
67 * indicates by which amount the drop precedence of
68 * the packet should be increase if the band is exceeded.
69 *
70 * @return a short value
71 */
Jian Li5c411232015-12-16 15:29:16 -080072 Short dropPrecedence();
alshabibc7911792015-07-30 17:55:30 -070073
74 /**
75 * Signals the type of band to create.
76 *
77 * @return a band type
78 */
79 Type type();
alshabibbc371962015-07-09 22:26:21 -070080
alshabib7bb05012015-08-05 10:15:09 -070081 /**
82 * Returns the packets seen by this band.
83 *
84 * @return a long value
85 */
86 long packets();
87
88 /**
89 * Return the bytes seen by this band.
90 *
91 * @return a byte counter
92 */
93 long bytes();
94
alshabib1d2bc402015-07-31 17:04:11 -070095 interface Builder {
96
97 /**
98 * Assigns a rate to this band. The units for this rate
99 * are defined in the encapsulating meter.
100 *
101 * @param rate a long value
102 * @return this
103 */
104 Builder withRate(long rate);
105
106 /**
107 * Assigns a burst size to this band. Only meaningful if
108 * the encapsulating meter is of burst type.
109 *
110 * @param burstSize a long value.
111 * @return this
112 */
113 Builder burstSize(long burstSize);
114
115 /**
116 * Assigns the drop precedence for this band. Only meaningful if
117 * the band is of REMARK type.
118 *
119 * @param prec a short value
120 * @return this
121 */
122 Builder dropPrecedence(short prec);
123
124 /**
Yuta HIGUCHI734e1e62016-09-07 09:12:20 -0700125 * Assigns the {@link Type} of this band.
alshabib1d2bc402015-07-31 17:04:11 -0700126 *
127 * @param type a band type
128 * @return this
129 */
130 Builder ofType(Type type);
131
132 /**
133 * Builds the band.
134 *
135 * @return a band
136 */
137 Band build();
138
139 }
140
alshabibbc371962015-07-09 22:26:21 -0700141
142}