kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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 | |
| 17 | package org.opencord.aaa; |
| 18 | |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 19 | import java.util.LinkedList; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 20 | import java.util.concurrent.atomic.AtomicLong; |
| 21 | |
| 22 | public class AaaStatistics { |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 23 | // Number of access accept packets sent to the server |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 24 | private AtomicLong acceptResponsesRx = new AtomicLong(); |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 25 | // Number of access reject packets sent to the server |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 26 | private AtomicLong rejectResponsesRx = new AtomicLong(); |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 27 | // Number of access challenge packets sent to the server |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 28 | private AtomicLong challengeResponsesRx = new AtomicLong(); |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 29 | // Number of access request packets sent to the server |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 30 | private AtomicLong accessRequestsTx = new AtomicLong(); |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 31 | // Number of access request packets pending a response from the server |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 32 | private AtomicLong pendingRequests = new AtomicLong(); |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 33 | // Number of packets of an unknown RADIUS type received from the accounting |
| 34 | // server |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 35 | private AtomicLong unknownTypeRx = new AtomicLong(); |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 36 | // Number of access response packets received from the server with an invalid |
| 37 | // validator |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 38 | private AtomicLong invalidValidatorsRx = new AtomicLong(); |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 39 | // Number of dropped packets received from the accounting server |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 40 | private AtomicLong droppedResponsesRx = new AtomicLong(); |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 41 | // Number of malformed access response packets received from the server |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 42 | private AtomicLong malformedResponsesRx = new AtomicLong(); |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 43 | // Number of packets received from an unknown server |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 44 | private AtomicLong unknownServerRx = new AtomicLong(); |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 45 | // Roundtrip packet time to the accounting server |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 46 | private AtomicLong requestRttMilis = new AtomicLong(); |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 47 | // Number of access request packets retransmitted to the server |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 48 | private AtomicLong requestReTx = new AtomicLong(); |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 49 | // Number of sessions expired |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 50 | private AtomicLong numberOfSessionsExpired = new AtomicLong(); |
| 51 | |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 52 | private LinkedList<Long> packetRoundTripTimeList = new LinkedList<Long>(); |
| 53 | |
| 54 | public LinkedList<Long> getPacketRoundTripTimeList() { |
| 55 | return packetRoundTripTimeList; |
| 56 | } |
| 57 | |
| 58 | public int getPacketRoundTripTimeListSize() { |
| 59 | return packetRoundTripTimeList.size(); |
| 60 | } |
| 61 | |
| 62 | public void clearPacketRoundTripTimeList() { |
| 63 | packetRoundTripTimeList.clear(); |
| 64 | } |
| 65 | |
| 66 | public void getPacketRoundTripTimeListRemoveFirst() { |
| 67 | packetRoundTripTimeList.removeFirst(); |
| 68 | } |
| 69 | |
| 70 | public void getPacketRoundTripTimeListAdd(long time) { |
| 71 | packetRoundTripTimeList.add(time); |
| 72 | } |
| 73 | |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 74 | public Long getRequestReTx() { |
| 75 | return requestReTx.get(); |
| 76 | } |
| 77 | |
| 78 | public void setRequestRttMilis(AtomicLong requestRttMilis) { |
| 79 | this.requestRttMilis = requestRttMilis; |
| 80 | } |
| 81 | |
| 82 | public Long getUnknownServerRx() { |
| 83 | return unknownServerRx.get(); |
| 84 | } |
| 85 | |
| 86 | public Long getRequestRttMilis() { |
| 87 | return requestRttMilis.get(); |
| 88 | } |
| 89 | |
| 90 | public Long getMalformedResponsesRx() { |
| 91 | return malformedResponsesRx.get(); |
| 92 | } |
| 93 | |
| 94 | public Long getDroppedResponsesRx() { |
| 95 | return droppedResponsesRx.get(); |
| 96 | } |
| 97 | |
| 98 | public Long getInvalidValidatorsRx() { |
| 99 | return invalidValidatorsRx.get(); |
| 100 | } |
| 101 | |
| 102 | public Long getAcceptResponsesRx() { |
| 103 | return acceptResponsesRx.get(); |
| 104 | } |
| 105 | |
| 106 | public Long getRejectResponsesRx() { |
| 107 | return rejectResponsesRx.get(); |
| 108 | } |
| 109 | |
| 110 | public Long getChallengeResponsesRx() { |
| 111 | return challengeResponsesRx.get(); |
| 112 | } |
| 113 | |
| 114 | public Long getAccessRequestsTx() { |
| 115 | return accessRequestsTx.get(); |
| 116 | } |
| 117 | |
| 118 | public Long getPendingRequests() { |
| 119 | return pendingRequests.get(); |
| 120 | } |
| 121 | |
| 122 | public Long getUnknownTypeRx() { |
| 123 | return unknownTypeRx.get(); |
| 124 | } |
| 125 | |
| 126 | public void increaseAcceptResponsesRx() { |
| 127 | acceptResponsesRx.incrementAndGet(); |
| 128 | } |
| 129 | |
| 130 | public void increaseRejectResponsesRx() { |
| 131 | rejectResponsesRx.incrementAndGet(); |
| 132 | } |
| 133 | |
| 134 | public void increaseChallengeResponsesRx() { |
| 135 | challengeResponsesRx.incrementAndGet(); |
| 136 | } |
| 137 | |
| 138 | public void increaseAccessRequestsTx() { |
| 139 | accessRequestsTx.incrementAndGet(); |
| 140 | } |
| 141 | |
| 142 | public void increaseRequestReTx() { |
| 143 | requestReTx.incrementAndGet(); |
| 144 | } |
| 145 | |
| 146 | public void increaseOrDecreasePendingRequests(boolean isIncrement) { |
| 147 | if (isIncrement) { |
| 148 | pendingRequests.incrementAndGet(); |
| 149 | } else { |
| 150 | pendingRequests.decrementAndGet(); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | public void increaseUnknownTypeRx() { |
| 155 | unknownTypeRx.incrementAndGet(); |
| 156 | } |
| 157 | |
| 158 | public void increaseMalformedResponsesRx() { |
| 159 | malformedResponsesRx.incrementAndGet(); |
| 160 | } |
| 161 | |
| 162 | public void increaseInvalidValidatorsRx() { |
| 163 | invalidValidatorsRx.incrementAndGet(); |
| 164 | } |
| 165 | |
| 166 | public void incrementUnknownServerRx() { |
| 167 | unknownServerRx.incrementAndGet(); |
| 168 | } |
| 169 | |
| 170 | public void incrementNumberOfSessionsExpired() { |
| 171 | numberOfSessionsExpired.incrementAndGet(); |
| 172 | } |
| 173 | |
| 174 | public void countDroppedResponsesRx() { |
| 175 | long numberOfDroppedPackets = invalidValidatorsRx.get(); |
| 176 | numberOfDroppedPackets += unknownTypeRx.get(); |
| 177 | numberOfDroppedPackets += malformedResponsesRx.get(); |
| 178 | numberOfDroppedPackets += numberOfSessionsExpired.get(); |
| 179 | this.droppedResponsesRx = new AtomicLong(numberOfDroppedPackets); |
| 180 | } |
Vijaykumar Kushwaha | a54ce55 | 2019-06-18 09:37:42 +0000 | [diff] [blame^] | 181 | |
| 182 | public void resetAllCounters() { |
| 183 | clearPacketRoundTripTimeList(); |
| 184 | |
| 185 | accessRequestsTx.set(0); |
| 186 | acceptResponsesRx.set(0); |
| 187 | challengeResponsesRx.set(0); |
| 188 | droppedResponsesRx.set(0); |
| 189 | invalidValidatorsRx.set(0); |
| 190 | malformedResponsesRx.set(0); |
| 191 | pendingRequests.set(0); |
| 192 | rejectResponsesRx.set(0); |
| 193 | requestReTx.set(0); |
| 194 | requestRttMilis.set(0); |
| 195 | unknownServerRx.set(0); |
| 196 | unknownTypeRx.set(0); |
| 197 | } |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 198 | } |