Data::...etflow(3pm)

πŸ“¦
version 0.31 Β· 4 versions
, in debian bookworm, ubuntu jammy

<div></div>

okay so hi bestie 🫢 you just opened the Data::...etflow(3pm) page β€” yeah the header name got a lil truncated, it's giving "mysterious icon", but it's part of the User Contributed Perl Documentation and it's genuinely so useful. Sit down, sip ur drink, we're parsing binary Netflow PDUs together πŸ’…


πŸ‘‘ NAME πŸ‘‘

Data::ParseBinary::Data::Netflow β€” parsing Netflow PDU binary structures. That's it, that's the whole job. You hand it Netflow binary PDUs, it parses them. Iconic behaviour honestly ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

use Data::ParseBinary::Data::Netflow qw($netflow_v5_parser);
$data = $netflow_v5_parser->parse(CreateStreamReader(File => $fh));
# If file contain multiple flows, parse them till EOF
while () {
    last if eof($fh);
    $data = $netflow_v5_parser->parse(CreateStreamReader(File => $fh));
}

so you import $netflow_v5_parser with that qw(...) list, then call ->parse(...) on it while feeding it a CreateStreamReader(File => $fh) β€” that's your stream reader, it's the main character here πŸ”₯

and if your file is stuffed with multiple flows (same, bestie, same), you just loop: bail out the second eof($fh) says we're done, otherwise keep calling $netflow_v5_parser->parse(...) on a fresh reader every time. Like a lil conveyor belt of flows 🌈


πŸŽ€ CAVEAT πŸŽ€

okay so real talk, read this part twice, it matters πŸ’€

as of right now, version 5 format is supported only. that's it, that's the one. no v9, no v10, just v5 living its best life. don't come for me, it's literally what the docs say πŸ™ˆ

and you gotta read files only in network byte order (BE). like, only BE. not little-endian, not "eh it's probably fine" β€” BE. periodt πŸ’…

also, this module is a part of the Data::ParseBinary package, and it's just one ready-made parser sitting in there. if you want the full lore, the additional usage info lives on the main page β€” go read it, iykyk 🌸


okay and for the cute sign-off: this lil page is perl v5.32.0, dated 2021-01-04, and it's brought to you by User Contributed Perl Documentation β€” a true classic, an heirloom, we love her πŸ’– thanks for coming to my ted talk, go parse some flows bestie 🧚✨

πŸ“¦ where this page comes from