goflow2 icon indicating copy to clipboard operation
goflow2 copied to clipboard

Problem with decoding of packet

Open gitchander opened this issue 7 months ago • 2 comments

I used next code: ` import ( "fmt" "github.com/netsampler/goflow2/decoders/netflow" )

...

b := bytes.NewBuffer(data)
templates := netflow.CreateTemplateSystem()
m, err := netflow.DecodeMessage(b, templates)
if err != nil {
	return err
}
fmt.Println(m)

` After decoding I have next error: "No info template 257 found for and domain id 58"

How I can fix it?

gitchander avatar Jun 19 '25 09:06 gitchander

Hi @gitchander You are trying to decode a NetFlow/IPFIX packet for which you do not have the template. This is how the protocol works: the templates indicate how long each field is in the data ensuring little repetition. This error can be intercepted by checking errors.Is(netflow.ErrorTemplateNotFound).

lspgn avatar Jun 20 '25 06:06 lspgn

Thanks for explaining! I have already fixed it.

I was able intercepted this error next way:

	errTNF, ok := err.(*netflow.ErrorTemplateNotFound)
	if ok {
		fmt.Println(errTNF)
	}

Next code is not worked:

	v := &(netflow.ErrorTemplateNotFound{})
	if errors.Is(err, v) {
		// not intercepted
	}

gitchander avatar Jun 20 '25 07:06 gitchander