bitkeks / python-netflow-v9-softflowd

PyPI "netflow" package. NetFlow v9 parser, collector and analyzer implemented in Python 3. Developed and tested with softflowd
https://bitkeks.eu/blog/2016/08/collecting-netflow-v9-on-openwrt.html
MIT License
110 stars 56 forks source link

Implement options templates/data records #30

Closed bitkeks closed 2 years ago

bitkeks commented 3 years ago

As noted in #29, options templates and options data records are missing a correct implementation. The current workaround is a for flowsets with ID 1, which is always the Options Template Flowset. The mixing might lead to errors, therefore correct handling is needed

cc @j-licht

bitkeks commented 3 years ago

@j-licht could you please try e43980f in your setup?

j-licht commented 3 years ago

@bitkeks works for me

bitkeks commented 3 years ago

Thanks for testing! I'll include this fix in the next version/release.

bitkeks commented 3 years ago

@j-licht could you please try again with commit 5adde00 ?

j-licht commented 3 years ago

I've get this, maybe only python 3.8 related error:

Traceback (most recent call last):
  File "./main.py", line 20, in <module>
    export = netflow.parse_packet(binascii.unhexlify(pkt.packet.payload.payload.payload), templates[pkt.packet.payload.src])
  File "/home/nas/.local/lib/python3.8/site-packages/netflow/utils.py", line 57, in parse_packet
    return V9ExportPacket(data, templates["netflow"])
  File "/home/nas/.local/lib/python3.8/site-packages/netflow/v9.py", line 503, in __init__
    otfs = V9OptionsTemplateFlowSet(data[offset:])
  File "/home/nas/.local/lib/python3.8/site-packages/netflow/v9.py", line 326, in __init__
    for scope_counter in range(option_scope_length / 4):  # example: option_scope_length = 4 means one scope
TypeError: 'float' object cannot be interpreted as an integer
bitkeks commented 3 years ago

Could you solve this? It's because it uses / (giving a float) instead of //

Fixed in https://github.com/bitkeks/python-netflow-v9-softflowd/commit/ab32ce93b53c62d909b7043649fa23900a3bc13e