ip-packet
Encode/decode raw ip packets
npm install ip-packet
Usage
var ip =var buf = ipconsole // prints out the decoded packet
API
buffer = ip.encode(packet, [buffer], [offset])
Encode a packet. A packet should look like this
version: 4dscp: 0ecn: 0identification: 0flags: 0fragmentOffset: 0ttl: 0protocol: 0sourceIp: '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 to0x0000
License
MIT