Ask Your Question
0

How to properly use heuristic dissector for TCP

asked 2019-07-17 03:31:23 +0000

I am trying to implement a heuristic dissector for TCP packets.

On the README.heuristic, it says that

"Once a packet for a particular "connection" has been identified as belonging to a particular protocol, Wireshark should then be set up to always directly call the dissector for that protocol. This removes the overhead of having to identify each packet of the connection heuristically."

I am not very sure what this "should be set up to always directly call the dissector for that protocol" mean. Does it mean that whenever the first packet is identified, the subsequent packets in the TCP stream will be automatically identified correctly?

I have tried to implement a heuristic dissector for TCP that only identifies the first incoming packet of the stream I want. It seems that it only identifies the first packet but not the subsequent ones in the stream.

If the heuristic for TCP is applied to all packets individually. I am not sure if the sample code for heuristic dissector makes sense. The sample code seems to try to identify the first few bytes of the packets individually. However, this may not work in real life because TCP packets may be fragmented arbitrarily by hardware if the information sent is too long. If the heuristic is done this way, will some of the fragmented TCP packets be miss identified?

Please advise.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-07-17 04:09:44 +0000

Guy Harris gravatar image

I am not very sure what this "should be set up to always directly call the dissector for that protocol" mean. Does it mean that whenever the first packet is identified, the subsequent packets in the TCP stream will be automatically identified correctly?

No.

"Should" has multiple meanings; there's "Used to indicate obligation, duty, or correctness, typically when criticizing someone's actions.", as in "I think we should trust our people more", and there's "Used to indicate what is probable.", as in "the bus should arrive in a few minutes". You're reading it in the latter sense; it was intended in the former sense.

That sentence should probably be changed to "Wireshark must be then set up..." to avoid the ambiguity.

The way you set it up is to arrange that there's a "conversation" for the TCP connection, and assign a non-heuristic version of your dissector as the dissector for that conversation; see the sample dissect_PROTOABBREV_heur_tcp() routine in the README.heuristic file - it does exactly that.

edit flag offensive delete link more

Comments

Thanks for the clarification!

yue12392 gravatar imageyue12392 ( 2019-07-17 05:15:06 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2019-07-17 03:31:23 +0000

Seen: 91 times

Last updated: Jul 17