I’m trying to analyze the raw NetFlow data coming from a Mikrotik using Python.
The Mikrotik is configured to send IPFIX data to my machine.
It looks like one of the few available pieces of code that can analyze IPFIX data is found in PyPi: https://pypi.org/project/ipfix/#description
I’m having trouble using it though.
I’m trying something like this:
import socket
import ipfix.message
sock = socket.socket(socket.AF_INET, socket.SOCK_DRAM)
sock.bind(('0.0.0.0', 1234))
msg = ipfix.message.MessageBuffer()
while True:
data, addr = sock.recvfrom(1024)
msg.from_bytes(data)
print(msg)
I think there’s probably more to printing “msg” than just “print(msg)”, but it won’t even get that far. It crashes on the “msg.from_bytes(data)” line, saying: “ipfix.template.IpfixDecodeError: (‘Illegal message length7’,)”.
Anyone either know how to use the ipfix python library, or any other, easier way to read NetFlow data coming from a Mikrotik?