blob: 1942876480ca5aa244d01b65ce7fa50d42041076 [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
23 /**
24 * Specifies the type of band.
25 */
26 enum Type {
27 /**
28 * Simple rate limiter which drops packets
29 * when the rate is exceeded.
30 */
31 DROP,
32
33 /**
34 * defines a simple DiffServ policer that remark
Yuta HIGUCHI734e1e62016-09-07 09:12:20 -070035 * the drop precedence of the DSCP field in the
alshabibbc371962015-07-09 22:26:21 -070036 * IP header of the packets that exceed the band
37 * rate value.
38 */
39 REMARK
40 }
41
42 /**
43 * The rate at which this meter applies.
44 *
alshabibc7911792015-07-30 17:55:30 -070045 * @return the long value of the rate
alshabibbc371962015-07-09 22:26:21 -070046 */
alshabibc7911792015-07-30 17:55:30 -070047 long rate();
alshabibbc371962015-07-09 22:26:21 -070048
49 /**
50 * The burst size at which the meter applies.
51 *
alshabibc7911792015-07-30 17:55:30 -070052 * @return the long value of the size
alshabibbc371962015-07-09 22:26:21 -070053 */
Jian Li5c411232015-12-16 15:29:16 -080054 Long burst();
alshabibc7911792015-07-30 17:55:30 -070055
56 /**
57 * Only meaningful in the case of a REMARK band type.
58 * indicates by which amount the drop precedence of
59 * the packet should be increase if the band is exceeded.
60 *
61 * @return a short value
62 */
Jian Li5c411232015-12-16 15:29:16 -080063 Short dropPrecedence();
alshabibc7911792015-07-30 17:55:30 -070064
65 /**
66 * Signals the type of band to create.
67 *
68 * @return a band type
69 */
70 Type type();
alshabibbc371962015-07-09 22:26:21 -070071
alshabib7bb05012015-08-05 10:15:09 -070072 /**
73 * Returns the packets seen by this band.
74 *
75 * @return a long value
76 */
77 long packets();
78
79 /**
80 * Return the bytes seen by this band.
81 *
82 * @return a byte counter
83 */
84 long bytes();
85
alshabib1d2bc402015-07-31 17:04:11 -070086 interface Builder {
87
88 /**
89 * Assigns a rate to this band. The units for this rate
90 * are defined in the encapsulating meter.
91 *
92 * @param rate a long value
93 * @return this
94 */
95 Builder withRate(long rate);
96
97 /**
98 * Assigns a burst size to this band. Only meaningful if
99 * the encapsulating meter is of burst type.
100 *
101 * @param burstSize a long value.
102 * @return this
103 */
104 Builder burstSize(long burstSize);
105
106 /**
107 * Assigns the drop precedence for this band. Only meaningful if
108 * the band is of REMARK type.
109 *
110 * @param prec a short value
111 * @return this
112 */
113 Builder dropPrecedence(short prec);
114
115 /**
Yuta HIGUCHI734e1e62016-09-07 09:12:20 -0700116 * Assigns the {@link Type} of this band.
alshabib1d2bc402015-07-31 17:04:11 -0700117 *
118 * @param type a band type
119 * @return this
120 */
121 Builder ofType(Type type);
122
123 /**
124 * Builds the band.
125 *
126 * @return a band
127 */
128 Band build();
129
130 }
131
alshabibbc371962015-07-09 22:26:21 -0700132
133}