blob: e7e4ecec57d8affa072d4c2243202106d1230ded [file] [log] [blame]
Sangsik Yoonf0b3ad82016-08-19 18:47:59 +09001/*
2 * Copyright 2016-present 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 */
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.
69 */
70 public TrafficStatInfo(long ethernetBytes, long discardedBytes, long ipPackets, long totalPackets,
71 long ipBytes, int avgPktSize, int uniqueFlows, long tcpPackets, long udpPackets,
72 double dpiThroughputPps, double dpiThroughputBps,
73 double trafficThroughputPps, double trafficThroughputBps,
74 double trafficDurationSec, int guessedFlowProtos) {
75 this.ethernetBytes = ethernetBytes;
76 this.discardedBytes = discardedBytes;
77 this.ipPackets = ipPackets;
78 this.totalPackets = totalPackets;
79 this.ipBytes = ipBytes;
80 this.avgPktSize = avgPktSize;
81 this.uniqueFlows = uniqueFlows;
82 this.tcpPackets = tcpPackets;
83 this.udpPackets = udpPackets;
84 this.dpiThroughputPps = dpiThroughputPps;
85 this.dpiThroughputBps = dpiThroughputBps;
86 this.trafficThroughputPps = trafficThroughputPps;
87 this.trafficThroughputBps = trafficThroughputBps;
88 this.trafficDurationSec = trafficDurationSec;
89 this.guessedFlowProtos = guessedFlowProtos;
90 }
91
92 /**
93 * Returns DPI traffic ethernet bytes.
94 *
95 * @return ethernetBytes
96 */
97 public long ethernetBytes() {
98 return ethernetBytes;
99 }
100
101 /**
102 * Returns DPI traffic discarded bytes.
103 *
104 * @return discardedBytes
105 */
106 public long discardedBytes() {
107 return discardedBytes;
108 }
109
110 /**
111 * Returns DPI traffic ip packets.
112 *
113 * @return ipPackets
114 */
115 public long ipPackets() {
116 return ipPackets;
117 }
118
119 /**
120 * Returns DPI traffic total packets.
121 *
122 * @return totalPackets
123 */
124 public long totalPackets() {
125 return totalPackets;
126 }
127
128 /**
129 * Returns DPI traffic ip bytes.
130 *
131 * @return ipBytes
132 */
133 public long ipBytes() {
134 return ipBytes;
135 }
136
137 /**
138 * Returns DPI traffic average packet size.
139 *
140 * @return avgPktSize
141 */
142 public int avgPktSize() {
143 return avgPktSize;
144 }
145
146 /**
147 * Returns DPI traffic the number of unique flows.
148 *
149 * @return uniqueFlows
150 */
151 public int uniqueFlows() {
152 return uniqueFlows;
153 }
154
155 /**
156 * Returns DPI traffic TCP packets.
157 *
158 * @return tcpPackets
159 */
160 public long tcpPackets() {
161 return tcpPackets;
162 }
163
164 /**
165 * Returns DPI traffic UDP packets.
166 *
167 * @return udpPackets
168 */
169 public long udpPackets() {
170 return udpPackets;
171 }
172
173 /**
174 * Returns DPI traffic throughput Pps(Packet per second).
175 *
176 * @return dpiThroughputPps
177 */
178 public double dpiThroughputPps() {
179 return dpiThroughputPps;
180 }
181
182 /**
183 * Returns DPI traffic throughput Bps(Byte per second).
184 *
185 * @return dpiThroughputBps
186 */
187 public double dpiThroughputBps() {
188 return dpiThroughputBps;
189 }
190
191 /**
192 * Returns total traffic throughput Pps(Packet per second).
193 *
194 * @return trafficThroughputPps
195 */
196 public double trafficThroughputPps() {
197 return trafficThroughputPps;
198 }
199
200 /**
201 * Returns total traffic throughput Bps(Byte per second).
202 *
203 * @return trafficThroughputBps
204 */
205 public double trafficThroughputBps() {
206 return trafficThroughputBps;
207 }
208
209 /**
210 * Returns DPI traffic duration second.
211 *
212 * @return trafficDurationSec
213 */
214 public double trafficDurationSec() {
215 return trafficDurationSec;
216 }
217
218 /**
219 * Returns DPI traffic the number of guessed flow protocols.
220 *
221 * @return guessedFlowProtos
222 */
223 public int guessedFlowProtos() {
224 return guessedFlowProtos;
225 }
226
227
228 public void setEthernetBytes(long ethernetBytes) {
229 this.ethernetBytes = ethernetBytes;
230 }
231
232 public void setDiscardedBytes(long discardedBytes) {
233 this.discardedBytes = discardedBytes;
234 }
235
236 public void setIpPackets(long ipPackets) {
237 this.ipPackets = ipPackets;
238 }
239
240 public void setTotalPackets(long totalPackets) {
241 this.totalPackets = totalPackets;
242 }
243
244 public void setIpBytes(long ipBytes) {
245 this.ipBytes = ipBytes;
246 }
247
248 public void setAvgPktSize(int avgPktSize) {
249 this.avgPktSize = avgPktSize;
250 }
251
252 public void setUniqueFlows(int uniqueFlows) {
253 this.uniqueFlows = uniqueFlows;
254 }
255
256 public void setTcpPackets(long tcpPackets) {
257 this.tcpPackets = tcpPackets;
258 }
259
260 public void setUdpPackets(long udpPackets) {
261 this.udpPackets = udpPackets;
262 }
263
264 public void setDpiThroughputPps(double dpiThroughputPps) {
265 this.dpiThroughputPps = dpiThroughputPps;
266 }
267
268 public void setDpiThroughputBps(double dpiThroughputBps) {
269 this.dpiThroughputBps = dpiThroughputBps;
270 }
271
272 public void setTrafficThroughputPps(double trafficThroughputPps) {
273 this.trafficThroughputPps = trafficThroughputPps;
274 }
275
276 public void setTrafficThroughputBps(double trafficThroughputBps) {
277 this.trafficThroughputBps = trafficThroughputBps;
278 }
279
280 public void setTrafficDurationSec(double trafficDurationSec) {
281 this.trafficDurationSec = trafficDurationSec;
282 }
283
284 public void setGuessedFlowProtos(int guessedFlowProtos) {
285 this.guessedFlowProtos = guessedFlowProtos;
286 }
287
288 @Override
289 public String toString() {
290 return toStringHelper(this)
291 .add("ethernetBytes", ethernetBytes)
292 .add("discardedBytes", discardedBytes)
293 .add("ipPackets", ipPackets)
294 .add("totalPackets", totalPackets)
295 .add("ipBytes", ipBytes)
296 .add("avgPktSize", avgPktSize)
297 .add("uniqueFlows", uniqueFlows)
298 .add("tcpPackets", tcpPackets)
299 .add("udpPackets", udpPackets)
300 .add("dpiThroughputPps", dpiThroughputPps + " " + PPS_STRING)
301 .add("dpiThroughputBps", dpiThroughputBps + " " + BPS_STRING)
302 .add("trafficThroughputPps", trafficThroughputPps + " " + PPS_STRING)
303 .add("trafficThroughputBps", trafficThroughputBps + " " + BPS_STRING)
304 .add("trafficDurationSec", trafficDurationSec + " " + SEC_STRING)
305 .add("guessedFlowProtos", guessedFlowProtos)
306 .toString();
307 }
308}