blob: befbeadf0f423b5a2da1be4658865eaf597784b2 [file] [log] [blame]
alshabibbc371962015-07-09 22:26:21 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
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 /**
Aaron Kruglikova3613102017-08-07 11:28:18 -070038 * 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 /**
Aaron Kruglikova3613102017-08-07 11:28:18 -070046 * Defines an experimental meter band.
Jordi Ortizaa8de492016-12-01 00:21:36 +010047 */
Frank Wangd7e3b4b2017-09-24 13:37:54 +090048 EXPERIMENTAL,
49
50 /**
51 * Defines a meter band with no action, used to mark
52 * packets internally in the pipeline, i.e. without
53 * modifying the packet headers.
pierventrec0914ec2021-08-27 15:25:02 +020054 *
55 * @deprecated in onos-2.5, replace by MARK_YELLOW and MARK_RED
Frank Wangd7e3b4b2017-09-24 13:37:54 +090056 */
pierventrec0914ec2021-08-27 15:25:02 +020057 @Deprecated
Frank Wangd7e3b4b2017-09-24 13:37:54 +090058 NONE,
pierventrec0914ec2021-08-27 15:25:02 +020059
60 /**
61 * Defines a meter band for the configuration of the committed
62 * rate AND the committed burst size. Used in conjunction with MARK_RED
63 * to implement a srTCM or trTCM, see RFCs 2697 and 2698 respectively.
64 */
65 MARK_YELLOW,
66
67 /**
68 * Defines a meter band for the configuration of the peak rate
69 * AND the peak burst size OR the excess burst size. When used to
70 * configure a srTCM excess rate must be 0. Used in conjunction with
71 * MARK_YELLOW to implement a srTCM or trTCM, see RFCs 2697 and 2698
72 * respectively.
73 */
74 MARK_RED,
alshabibbc371962015-07-09 22:26:21 -070075 }
76
77 /**
78 * The rate at which this meter applies.
79 *
alshabibc7911792015-07-30 17:55:30 -070080 * @return the long value of the rate
alshabibbc371962015-07-09 22:26:21 -070081 */
alshabibc7911792015-07-30 17:55:30 -070082 long rate();
alshabibbc371962015-07-09 22:26:21 -070083
84 /**
85 * The burst size at which the meter applies.
86 *
alshabibc7911792015-07-30 17:55:30 -070087 * @return the long value of the size
alshabibbc371962015-07-09 22:26:21 -070088 */
Jian Li5c411232015-12-16 15:29:16 -080089 Long burst();
alshabibc7911792015-07-30 17:55:30 -070090
91 /**
92 * Only meaningful in the case of a REMARK band type.
93 * indicates by which amount the drop precedence of
94 * the packet should be increase if the band is exceeded.
95 *
96 * @return a short value
97 */
Jian Li5c411232015-12-16 15:29:16 -080098 Short dropPrecedence();
alshabibc7911792015-07-30 17:55:30 -070099
100 /**
101 * Signals the type of band to create.
102 *
103 * @return a band type
104 */
105 Type type();
alshabibbc371962015-07-09 22:26:21 -0700106
alshabib7bb05012015-08-05 10:15:09 -0700107 /**
108 * Returns the packets seen by this band.
109 *
110 * @return a long value
111 */
112 long packets();
113
114 /**
115 * Return the bytes seen by this band.
116 *
117 * @return a byte counter
118 */
119 long bytes();
120
alshabib1d2bc402015-07-31 17:04:11 -0700121 interface Builder {
122
123 /**
124 * Assigns a rate to this band. The units for this rate
125 * are defined in the encapsulating meter.
126 *
127 * @param rate a long value
128 * @return this
129 */
130 Builder withRate(long rate);
131
132 /**
133 * Assigns a burst size to this band. Only meaningful if
134 * the encapsulating meter is of burst type.
135 *
136 * @param burstSize a long value.
137 * @return this
138 */
139 Builder burstSize(long burstSize);
140
141 /**
142 * Assigns the drop precedence for this band. Only meaningful if
143 * the band is of REMARK type.
144 *
145 * @param prec a short value
146 * @return this
147 */
148 Builder dropPrecedence(short prec);
149
150 /**
Yuta HIGUCHI734e1e62016-09-07 09:12:20 -0700151 * Assigns the {@link Type} of this band.
alshabib1d2bc402015-07-31 17:04:11 -0700152 *
153 * @param type a band type
154 * @return this
155 */
156 Builder ofType(Type type);
157
158 /**
159 * Builds the band.
160 *
161 * @return a band
162 */
163 Band build();
164
165 }
166
alshabibbc371962015-07-09 22:26:21 -0700167
168}