flowpktdistmetric.java

来自「利用Java Socket写的一段通讯协议」· Java 代码 · 共 50 行

JAVA
50
字号
package com.ict.netcom2.metric;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/**
 * 流大小分布统计,按照包个数 
 * 32 bytes
 */
public class FlowPktDistMetric {

	public static final int length = 32;

	public int less10; // 包个数<=10的流个数

	public int less50; // 包个数在10~50之间的流个数

	public int less100; // 包个数在50~100之间的流个数

	public int less200; // 包个数在100~200之间的流个数

	public int less400; // 包个数在200~400之间的流个数

	public int less600; // 包个数在400~600之间的流个数

	public int less1000; // 包个数在600~1000之间的流个数

	public int more1000; // 包个数>1000的流个数

	public void store(byte[] result) {
		
		if (result.length != length) {
			System.err.println("[FlowPktDistMetric.store()] param len wrong.");
		}
		
		ByteBuffer buf = ByteBuffer.wrap(result);
		buf.order(ByteOrder.LITTLE_ENDIAN);
		
		this.less10 = buf.getInt();
		this.less50 = buf.getInt();
		this.less100 = buf.getInt();
		this.less200 = buf.getInt();
		this.less400 = buf.getInt();
		this.less600 = buf.getInt();
		this.less1000 = buf.getInt();
		this.more1000 = buf.getInt();
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?