blob: 35a816f3236d2d2c0c61508fde9a268caf442449 [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 */
43 REMARK
44 }
45
46 /**
47 * The rate at which this meter applies.
48 *
alshabibc7911792015-07-30 17:55:30 -070049 * @return the long value of the rate
alshabibbc371962015-07-09 22:26:21 -070050 */
alshabibc7911792015-07-30 17:55:30 -070051 long rate();
alshabibbc371962015-07-09 22:26:21 -070052
53 /**
54 * The burst size at which the meter applies.
55 *
alshabibc7911792015-07-30 17:55:30 -070056 * @return the long value of the size
alshabibbc371962015-07-09 22:26:21 -070057 */
Jian Li5c411232015-12-16 15:29:16 -080058 Long burst();
alshabibc7911792015-07-30 17:55:30 -070059
60 /**
61 * Only meaningful in the case of a REMARK band type.
62 * indicates by which amount the drop precedence of
63 * the packet should be increase if the band is exceeded.
64 *
65 * @return a short value
66 */
Jian Li5c411232015-12-16 15:29:16 -080067 Short dropPrecedence();
alshabibc7911792015-07-30 17:55:30 -070068
69 /**
70 * Signals the type of band to create.
71 *
72 * @return a band type
73 */
74 Type type();
alshabibbc371962015-07-09 22:26:21 -070075
alshabib7bb05012015-08-05 10:15:09 -070076 /**
77 * Returns the packets seen by this band.
78 *
79 * @return a long value
80 */
81 long packets();
82
83 /**
84 * Return the bytes seen by this band.
85 *
86 * @return a byte counter
87 */
88 long bytes();
89
alshabib1d2bc402015-07-31 17:04:11 -070090 interface Builder {
91
92 /**
93 * Assigns a rate to this band. The units for this rate
94 * are defined in the encapsulating meter.
95 *
96 * @param rate a long value
97 * @return this
98 */
99 Builder withRate(long rate);
100
101 /**
102 * Assigns a burst size to this band. Only meaningful if
103 * the encapsulating meter is of burst type.
104 *
105 * @param burstSize a long value.
106 * @return this
107 */
108 Builder burstSize(long burstSize);
109
110 /**
111 * Assigns the drop precedence for this band. Only meaningful if
112 * the band is of REMARK type.
113 *
114 * @param prec a short value
115 * @return this
116 */
117 Builder dropPrecedence(short prec);
118
119 /**
Yuta HIGUCHI734e1e62016-09-07 09:12:20 -0700120 * Assigns the {@link Type} of this band.
alshabib1d2bc402015-07-31 17:04:11 -0700121 *
122 * @param type a band type
123 * @return this
124 */
125 Builder ofType(Type type);
126
127 /**
128 * Builds the band.
129 *
130 * @return a band
131 */
132 Band build();
133
134 }
135
alshabibbc371962015-07-09 22:26:21 -0700136
137}