View Javadoc
1   /*
2    * Copyright 2014 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. 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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package io.netty.channel.epoll;
17  
18  /**
19   * <p>
20   * struct tcp_info
21   * {
22   *      __u8    tcpi_state;
23   *      __u8    tcpi_ca_state;
24   *      __u8    tcpi_retransmits;
25   *      __u8    tcpi_probes;
26   *      __u8    tcpi_backoff;
27   *      __u8    tcpi_options;
28   *      __u8    tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
29   *
30   *      __u32   tcpi_rto;
31   *      __u32   tcpi_ato;
32   *      __u32   tcpi_snd_mss;
33   *      __u32   tcpi_rcv_mss;
34   *
35   *      __u32   tcpi_unacked;
36   *      __u32   tcpi_sacked;
37   *      __u32   tcpi_lost;
38   *      __u32   tcpi_retrans;
39   *      __u32   tcpi_fackets;
40   *
41   *      __u32   tcpi_last_data_sent;
42   *      __u32   tcpi_last_ack_sent;
43   *      __u32   tcpi_last_data_recv;
44   *      __u32   tcpi_last_ack_recv;
45   *
46   *      __u32   tcpi_pmtu;
47   *      __u32   tcpi_rcv_ssthresh;
48   *      __u32   tcpi_rtt;
49   *      __u32   tcpi_rttvar;
50   *      __u32   tcpi_snd_ssthresh;
51   *      __u32   tcpi_snd_cwnd;
52   *      __u32   tcpi_advmss;
53   *      __u32   tcpi_reordering;
54   *
55   *      __u32   tcpi_rcv_rtt;
56   *      __u32   tcpi_rcv_space;
57   *
58   *      __u32   tcpi_total_retrans;
59   * };
60   * </p>
61   */
62  public final class EpollTcpInfo {
63  
64      final int[] info = new int[32];
65  
66      public int state() {
67          return info[0] & 0xFF;
68      }
69  
70      public int caState() {
71          return info[1] & 0xFF;
72      }
73  
74      public int retransmits() {
75          return info[2] & 0xFF;
76      }
77  
78      public int probes() {
79          return info[3] & 0xFF;
80      }
81  
82      public int backoff() {
83          return info[4] & 0xFF;
84      }
85  
86      public int options() {
87          return info[5] & 0xFF;
88      }
89  
90      public int sndWscale() {
91          return info[6] & 0xFF;
92      }
93  
94      public int rcvWscale() {
95          return info[7] & 0xFF;
96      }
97  
98      public long rto() {
99          return info[8] & 0xFFFFFFFFL;
100     }
101 
102     public long ato() {
103         return info[9] & 0xFFFFFFFFL;
104     }
105 
106     public long sndMss() {
107         return info[10] & 0xFFFFFFFFL;
108     }
109 
110     public long rcvMss() {
111         return info[11] & 0xFFFFFFFFL;
112     }
113 
114     public long unacked() {
115         return info[12] & 0xFFFFFFFFL;
116     }
117 
118     public long sacked() {
119         return info[13] & 0xFFFFFFFFL;
120     }
121 
122     public long lost() {
123         return info[14] & 0xFFFFFFFFL;
124     }
125 
126     public long retrans() {
127         return info[15] & 0xFFFFFFFFL;
128     }
129 
130     public long fackets() {
131         return info[16] & 0xFFFFFFFFL;
132     }
133 
134     public long lastDataSent() {
135         return info[17] & 0xFFFFFFFFL;
136     }
137 
138     public long lastAckSent() {
139         return info[18] & 0xFFFFFFFFL;
140     }
141 
142     public long lastDataRecv() {
143         return info[19] & 0xFFFFFFFFL;
144     }
145 
146     public long lastAckRecv() {
147         return info[20] & 0xFFFFFFFFL;
148     }
149 
150     public long pmtu() {
151         return info[21] & 0xFFFFFFFFL;
152     }
153 
154     public long rcvSsthresh() {
155         return info[22] & 0xFFFFFFFFL;
156     }
157 
158     public long rtt() {
159         return info[23] & 0xFFFFFFFFL;
160     }
161 
162     public long rttvar() {
163         return info[24] & 0xFFFFFFFFL;
164     }
165 
166     public long sndSsthresh() {
167         return info[25] & 0xFFFFFFFFL;
168     }
169 
170     public long sndCwnd() {
171         return info[26] & 0xFFFFFFFFL;
172     }
173 
174     public long advmss() {
175         return info[27] & 0xFFFFFFFFL;
176     }
177 
178     public long reordering() {
179         return info[28] & 0xFFFFFFFFL;
180     }
181 
182     public long rcvRtt() {
183         return info[29] & 0xFFFFFFFFL;
184     }
185 
186     public long rcvSpace() {
187         return info[30] & 0xFFFFFFFFL;
188     }
189 
190     public long totalRetrans() {
191         return info[31] & 0xFFFFFFFFL;
192     }
193 }