# ip-packet

> Encode/decode raw ip packets

Latest version **2.2.1** (published 2024-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install ip-packet
pnpm add ip-packet
yarn add ip-packet
bun add ip-packet
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.1 |
| Published | 2024-07-05 |
| First published | 2015-08-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/ip-packet) |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 45 |
| Author | Mathias Buus |
| Maintainers | freeall, mafintosh |

## Links

- npm: https://www.npmjs.com/package/ip-packet
- Repository: https://github.com/mafintosh/ip-packet
- Issues: https://github.com/mafintosh/ip-packet/issues
- npm.io page: https://npm.io/package/ip-packet

## Recent versions

- 2.2.1 (latest) — 2024-07-05
- 2.2.0 — 2024-07-04
- 2.1.1 — 2024-06-28
- 2.1.0 — 2024-06-28
- 2.0.1 — 2024-06-28
- 2.0.0 — 2024-06-28
- 1.1.0 — 2019-06-25
- 1.0.2 — 2015-08-10
- 1.0.1 — 2015-08-10
- 1.0.0 — 2015-08-10

## 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: <Buffer>
}
```

#### `packet = ip.decode(state)

Decode a packet.

#### `ip.preencode(state, packet)`

Preencode a packet.

## License

Apache-2.0

---
_Source: https://npm.io/package/ip-packet · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
