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

📄 tcpmetric.java

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

import java.nio.ByteBuffer;

/**
 * 44 * 24 = 1056 bytes
 */
public class TCPMetric {	
	
	public static final int length = 1056;

	public MetricUnit http = new MetricUnit(); // 80

	public MetricUnit ssh = new MetricUnit(); // 22 SSH remote login

	public MetricUnit ftp_ctl = new MetricUnit(); // 21

	public MetricUnit ftp_data = new MetricUnit(); // 20

	public MetricUnit smtp = new MetricUnit(); // 25

	public MetricUnit rap = new MetricUnit(); // 38 Internet route access protocol

	public MetricUnit whois = new MetricUnit(); // 43,63(whois++)

	public MetricUnit imp = new MetricUnit(); // 45,Internet message protocol

	public MetricUnit finger = new MetricUnit(); // 79

	public MetricUnit pop3 = new MetricUnit(); // 110

	public MetricUnit dns = new MetricUnit(); // 53

	public MetricUnit telnet = new MetricUnit(); // 23

	public MetricUnit telnets = new MetricUnit(); // 992

	public MetricUnit nntp = new MetricUnit(); // 119,Network News Transfer Protocol

	public MetricUnit pop2 = new MetricUnit(); // 109

	public MetricUnit pop3s = new MetricUnit(); // 995

	public MetricUnit gopher = new MetricUnit(); // 70; distributed document search and retrieval protocol

	public MetricUnit irc = new MetricUnit(); // 194 Internet relay chat protocol

	public MetricUnit imap = new MetricUnit(); // 143 Internet Message Access Protocol 220 imap3

	public MetricUnit bgp = new MetricUnit(); // BGP 179

	public MetricUnit bgmp = new MetricUnit(); // 264,Border gateway multicast protocol

	public MetricUnit imaps = new MetricUnit(); // 993

	public MetricUnit sftp = new MetricUnit(); // 115; Simple File Transfer Protocol

	public MetricUnit megaco = new MetricUnit(); // 2944-Text; 2945-binary; Media Gateway Control

	public MetricUnit rtsp = new MetricUnit(); // 554Real Time Streaming Protocol

	public MetricUnit ldp = new MetricUnit(); // 646; Label Distribution Protocol

	public MetricUnit sip = new MetricUnit(); // 5060-SCTP,TCP,UDP, 5061-TLS; Session Initiation Protocol

	public MetricUnit https = new MetricUnit(); // 443

	public MetricUnit ftps_ctrl = new MetricUnit(); // 990

	public MetricUnit ftps_data = new MetricUnit(); // 989

	public MetricUnit smtps = new MetricUnit(); // 465

	public MetricUnit chat = new MetricUnit(); // 531

	public MetricUnit nntps = new MetricUnit(); // 563

	public MetricUnit ircs = new MetricUnit(); // 994

	public MetricUnit socks = new MetricUnit(); // 1080

	public MetricUnit mul_conf = new MetricUnit(); // 1347,1348

	public MetricUnit wins = new MetricUnit(); // 1512

	public MetricUnit h323 = new MetricUnit(); // 1300,1718,1719,1720,2517,11720

	public MetricUnit pptp = new MetricUnit(); // 1723, Point to Point Tunneling Protocol.

	public MetricUnit lfap = new MetricUnit(); // 3145, Light-weight Flow Admission Protocol.

	public MetricUnit ifcp = new MetricUnit(); // 3420, Fibre Channel Over TCP/IP

	public MetricUnit diameter = new MetricUnit(); // 3868

	public MetricUnit trip = new MetricUnit(); // 6069, Telephone Routing over IP

	public MetricUnit unknow = new MetricUnit();
	

	
	public void store(byte[] result) {
		
		if (result.length != length) {
			System.err.println("[TCPMetric.store()] param len wrong.");
		}
		
		ByteBuffer buf = ByteBuffer.wrap(result);
		
		byte[] b = new byte[MetricUnit.length];
		buf.get(b);
		http.store(b); // 80

		buf.get(b);
		ssh.store(b); // 22 SSH remote login

		buf.get(b);
		ftp_ctl.store(b); // 21

		buf.get(b);
		ftp_data.store(b); // 20

		buf.get(b);
		smtp.store(b); // 25

		buf.get(b);
		rap.store(b); // 38 Internet route access protocol

		buf.get(b);
		whois.store(b); // 43,63(whois++)

		buf.get(b);
		imp.store(b); // 45,Internet message protocol

		buf.get(b);
		finger.store(b); // 79

		buf.get(b);
		pop3.store(b); // 110

		buf.get(b);
		dns.store(b); // 53

		buf.get(b);
		telnet.store(b); // 23

		buf.get(b);
		telnets.store(b); // 992

		buf.get(b);
		nntp.store(b); // 119,Network News Transfer Protocol

		buf.get(b);
		pop2.store(b); // 109

		buf.get(b);
		pop3s.store(b); // 995

		buf.get(b);
		gopher.store(b); // 70; distributed document search and retrieval protocol

		buf.get(b);
		irc.store(b); // 194 Internet relay chat protocol

		buf.get(b);
		imap.store(b); // 143 Internet Message Access Protocol 220 imap3

		buf.get(b);
		bgp.store(b); // BGP 179

		buf.get(b);
		bgmp.store(b); // 264,Border gateway multicast protocol

		buf.get(b);
		imaps.store(b); // 993

		buf.get(b);
		sftp.store(b); // 115; Simple File Transfer Protocol

		buf.get(b);
		megaco.store(b); // 2944-Text; 2945-binary; Media Gateway Control

		buf.get(b);
		rtsp.store(b); // 554Real Time Streaming Protocol

		buf.get(b);
		ldp.store(b); // 646; Label Distribution Protocol

		buf.get(b);
		sip.store(b); // 5060-SCTP,TCP,UDP, 5061-TLS; Session Initiation Protocol

		buf.get(b);
		https.store(b); // 443

		buf.get(b);
		ftps_ctrl.store(b); // 990

		buf.get(b);
		ftps_data.store(b); // 989

		buf.get(b);
		smtps.store(b); // 465

		buf.get(b);
		chat.store(b); // 531

		buf.get(b);
		nntps.store(b); // 563

		buf.get(b);
		ircs.store(b); // 994

		buf.get(b);
		socks.store(b); // 1080

		buf.get(b);
		mul_conf.store(b); // 1347,1348

		buf.get(b);
		wins.store(b); // 1512

		buf.get(b);
		h323.store(b); // 1300,1718,1719,1720,2517,11720

		buf.get(b);
		pptp.store(b); // 1723, Point to Point Tunneling Protocol.

		buf.get(b);
		lfap.store(b); // 3145, Light-weight Flow Admission Protocol.

		buf.get(b);
		ifcp.store(b); // 3420, Fibre Channel Over TCP/IP

		buf.get(b);
		diameter.store(b); // 3868

		buf.get(b);
		trip.store(b); // 6069, Telephone Routing over IP

		buf.get(b);
		unknow.store(b);
	}
}

⌨️ 快捷键说明

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