Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mafintosh/ip-packet
Encode/decode raw ip packets
https://github.com/mafintosh/ip-packet
Last synced: 23 days ago
JSON representation
Encode/decode raw ip packets
- Host: GitHub
- URL: https://github.com/mafintosh/ip-packet
- Owner: mafintosh
- License: mit
- Created: 2015-08-10T15:33:57.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-06-25T07:45:54.000Z (over 5 years ago)
- Last Synced: 2024-05-11T21:22:51.761Z (8 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 41
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-network-js - ip-packet
README
# ip-packet
Encode/decode raw ip packets
```
npm install ip-packet
```## Usage
``` js
// compact-encoder
const ip = require('ip-packet')ip.encode(state, { version, ... })
console.log(ip.decode(state))
```## API
#### `ip.encode(state, packet)`
Encode a packet. A packet should look like this
``` js
{
version: 4,
dscp: 0,
ecn: 0,
identification: 0,
flags: 0,
fragmentOffset: 0,
ttl: 0,
protocol: 0,
checksum: 0,
sourceIp: '127.0.0.1',
destinationIp: '127.0.0.1',
data:
}
```#### `packet = ip.decode(state)
Decode a packet.
#### `ip.preencode(state, packet)`
Preencode a packet.
## License
Apache-2.0