summaryrefslogtreecommitdiffstats
path: root/service/java/com/android/server/wifi/WifiLinkLayerStats.java
blob: 898b1313d2bacdbe317f7e1d29406b07b17085fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/*
 * Copyright 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wifi;

import android.util.SparseArray;

import java.util.Arrays;

/**
 * A class representing link layer statistics collected over a Wifi Interface.
 */

/**
 * {@hide}
 */
public class WifiLinkLayerStats {
    public static final String V1_0 = "V1_0";
    public static final String V1_3 = "V1_3";

    /** The version of hal StaLinkLayerStats **/
    public String version;

    /** Number of beacons received from our own AP */
    public int beacon_rx;

    /** RSSI of management frames */
    public int rssi_mgmt;

    /* Packet counters */

    /** WME Best Effort Access Category received mpdu */
    public long rxmpdu_be;
    /** WME Best Effort Access Category transmitted mpdu */
    public long txmpdu_be;
    /** WME Best Effort Access Category lost mpdu */
    public long lostmpdu_be;
    /** WME Best Effort Access Category number of transmission retries */
    public long retries_be;

    /** WME Background Access Category received mpdu */
    public long rxmpdu_bk;
    /** WME Background Access Category transmitted mpdu */
    public long txmpdu_bk;
    /** WME Background Access Category lost mpdu */
    public long lostmpdu_bk;
    /** WME Background Access Category number of transmission retries */
    public long retries_bk;

    /** WME Video Access Category received mpdu */
    public long rxmpdu_vi;
    /** WME Video Access Category transmitted mpdu */
    public long txmpdu_vi;
    /** WME Video Access Category lost mpdu */
    public long lostmpdu_vi;
    /** WME Video Access Category number of transmission retries */
    public long retries_vi;

    /** WME Voice Access Category received mpdu */
    public long rxmpdu_vo;
    /** WME Voice Access Category transmitted mpdu */
    public long txmpdu_vo;
    /** WME Voice Access Category lost mpdu */
    public long lostmpdu_vo;
    /** WME Voice Access Category number of transmission retries */
    public long retries_vo;

    /**
     * Cumulative milliseconds when radio is awake
     */
    public int on_time;
    /**
     * Cumulative milliseconds of active transmission
     */
    public int tx_time;
    /**
     * Cumulative milliseconds per level of active transmission
     */
    public int[] tx_time_per_level;
    /**
     * Cumulative milliseconds of active receive
     */
    public int rx_time;
    /**
     * Cumulative milliseconds when radio is awake due to scan
     */
    public int on_time_scan;
    /**
     * Cumulative milliseconds when radio is awake due to nan scan
     */
    public int on_time_nan_scan = -1;
    /**
     * Cumulative milliseconds when radio is awake due to background scan
     */
    public int on_time_background_scan = -1;
    /**
     * Cumulative milliseconds when radio is awake due to roam scan
     */
    public int on_time_roam_scan = -1;
    /**
     * Cumulative milliseconds when radio is awake due to pno scan
     */
    public int on_time_pno_scan = -1;
    /**
     * Cumulative milliseconds when radio is awake due to hotspot 2.0 scan amd GAS exchange
     */
    public int on_time_hs20_scan = -1;
    /**
     * channel stats
     */
    public static class ChannelStats {
        /**
         * Channel frequency in MHz;
         */
        public int frequency;
        /**
         * Cumulative milliseconds radio is awake on this channel
         */
        public int radioOnTimeMs;
        /**
         * Cumulative milliseconds CCA is held busy on this channel
         */
        public int ccaBusyTimeMs;
    }
    /**
     * Channel stats list
     */
    public final SparseArray<ChannelStats> channelStatsMap = new SparseArray<>();

    /**
     * TimeStamp - absolute milliseconds from boot when these stats were sampled.
     */
    public long timeStampInMs;

    @Override
    public String toString() {
        StringBuilder sbuf = new StringBuilder();
        sbuf.append(" WifiLinkLayerStats: ").append('\n');

        sbuf.append(" version of StaLinkLayerStats: ").append(version).append('\n');
        sbuf.append(" my bss beacon rx: ").append(Integer.toString(this.beacon_rx)).append('\n');
        sbuf.append(" RSSI mgmt: ").append(Integer.toString(this.rssi_mgmt)).append('\n');
        sbuf.append(" BE : ").append(" rx=").append(Long.toString(this.rxmpdu_be))
                .append(" tx=").append(Long.toString(this.txmpdu_be))
                .append(" lost=").append(Long.toString(this.lostmpdu_be))
                .append(" retries=").append(Long.toString(this.retries_be)).append('\n');
        sbuf.append(" BK : ").append(" rx=").append(Long.toString(this.rxmpdu_bk))
                .append(" tx=").append(Long.toString(this.txmpdu_bk))
                .append(" lost=").append(Long.toString(this.lostmpdu_bk))
                .append(" retries=").append(Long.toString(this.retries_bk)).append('\n');
        sbuf.append(" VI : ").append(" rx=").append(Long.toString(this.rxmpdu_vi))
                .append(" tx=").append(Long.toString(this.txmpdu_vi))
                .append(" lost=").append(Long.toString(this.lostmpdu_vi))
                .append(" retries=").append(Long.toString(this.retries_vi)).append('\n');
        sbuf.append(" VO : ").append(" rx=").append(Long.toString(this.rxmpdu_vo))
                .append(" tx=").append(Long.toString(this.txmpdu_vo))
                .append(" lost=").append(Long.toString(this.lostmpdu_vo))
                .append(" retries=").append(Long.toString(this.retries_vo)).append('\n');
        sbuf.append(" on_time : ").append(Integer.toString(this.on_time))
                .append(" tx_time=").append(Integer.toString(this.tx_time))
                .append(" rx_time=").append(Integer.toString(this.rx_time))
                .append(" scan_time=").append(Integer.toString(this.on_time_scan)).append('\n')
                .append(" nan_scan_time=")
                .append(Integer.toString(this.on_time_nan_scan)).append('\n')
                .append(" g_scan_time=")
                .append(Integer.toString(this.on_time_background_scan)).append('\n')
                .append(" roam_scan_time=")
                .append(Integer.toString(this.on_time_roam_scan)).append('\n')
                .append(" pno_scan_time=")
                .append(Integer.toString(this.on_time_pno_scan)).append('\n')
                .append(" hs2.0_scan_time=")
                .append(Integer.toString(this.on_time_hs20_scan)).append('\n')
                .append(" tx_time_per_level=" + Arrays.toString(tx_time_per_level)).append('\n');
        int numChanStats = this.channelStatsMap.size();
        sbuf.append(" Number of channel stats=").append(numChanStats).append('\n');
        for (int i = 0; i < numChanStats; ++i) {
            ChannelStats channelStatsEntry = this.channelStatsMap.valueAt(i);
            sbuf.append(" Frequency=").append(channelStatsEntry.frequency)
                    .append(" radioOnTimeMs=").append(channelStatsEntry.radioOnTimeMs)
                    .append(" ccaBusyTimeMs=").append(channelStatsEntry.ccaBusyTimeMs).append('\n');
        }
        sbuf.append(" ts=" + timeStampInMs);
        return sbuf.toString();
    }

}