node_pcap解析数据包
node_pcap 是从 libpcap 到 Node.js 的绑定集,提供有用的库来解码,打印和解析数据包。
node_pcap
虽然很有用,但是并不是理解所有的协议。
示例:
var pcap = require('pcap'), tcp_tracker = new pcap.TCP_tracker(), pcap_session = pcap.createSession(interface, "ip proto \\tcp"); tcp_tracker.on('start', function (session) { console.log("Start of TCP session between " + session.src_name + " and " + session.dst_name); }); tcp_tracker.on('end', function (session) { console.log("End of TCP session between " + session.src_name + " and " + session.dst_name); }); pcap_session.on('packet', function (raw_packet) { var packet = pcap.decode.packet(raw_packet); tcp_tracker.track_packet(packet); });
评论