ip-stream
IP header serialization object stream.
Example
Reading
var IpStream = ;var EtherStream = ;var PcapStream = ; var pstream = PCAP_FILE;var estream = ;var ipstream = ; pstream; ipstream; // Packets that cannot be parsed as IP are emitted with 'ignored' eventipstream; ipstream; // you can also control how fragments are handledvar ipsream2 = fragments: 'reassemble'; // the defaultvar ipsream3 = fragments: 'drop'; // ignore fragmentsvar ipsream4 = fragments: 'pass'; // passthrough frags // When reassembling, unmatched fragments are timed-out after 30 seconds by// default, but you can configure that:var ipstream5 = fragmentTimeout: 5000;
Writing
var IpStream = ;var EtherStream = ;var IpHeader = ;var EtherFrame = ; var estream = ;var ipstream = ; estream; // define the content to write out to the buffervar input = ether: dst: '01:23:45:54:32:10' ip: dst: '1.1.1.1' dataLength: 500 data: 8*1024 // adequate storage for header; // NOTE: packet payload is not input.data, that must be appended later estream;var output = ipstream; // header values have been written to the bufferoutoffset === inputetherlength * inputiplength;test;test;