Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update examples.

  • Loading branch information...
commit 06423e3dc34a3bc2422d26818d3ae3b0777d97ad 1 parent 7579f4e
@mranney authored
Showing with 80 additions and 135 deletions.
  1. +80 −135 README.md
View
215 README.md
@@ -7,19 +7,21 @@ Run the test program as root to be able to open the capture device:
mjr:~/work/node_pcap$ sudo node test.js
-Here is the "API":
+## Usage
- DEBUG: { findalldevs: [Function]
- , open_live: [Function]
- , dispatch: [Function]
- , fileno: [Function]
- , close: [Function]
- , stats: [Function]
- }
+ var pcap = require("./pcap");
+
+ session = pcap.createSession("en0", "port 22");
+ session.addListener('packet', function (pcap_header, raw_packet) {
+ decoded = decode_packet(pcap_header, raw_packet);
+ sys.puts((pcap_header.time - start_time) + "ms len: " + pcap_header.len + " " +
+ decoded.ethernet.shost + " " + decoded.ethernet.dhost + " " +
+ sys.inspect(decoded.ip) + sys.inspect(decoded.tcp)
+ );
+ });
-Output from `findalldevs`:
+## Output from `findalldevs`:
- open_live starting en0
[ { name: 'en0'
, addresses:
[ { addr: '10.51.2.183'
@@ -36,133 +38,76 @@ Output from `findalldevs`:
}
]
-114 bytes of actual packet, one byte at a time, not in any way decoded:
+## Ethernet, IP, and TCP decode:
- DEBUG: readWatcher callback
- packet no: 1, 1274297591.327988, length: 114
- DEBUG: callback called back.
- Header:
- { time: Wed, 19 May 2010 19:33:11 GMT
- , caplen: 114
- , len: 114
+ 5060ms len: 78 00:17:f2:0f:49:a6 00:1e:c9:45:e8:30 { version: 4
+ , header_length: 5
+ , diffserv: 0
+ , total_length: 64
+ , identification: 21049
+ , flag_reserved: 0
+ , flag_df: 1
+ , flag_mf: 0
+ , fragment_offset: 0
+ , ttl: 64
+ , protocol: 6
+ , header_checksum: 0
+ , saddr: '10.51.2;183'
+ , daddr: '184.72.56;14'
+ , protocol_name: 'TCP'
+ }{ sport: 56051
+ , dport: 22
+ , seqno: 2449256658
+ , ackno: 0
+ , data_offset: 11
+ , reserved: 0
+ , flag_cwr: 0
+ , flag_ece: 0
+ , flag_urg: 0
+ , flag_ack: 0
+ , flag_psh: 0
+ , flag_rst: 0
+ , flag_syn: 1
+ , flag_fin: 0
+ , window_size: 65535
+ , checksum: 64882
+ , urgent_pointer: 0
}
- Packet:
- 0: 0
- 1: 30
- 2: 201
- 3: 69
- 4: 232
- 5: 48
- 6: 0
- 7: 23
- 8: 242
- 9: 15
- 10: 73
- 11: 166
- 12: 8
- 13: 0
- 14: 69
- 15: 16
- 16: 0
- 17: 100
- 18: 79
- 19: 217
- 20: 64
- 21: 0
- 22: 64
- 23: 6
- 24: 0
- 25: 0
- 26: 10
- 27: 51
- 28: 2
- 29: 183
- 30: 184
- 31: 72
- 32: 56
- 33: 14
- 34: 194
- 35: 128
- 36: 0
- 37: 22
- 38: 35
- 39: 18
- 40: 29
- 41: 237
- 42: 204
- 43: 198
- 44: 127
- 45: 66
- 46: 128
- 47: 24
- 48: 255
- 49: 255
- 50: 253
- 51: 150
- 52: 0
- 53: 0
- 54: 1
- 55: 1
- 56: 8
- 57: 10
- 58: 30
- 59: 53
- 60: 251
- 61: 183
- 62: 25
- 63: 167
- 64: 111
- 65: 129
- 66: 79
- 67: 239
- 68: 209
- 69: 172
- 70: 31
- 71: 174
- 72: 86
- 73: 55
- 74: 64
- 75: 127
- 76: 107
- 77: 87
- 78: 148
- 79: 233
- 80: 9
- 81: 97
- 82: 107
- 83: 118
- 84: 181
- 85: 185
- 86: 21
- 87: 17
- 88: 164
- 89: 241
- 90: 194
- 91: 137
- 92: 91
- 93: 224
- 94: 66
- 95: 149
- 96: 22
- 97: 194
- 98: 205
- 99: 229
- 100: 234
- 101: 98
- 102: 117
- 103: 198
- 104: 136
- 105: 205
- 106: 181
- 107: 146
- 108: 223
- 109: 34
- 110: 214
- 111: 15
- 112: 246
- 113: 132
-
-Output from `pcap_stats`:
+ 5066ms len: 78 00:1e:c9:45:e8:30 00:17:f2:0f:49:a6 { version: 4
+ , header_length: 5
+ , diffserv: 0
+ , total_length: 60
+ , identification: 0
+ , flag_reserved: 0
+ , flag_df: 1
+ , flag_mf: 0
+ , fragment_offset: 0
+ , ttl: 49
+ , protocol: 6
+ , header_checksum: 19580
+ , saddr: '184.72.56;14'
+ , daddr: '10.51.2;183'
+ , protocol_name: 'TCP'
+ }{ sport: 22
+ , dport: 56051
+ , seqno: 2268319228
+ , ackno: 2449256659
+ , data_offset: 10
+ , reserved: 0
+ , flag_cwr: 0
+ , flag_ece: 0
+ , flag_urg: 0
+ , flag_ack: 1
+ , flag_psh: 0
+ , flag_rst: 0
+ , flag_syn: 1
+ , flag_fin: 0
+ , window_size: 5792
+ , checksum: 28115
+ , urgent_pointer: 0
+ }
+
+## Output from `pcap_stats`:
{ ps_recv: 17, ps_drop: 0, ps_ifdrop: 1606411320 }
Please sign in to comment.
Something went wrong with that request. Please try again.