📄 rawmetric.java
字号:
package com.ict.netcom2.metric;
import java.nio.*;
/**
* 基本统计信息,不同协议流量统计,包大小统计及IPv4流统计信息
*
*/
public class RawMetric {
public static final int length = 8576;
public int refresh_time;
public int reserved;
public MacMetric mac_stat = new MacMetric();
// 每个成员表示包大小位于{(64*i,64*(i+1)>}之间的包个数信息
// 对于大于1500的数据包个数统计,我们放在了24里面
public MetricUnit[] mac_size_dist = new MetricUnit[25];
// 如果定义了IPv4流量监测,缺省支持
public IPMetric ipv4 = new IPMetric(); // IPv4层协议统计信息
public TCPMetric tcp4 = new TCPMetric(); // 基于IPv4的TCP层协议统计信息
public UDPMetric udp4 = new UDPMetric(); // 基于IPv4的UDP层协议统计信息
public ICMPv4Metric icmpv4 = new ICMPv4Metric(); // ICMPv4消息分类统计
public FlowMetric flow4 = new FlowMetric(); // 基于IPv4的流统计信息
public IPMetric ipv6 = new IPMetric(); // IPv6层协议统计信息
public TCPMetric tcp6 = new TCPMetric(); // 基于IPv6的TCP层协议统计信息
public UDPMetric udp6 = new UDPMetric(); // 基于IPv6的UDP层协议统计信息
public ICMPv6Metric icmpv6 = new ICMPv6Metric(); // ICMPv6消息分类统计
public NewAppMetric newapp = new NewAppMetric(); // 新增应用层协议统计 //--guangxing & pengda 于20060414添加--
public RawMetric() {
for (int i=0; i<25; i++) {
mac_size_dist[i] = new MetricUnit();
}
}
public void store(byte[] result) {
if (result.length != length) {
System.err.println("[RawMetric.store()] param len wrong.");
}
ByteBuffer buf = ByteBuffer.wrap(result);
buf.order(ByteOrder.LITTLE_ENDIAN);
refresh_time = buf.getInt();
reserved = buf.getInt();
byte[] b = new byte[MacMetric.length];
buf.get(b);
mac_stat.store(b);
b = new byte[MetricUnit.length];
for (int i=0; i<25; i++) {
buf.get(b);
mac_size_dist[i].store(b);
}
b = new byte[IPMetric.length];
buf.get(b);
ipv4.store(b); // IPv4层协议统计信息
b = new byte[TCPMetric.length];
buf.get(b);
tcp4.store(b); // 基于IPv4的TCP层协议统计信息
b = new byte[UDPMetric.length];
buf.get(b);
udp4.store(b); // 基于IPv4的UDP层协议统计信息
b = new byte[ICMPv4Metric.length];
buf.get(b);
icmpv4.store(b); // ICMPv4消息分类统计
b = new byte[FlowMetric.length];
buf.get(b);
flow4.store(b); // 基于IPv4的流统计信息
b = new byte[IPMetric.length];
buf.get(b);
ipv6.store(b); // IPv6层协议统计信息
b = new byte[TCPMetric.length];
buf.get(b);
tcp6.store(b); // 基于IPv6的TCP层协议统计信息
b = new byte[UDPMetric.length];
buf.get(b);
udp6.store(b); // 基于IPv6的UDP层协议统计信息
b = new byte[ICMPv6Metric.length];
buf.get(b);
icmpv6.store(b); // ICMPv6消息分类统计
b = new byte[NewAppMetric.length];
buf.get(b);
newapp.store(b); // 新增应用层协议统计
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -