alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 3 | * |
| 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 | */ |
alshabib | 10c810b | 2015-08-18 16:59:04 -0700 | [diff] [blame] | 16 | package org.onosproject.net.meter; |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * Represents a band used within a meter. |
| 20 | */ |
| 21 | public interface Band { |
| 22 | |
Jayasree Ghosh | e7a240c | 2016-09-10 14:45:15 +0530 | [diff] [blame] | 23 | short MIN_PRECEDENCE = 0; |
| 24 | short MAX_PRECEDENCE = 255; |
| 25 | String ERR_MSG = "Precedence out of range"; |
| 26 | |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 27 | /** |
| 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 HIGUCHI | 734e1e6 | 2016-09-07 09:12:20 -0700 | [diff] [blame] | 39 | * the drop precedence of the DSCP field in the |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 40 | * 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 | * |
alshabib | c791179 | 2015-07-30 17:55:30 -0700 | [diff] [blame] | 49 | * @return the long value of the rate |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 50 | */ |
alshabib | c791179 | 2015-07-30 17:55:30 -0700 | [diff] [blame] | 51 | long rate(); |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * The burst size at which the meter applies. |
| 55 | * |
alshabib | c791179 | 2015-07-30 17:55:30 -0700 | [diff] [blame] | 56 | * @return the long value of the size |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 57 | */ |
Jian Li | 5c41123 | 2015-12-16 15:29:16 -0800 | [diff] [blame] | 58 | Long burst(); |
alshabib | c791179 | 2015-07-30 17:55:30 -0700 | [diff] [blame] | 59 | |
| 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 Li | 5c41123 | 2015-12-16 15:29:16 -0800 | [diff] [blame] | 67 | Short dropPrecedence(); |
alshabib | c791179 | 2015-07-30 17:55:30 -0700 | [diff] [blame] | 68 | |
| 69 | /** |
| 70 | * Signals the type of band to create. |
| 71 | * |
| 72 | * @return a band type |
| 73 | */ |
| 74 | Type type(); |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 75 | |
alshabib | 7bb0501 | 2015-08-05 10:15:09 -0700 | [diff] [blame] | 76 | /** |
| 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 | |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 90 | 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 HIGUCHI | 734e1e6 | 2016-09-07 09:12:20 -0700 | [diff] [blame] | 120 | * Assigns the {@link Type} of this band. |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame] | 121 | * |
| 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 | |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 136 | |
| 137 | } |