Encode/decode raw ip packets
npm install ip-packet
// compact-encoder
const ip = require('ip-packet')
ip.encode(state, { version, ... })
console.log(ip.decode(state))
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,
checksum: 0,
sourceIp: '127.0.0.1',
destinationIp: '127.0.0.1',
data: <Buffer>
}
Decode a packet.
Preencode a packet.
Apache-2.0