alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Open Networking Laboratory |
| 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 | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame^] | 16 | package org.onosproject.incubator.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 | |
| 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 |
alshabib | c791179 | 2015-07-30 17:55:30 -0700 | [diff] [blame] | 35 | * the drop precedence of the DSCP field in the |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 36 | * 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 | * |
alshabib | c791179 | 2015-07-30 17:55:30 -0700 | [diff] [blame] | 45 | * @return the long value of the rate |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 46 | */ |
alshabib | c791179 | 2015-07-30 17:55:30 -0700 | [diff] [blame] | 47 | long rate(); |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * The burst size at which the meter applies. |
| 51 | * |
alshabib | c791179 | 2015-07-30 17:55:30 -0700 | [diff] [blame] | 52 | * @return the long value of the size |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 53 | */ |
alshabib | c791179 | 2015-07-30 17:55:30 -0700 | [diff] [blame] | 54 | long burst(); |
| 55 | |
| 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 | */ |
| 63 | short dropPrecedence(); |
| 64 | |
| 65 | /** |
| 66 | * Signals the type of band to create. |
| 67 | * |
| 68 | * @return a band type |
| 69 | */ |
| 70 | Type type(); |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 71 | |
alshabib | 1d2bc40 | 2015-07-31 17:04:11 -0700 | [diff] [blame^] | 72 | interface Builder { |
| 73 | |
| 74 | /** |
| 75 | * Assigns a rate to this band. The units for this rate |
| 76 | * are defined in the encapsulating meter. |
| 77 | * |
| 78 | * @param rate a long value |
| 79 | * @return this |
| 80 | */ |
| 81 | Builder withRate(long rate); |
| 82 | |
| 83 | /** |
| 84 | * Assigns a burst size to this band. Only meaningful if |
| 85 | * the encapsulating meter is of burst type. |
| 86 | * |
| 87 | * @param burstSize a long value. |
| 88 | * @return this |
| 89 | */ |
| 90 | Builder burstSize(long burstSize); |
| 91 | |
| 92 | /** |
| 93 | * Assigns the drop precedence for this band. Only meaningful if |
| 94 | * the band is of REMARK type. |
| 95 | * |
| 96 | * @param prec a short value |
| 97 | * @return this |
| 98 | */ |
| 99 | Builder dropPrecedence(short prec); |
| 100 | |
| 101 | /** |
| 102 | * Assigns the @See Type of this band. |
| 103 | * |
| 104 | * @param type a band type |
| 105 | * @return this |
| 106 | */ |
| 107 | Builder ofType(Type type); |
| 108 | |
| 109 | /** |
| 110 | * Builds the band. |
| 111 | * |
| 112 | * @return a band |
| 113 | */ |
| 114 | Band build(); |
| 115 | |
| 116 | } |
| 117 | |
alshabib | bc37196 | 2015-07-09 22:26:21 -0700 | [diff] [blame] | 118 | |
| 119 | } |