mscdex / cap

A cross-platform binding for performing packet capturing with node.js
MIT License
361 stars 45 forks source link

Buffered packet #49

Closed robsontenorio closed 7 years ago

robsontenorio commented 7 years ago

Is there any way to make the event on('packet') buffered?

Some times a packet should be buffered before returning the full payload.

mscdex commented 7 years ago

There is no knowledge of application-level protocols at the packet capturing level, so you have to be prepared to buffer as needed. For TCP it's just a stream of bytes, so it's especially difficult to know when there is a "full payload."

robsontenorio commented 7 years ago

This question is based on a very known lib https://linux.die.net/man/8/ngrep

Some parameters(-l combined with -W) allow us to buff "stdout" in order to avoid "line by line" packet output. Its more like packet display format.

Any chance to achieve that ?

mscdex commented 7 years ago

I still don't understand what you're after. libpcap is already buffering up packets. Those are being delivered via the 'packet' event. ngrep's buffering of stdout has nothing to do with the packets being captured, it's merely describing how the data is delivered via local stdio.