📄 icmpv4metric.java
字号:
package com.ict.netcom2.metric;
import java.nio.ByteBuffer;
import com.ict.netcom2.util.Shower;
/**
* 32 * 24 = 768 bytes
*
*/
public class ICMPv4Metric {
public static final int length = 768;
public MetricUnit echo_reply = new MetricUnit(); // Echo Reply
public MetricUnit echo = new MetricUnit(); // Echo
public MetricUnit[] dst_unreach = new MetricUnit[16]; // Destination Unreachable,数组下标表示code
public MetricUnit time_exceeded = new MetricUnit(); // Time Exceeded
public MetricUnit param_problem = new MetricUnit(); // Parameter Problem
public MetricUnit src_quench = new MetricUnit(); // Source Quench
public MetricUnit redirect = new MetricUnit(); // Redirect
public MetricUnit timestamp = new MetricUnit(); // Timestamp
public MetricUnit timestamp_reply = new MetricUnit(); // Timestamp Reply
public MetricUnit info_req = new MetricUnit(); // Information Request
public MetricUnit info_reply = new MetricUnit(); // Information Reply
public MetricUnit alter_addr = new MetricUnit(); // Alternate Address for Host
public MetricUnit router_adv = new MetricUnit(); // Router Advertisement
public MetricUnit router_selec = new MetricUnit(); // Router Selection
public MetricUnit addrmask_req = new MetricUnit(); // Address Mask Request
public MetricUnit addrmask_reply = new MetricUnit(); // Address Mask Reply
public MetricUnit traceroute = new MetricUnit(); // Traceroute
public ICMPv4Metric() {
for (int i=0; i<16; i++) {
dst_unreach[i] = new MetricUnit();
}
}
public void store(byte[] result) {
if (result.length != length) {
System.err.println("[ICMPv4Metric.store()] param len wrong.");
}
ByteBuffer buf = ByteBuffer.wrap(result);
byte[] b = new byte[MetricUnit.length];
buf.get(b);
echo_reply.store(b);
buf.get(b);
echo.store(b);
for (int i=0; i<16; i++) {
buf.get(b);
dst_unreach[i].store(b);
}
buf.get(b);
time_exceeded.store(b);
buf.get(b);
param_problem.store(b);
buf.get(b);
src_quench.store(b);
buf.get(b);
redirect.store(b);
buf.get(b);
timestamp.store(b);
buf.get(b);
timestamp_reply.store(b);
buf.get(b);
info_req.store(b);
buf.get(b);
info_reply.store(b);
buf.get(b);
alter_addr.store(b);
buf.get(b);
router_adv.store(b);
buf.get(b);
router_selec.store(b);
buf.get(b);
addrmask_req.store(b);
buf.get(b);
addrmask_reply.store(b);
buf.get(b);
traceroute.store(b);
}
public static void main(String[] args) {
byte[] result = {0,0,0,0,0,0,0,1,
0,0,0,0,0,0,0,2,
0,0,0,3,0,0,0,-1};
ByteBuffer buf = ByteBuffer.wrap(result);
byte[] b = new byte[8];
buf.get(b);
buf.get(b);
Shower.showInVal(b);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -