Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 114 lines (100 sloc) 2.681 kB
b567b74 @mranney Add simple README
authored
1 node_pcap
2 =========
3
4 This is not done yet. If you want to see how awesome it will be, check this out:
5
6 Run the test program as root to be able to open the capture device:
7
8 mjr:~/work/node_pcap$ sudo node test.js
9
06423e3 @mranney Update examples.
authored
10 ## Usage
b567b74 @mranney Add simple README
authored
11
06423e3 @mranney Update examples.
authored
12 var pcap = require("./pcap");
13
14 session = pcap.createSession("en0", "port 22");
15 session.addListener('packet', function (pcap_header, raw_packet) {
16 decoded = decode_packet(pcap_header, raw_packet);
17 sys.puts((pcap_header.time - start_time) + "ms len: " + pcap_header.len + " " +
18 decoded.ethernet.shost + " " + decoded.ethernet.dhost + " " +
19 sys.inspect(decoded.ip) + sys.inspect(decoded.tcp)
20 );
21 });
b567b74 @mranney Add simple README
authored
22
06423e3 @mranney Update examples.
authored
23 ## Output from `findalldevs`:
b567b74 @mranney Add simple README
authored
24
25 [ { name: 'en0'
26 , addresses:
27 [ { addr: '10.51.2.183'
28 , netmask: '255.255.255.0'
29 , broadaddr: '10.51.2.255'
30 }
31 ]
32 }
33 , { name: 'fw0', addresses: [] }
34 , { name: 'en1', addresses: [] }
35 , { name: 'lo0'
36 , addresses: [ { addr: '127.0.0.1', netmask: '255.0.0.0' } ]
37 , flags: 'PCAP_IF_LOOPBACK'
38 }
39 ]
40
06423e3 @mranney Update examples.
authored
41 ## Ethernet, IP, and TCP decode:
b567b74 @mranney Add simple README
authored
42
06423e3 @mranney Update examples.
authored
43 5060ms len: 78 00:17:f2:0f:49:a6 00:1e:c9:45:e8:30 { version: 4
44 , header_length: 5
45 , diffserv: 0
46 , total_length: 64
47 , identification: 21049
48 , flag_reserved: 0
49 , flag_df: 1
50 , flag_mf: 0
51 , fragment_offset: 0
52 , ttl: 64
53 , protocol: 6
54 , header_checksum: 0
55 , saddr: '10.51.2;183'
56 , daddr: '184.72.56;14'
57 , protocol_name: 'TCP'
58 }{ sport: 56051
59 , dport: 22
60 , seqno: 2449256658
61 , ackno: 0
62 , data_offset: 11
63 , reserved: 0
64 , flag_cwr: 0
65 , flag_ece: 0
66 , flag_urg: 0
67 , flag_ack: 0
68 , flag_psh: 0
69 , flag_rst: 0
70 , flag_syn: 1
71 , flag_fin: 0
72 , window_size: 65535
73 , checksum: 64882
74 , urgent_pointer: 0
b567b74 @mranney Add simple README
authored
75 }
06423e3 @mranney Update examples.
authored
76 5066ms len: 78 00:1e:c9:45:e8:30 00:17:f2:0f:49:a6 { version: 4
77 , header_length: 5
78 , diffserv: 0
79 , total_length: 60
80 , identification: 0
81 , flag_reserved: 0
82 , flag_df: 1
83 , flag_mf: 0
84 , fragment_offset: 0
85 , ttl: 49
86 , protocol: 6
87 , header_checksum: 19580
88 , saddr: '184.72.56;14'
89 , daddr: '10.51.2;183'
90 , protocol_name: 'TCP'
91 }{ sport: 22
92 , dport: 56051
93 , seqno: 2268319228
94 , ackno: 2449256659
95 , data_offset: 10
96 , reserved: 0
97 , flag_cwr: 0
98 , flag_ece: 0
99 , flag_urg: 0
100 , flag_ack: 1
101 , flag_psh: 0
102 , flag_rst: 0
103 , flag_syn: 1
104 , flag_fin: 0
105 , window_size: 5792
106 , checksum: 28115
107 , urgent_pointer: 0
108 }
109
110 ## Output from `pcap_stats`:
b567b74 @mranney Add simple README
authored
111
112 { ps_recv: 17, ps_drop: 0, ps_ifdrop: 1606411320 }
113
Something went wrong with that request. Please try again.