Socket
Book a DemoInstallSign in
Socket

ip-packet

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip-packet

Encode/decode raw ip packets

Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

ip-packet

Encode/decode raw ip packets

npm install ip-packet

build status

Usage

var ip = require('ip-packet')

var buf = ip.encode({
  version: 4,
  protocol: 0,
  sourceIp: '127.0.0.1',
  destinationIp: '127.0.0.1',
  data: new Buffer('some data')
})

console.log(ip.decode(buf)) // prints out the decoded packet

API

buffer = ip.encode(packet, [buffer], [offset])

Encode a packet. A packet should look like this

{
  version: 4,
  dscp: 0,
  ecn: 0,
  identification: 0,
  flags: 0,
  fragmentOffset: 0,
  ttl: 0,
  protocol: 0,
  sourceIp: '127.0.0.1',
  destinationIp: '127.0.0.1',
  data: <Buffer>
}

`packet = ip.decode(buffer, [offset])

Decode a packet. Throws an exception if the packet contains a bad checksum.

length = ip.encodingLength(packet)

Returns the byte length of the packet encoded

configure = ip.configure(options)

Returns ip-packet configured with options.

Options:

  • allowNullChecksum. When decoding, ignore checksums set to 0x0000

License

MIT

FAQs

Package last updated on 25 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts