⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ttlmetric.java

📁 利用Java Socket写的一段通讯协议
💻 JAVA
字号:
package com.ict.netcom2.metric;

import java.nio.ByteBuffer;

/**
 * 7 * 24 = 168 bytes
 * @author as
 *
 */
public class TTLMetric {	
	
	public static final int length = 168;

	public MetricUnit less5 = new MetricUnit(); // ttl值<5

	public MetricUnit less10 = new MetricUnit(); // ttl值在5到10之间

	public MetricUnit less20 = new MetricUnit(); // ttl值在10到20之间

	public MetricUnit less40 = new MetricUnit(); // ttl值在20到40之间

	public MetricUnit less80 = new MetricUnit(); // ttl值在40到80之间

	public MetricUnit less128 = new MetricUnit(); // ttl值在80到128之间

	public MetricUnit more128 = new MetricUnit(); // ttl值大于128
	
	public void store(byte[] result) {
		
		if (result.length != length) {
			System.err.println("[TTLMetric.store()] param len wrong.");
		}
		
		ByteBuffer buf = ByteBuffer.wrap(result);
		
		byte[] b = new byte[MetricUnit.length];
		buf.get(b);
		less5.store(b); // ttl值<5

		buf.get(b);
		less10.store(b); // ttl值在5到10之间

		buf.get(b);
		less20.store(b); // ttl值在10到20之间

		buf.get(b);
		less40.store(b); // ttl值在20到40之间

		buf.get(b);
		less80.store(b); // ttl值在40到80之间

		buf.get(b);
		less128.store(b); // ttl值在80到128之间

		buf.get(b);
		more128.store(b); // ttl值大于128
	}
}

⌨️ 快捷键说明

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