blob: ef7d30bada0383745d432807cea812effe519752 [file] [log] [blame]
Sangsik Yoonf0b3ad82016-08-19 18:47:59 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2016-present Open Networking Foundation
Sangsik Yoonf0b3ad82016-08-19 18:47:59 +09003 *
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 */
16
17package org.onosproject.incubator.net.dpi;
18
19import static com.google.common.base.MoreObjects.toStringHelper;
20
21/**
22 * Traffic statistic information.
23 */
24public class TrafficStatInfo {
25 long ethernetBytes;
26 long discardedBytes;
27 long ipPackets;
28 long totalPackets;
29 long ipBytes;
30 int avgPktSize;
31 int uniqueFlows;
32 long tcpPackets;
33 long udpPackets;
34
35 double dpiThroughputPps;
36 double dpiThroughputBps;
37 double trafficThroughputPps;
38 double trafficThroughputBps;
39 double trafficDurationSec;
40 int guessedFlowProtos;
41
42 static final String PPS_STRING = "pps";
43 static final String BPS_STRING = "bps";
44 static final String SEC_STRING = "sec";
45
46 /**
47 * Constructor for default TrafficStatInfo class.
48 */
49 public TrafficStatInfo() {
50 ethernetBytes = 0;
51 discardedBytes = 0;
52 ipPackets = 0;
53 totalPackets = 0;
54 ipBytes = 0;
55 avgPktSize = 0;
56 uniqueFlows = 0;
57 tcpPackets = 0;
58 udpPackets = 0;
59 dpiThroughputPps = 0;
60 dpiThroughputBps = 0;
61 trafficThroughputPps = 0;
62 trafficThroughputBps = 0;
63 trafficDurationSec = 0;
64 guessedFlowProtos = 0;
65 }
66
67 /**
68 * Constructor for TrafficStatInfo class specified with traffic statistic parameters.
Ray Milkeyef794342016-11-09 16:20:29 -080069 *
70 * @param ethernetBytes ethernet byte count
71 * @param discardedBytes discarded byte count
72 * @param ipPackets IP packet count
73 * @param totalPackets total packet count
74 * @param ipBytes total IP byte count
75 * @param avgPktSize average packet size
76 * @param uniqueFlows unique flows count
77 * @param tcpPackets TCP packet count
78 * @param udpPackets UDP packet count
79 * @param trafficThroughputPps traffic throughput PPS
80 * @param trafficThroughputBps traffic throughput BPS
81 * @param dpiThroughputPps DPI throughput PPS
82 * @param dpiThroughputBps DPI throughput BPS
83 * @param trafficDurationSec traffic duration in seconds
84 * @param guessedFlowProtos guess flow protocols
Sangsik Yoonf0b3ad82016-08-19 18:47:59 +090085 */
86 public TrafficStatInfo(long ethernetBytes, long discardedBytes, long ipPackets, long totalPackets,
87 long ipBytes, int avgPktSize, int uniqueFlows, long tcpPackets, long udpPackets,
88 double dpiThroughputPps, double dpiThroughputBps,
89 double trafficThroughputPps, double trafficThroughputBps,
90 double trafficDurationSec, int guessedFlowProtos) {
91 this.ethernetBytes = ethernetBytes;
92 this.discardedBytes = discardedBytes;
93 this.ipPackets = ipPackets;
94 this.totalPackets = totalPackets;
95 this.ipBytes = ipBytes;
96 this.avgPktSize = avgPktSize;
97 this.uniqueFlows = uniqueFlows;
98 this.tcpPackets = tcpPackets;
99 this.udpPackets = udpPackets;
100 this.dpiThroughputPps = dpiThroughputPps;
101 this.dpiThroughputBps = dpiThroughputBps;
102 this.trafficThroughputPps = trafficThroughputPps;
103 this.trafficThroughputBps = trafficThroughputBps;
104 this.trafficDurationSec = trafficDurationSec;
105 this.guessedFlowProtos = guessedFlowProtos;
106 }
107
108 /**
109 * Returns DPI traffic ethernet bytes.
110 *
111 * @return ethernetBytes
112 */
113 public long ethernetBytes() {
114 return ethernetBytes;
115 }
116
117 /**
118 * Returns DPI traffic discarded bytes.
119 *
120 * @return discardedBytes
121 */
122 public long discardedBytes() {
123 return discardedBytes;
124 }
125
126 /**
127 * Returns DPI traffic ip packets.
128 *
129 * @return ipPackets
130 */
131 public long ipPackets() {
132 return ipPackets;
133 }
134
135 /**
136 * Returns DPI traffic total packets.
137 *
138 * @return totalPackets
139 */
140 public long totalPackets() {
141 return totalPackets;
142 }
143
144 /**
145 * Returns DPI traffic ip bytes.
146 *
147 * @return ipBytes
148 */
149 public long ipBytes() {
150 return ipBytes;
151 }
152
153 /**
154 * Returns DPI traffic average packet size.
155 *
156 * @return avgPktSize
157 */
158 public int avgPktSize() {
159 return avgPktSize;
160 }
161
162 /**
163 * Returns DPI traffic the number of unique flows.
164 *
165 * @return uniqueFlows
166 */
167 public int uniqueFlows() {
168 return uniqueFlows;
169 }
170
171 /**
172 * Returns DPI traffic TCP packets.
173 *
174 * @return tcpPackets
175 */
176 public long tcpPackets() {
177 return tcpPackets;
178 }
179
180 /**
181 * Returns DPI traffic UDP packets.
182 *
183 * @return udpPackets
184 */
185 public long udpPackets() {
186 return udpPackets;
187 }
188
189 /**
190 * Returns DPI traffic throughput Pps(Packet per second).
191 *
192 * @return dpiThroughputPps
193 */
194 public double dpiThroughputPps() {
195 return dpiThroughputPps;
196 }
197
198 /**
199 * Returns DPI traffic throughput Bps(Byte per second).
200 *
201 * @return dpiThroughputBps
202 */
203 public double dpiThroughputBps() {
204 return dpiThroughputBps;
205 }
206
207 /**
208 * Returns total traffic throughput Pps(Packet per second).
209 *
210 * @return trafficThroughputPps
211 */
212 public double trafficThroughputPps() {
213 return trafficThroughputPps;
214 }
215
216 /**
217 * Returns total traffic throughput Bps(Byte per second).
218 *
219 * @return trafficThroughputBps
220 */
221 public double trafficThroughputBps() {
222 return trafficThroughputBps;
223 }
224
225 /**
226 * Returns DPI traffic duration second.
227 *
228 * @return trafficDurationSec
229 */
230 public double trafficDurationSec() {
231 return trafficDurationSec;
232 }
233
234 /**
235 * Returns DPI traffic the number of guessed flow protocols.
236 *
237 * @return guessedFlowProtos
238 */
239 public int guessedFlowProtos() {
240 return guessedFlowProtos;
241 }
242
243
244 public void setEthernetBytes(long ethernetBytes) {
245 this.ethernetBytes = ethernetBytes;
246 }
247
248 public void setDiscardedBytes(long discardedBytes) {
249 this.discardedBytes = discardedBytes;
250 }
251
252 public void setIpPackets(long ipPackets) {
253 this.ipPackets = ipPackets;
254 }
255
256 public void setTotalPackets(long totalPackets) {
257 this.totalPackets = totalPackets;
258 }
259
260 public void setIpBytes(long ipBytes) {
261 this.ipBytes = ipBytes;
262 }
263
264 public void setAvgPktSize(int avgPktSize) {
265 this.avgPktSize = avgPktSize;
266 }
267
268 public void setUniqueFlows(int uniqueFlows) {
269 this.uniqueFlows = uniqueFlows;
270 }
271
272 public void setTcpPackets(long tcpPackets) {
273 this.tcpPackets = tcpPackets;
274 }
275
276 public void setUdpPackets(long udpPackets) {
277 this.udpPackets = udpPackets;
278 }
279
280 public void setDpiThroughputPps(double dpiThroughputPps) {
281 this.dpiThroughputPps = dpiThroughputPps;
282 }
283
284 public void setDpiThroughputBps(double dpiThroughputBps) {
285 this.dpiThroughputBps = dpiThroughputBps;
286 }
287
288 public void setTrafficThroughputPps(double trafficThroughputPps) {
289 this.trafficThroughputPps = trafficThroughputPps;
290 }
291
292 public void setTrafficThroughputBps(double trafficThroughputBps) {
293 this.trafficThroughputBps = trafficThroughputBps;
294 }
295
296 public void setTrafficDurationSec(double trafficDurationSec) {
297 this.trafficDurationSec = trafficDurationSec;
298 }
299
300 public void setGuessedFlowProtos(int guessedFlowProtos) {
301 this.guessedFlowProtos = guessedFlowProtos;
302 }
303
304 @Override
305 public String toString() {
306 return toStringHelper(this)
307 .add("ethernetBytes", ethernetBytes)
308 .add("discardedBytes", discardedBytes)
309 .add("ipPackets", ipPackets)
310 .add("totalPackets", totalPackets)
311 .add("ipBytes", ipBytes)
312 .add("avgPktSize", avgPktSize)
313 .add("uniqueFlows", uniqueFlows)
314 .add("tcpPackets", tcpPackets)
315 .add("udpPackets", udpPackets)
316 .add("dpiThroughputPps", dpiThroughputPps + " " + PPS_STRING)
317 .add("dpiThroughputBps", dpiThroughputBps + " " + BPS_STRING)
318 .add("trafficThroughputPps", trafficThroughputPps + " " + PPS_STRING)
319 .add("trafficThroughputBps", trafficThroughputBps + " " + BPS_STRING)
320 .add("trafficDurationSec", trafficDurationSec + " " + SEC_STRING)
321 .add("guessedFlowProtos", guessedFlowProtos)
322 .toString();
323 }
324}