https://github.com/txchen/p-by-p
Packet-By-Packet, a pcap reader inspired by line-by-line and pcap-reader
https://github.com/txchen/p-by-p
Last synced: 9 months ago
JSON representation
Packet-By-Packet, a pcap reader inspired by line-by-line and pcap-reader
- Host: GitHub
- URL: https://github.com/txchen/p-by-p
- Owner: txchen
- License: mit
- Created: 2018-02-23T21:30:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-24T21:54:34.000Z (over 8 years ago)
- Last Synced: 2025-02-15T04:46:36.156Z (over 1 year ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# p-by-p
Packet-By-Packet, a pcap reader inspired by line-by-line and pcap-reader
## Installation
```bash
npm install p-by-p
```
## Usage
```js
const PacketByPacket = require('p-by-p')
const readline = require('readline')
const pbyp = PacketByPacket('/path/to/file.pcap')
// setup event handler
pbyp.on('globalHeader', gh => {
// process pcap file global header
})
pbyp.on('packet', p => {
// process your packet data
// you can also stop/resume the reader
pbyp.pause()
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
rl.question(`Do you want to resume?`, (answer) => {
pbyp.resume()
rl.close()
})
})
pbyp.on('end', () => {
// no more data
})
pbyp.on('error', err => {})
// start it
pbyp.resume()
```