blob: 9f9479c987f342ab2aadbd5d38591a5cc73c854d [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.
54 */
55 NONE,
alshabibbc371962015-07-09 22:26:21 -070056 }
57
58 /**
59 * The rate at which this meter applies.
60 *
alshabibc7911792015-07-30 17:55:30 -070061 * @return the long value of the rate
alshabibbc371962015-07-09 22:26:21 -070062 */
alshabibc7911792015-07-30 17:55:30 -070063 long rate();
alshabibbc371962015-07-09 22:26:21 -070064
65 /**
66 * The burst size at which the meter applies.
67 *
alshabibc7911792015-07-30 17:55:30 -070068 * @return the long value of the size
alshabibbc371962015-07-09 22:26:21 -070069 */
Jian Li5c411232015-12-16 15:29:16 -080070 Long burst();
alshabibc7911792015-07-30 17:55:30 -070071
72 /**
73 * Only meaningful in the case of a REMARK band type.
74 * indicates by which amount the drop precedence of
75 * the packet should be increase if the band is exceeded.
76 *
77 * @return a short value
78 */
Jian Li5c411232015-12-16 15:29:16 -080079 Short dropPrecedence();
alshabibc7911792015-07-30 17:55:30 -070080
81 /**
82 * Signals the type of band to create.
83 *
84 * @return a band type
85 */
86 Type type();
alshabibbc371962015-07-09 22:26:21 -070087
alshabib7bb05012015-08-05 10:15:09 -070088 /**
89 * Returns the packets seen by this band.
90 *
91 * @return a long value
92 */
93 long packets();
94
95 /**
96 * Return the bytes seen by this band.
97 *
98 * @return a byte counter
99 */
100 long bytes();
101
alshabib1d2bc402015-07-31 17:04:11 -0700102 interface Builder {
103
104 /**
105 * Assigns a rate to this band. The units for this rate
106 * are defined in the encapsulating meter.
107 *
108 * @param rate a long value
109 * @return this
110 */
111 Builder withRate(long rate);
112
113 /**
114 * Assigns a burst size to this band. Only meaningful if
115 * the encapsulating meter is of burst type.
116 *
117 * @param burstSize a long value.
118 * @return this
119 */
120 Builder burstSize(long burstSize);
121
122 /**
123 * Assigns the drop precedence for this band. Only meaningful if
124 * the band is of REMARK type.
125 *
126 * @param prec a short value
127 * @return this
128 */
129 Builder dropPrecedence(short prec);
130
131 /**
Yuta HIGUCHI734e1e62016-09-07 09:12:20 -0700132 * Assigns the {@link Type} of this band.
alshabib1d2bc402015-07-31 17:04:11 -0700133 *
134 * @param type a band type
135 * @return this
136 */
137 Builder ofType(Type type);
138
139 /**
140 * Builds the band.
141 *
142 * @return a band
143 */
144 Band build();
145
146 }
147
alshabibbc371962015-07-09 22:26:21 -0700148
149}