I've seen several topics here that relate to this issue, but none of the solutions have worked for me so far, so hopefully someone can point out where I'm going wrong. I have a capture with 4 separate UDP streams being received on 4 well known ports, 30300 - 30303. The UDP packets have a private "sequence number" that increments monotonically for each port. I've been able to write a dissector in Lua that highlights that sequence number, but want to go to the next step: highlighting or somehow calling out packets just after a packet drop has been detected, indicated by a break in the sequence. Here's my attempt so far: http://pastebin.com/nL9TCPWq I've seen discussions indicating a Tap may be more appropriate for this purpose, but haven't found any Lua examples as yet. asked 11 Sep '13, 16:09 Gordon Marler |
2 Answers:
The code looks like it could work. So, what is your question? BTW: why
instead of
?? Regards answered 12 Sep '13, 14:15 Kurt Knochner ♦ showing 5 of 10 show 5 more comments |
Support for 64-bt integers in Lua has now been added in Wireshark 1.11.3, and should be in the latest nightly builds. It provides Int64/UInt64 objects with abilities to use math and comparison operators and such. See wiki.wireshark.org/LuaAPI/Int64 for details. answered 06 Feb '14, 07:57 Hadriel |
That was a mistake, probably an attempt to build a nested table initially, which wasn't necessary. I've corrected it as you've shown.
As to my question, through various trial and error, the script seems to just stop at this line, where I try to increment the last sequence number and store it in expected:
I'm wondering if the value I extracted from the packet with buffer(8,8) as the sequence number is actually being interpreted as an integer.
good question. Impossible to answer without a sample capture file ;-) Can you please post one on google drive, dropbox or cloudshark?
That makes sense - here's a sample capture:
dropped-test.pcapng
The first 8 bytes are not a counter in any way, as the bytes are the same for every frame, and I can't see any other byte sequence that increments in a detectable/predictable way.
So, where exactly is that sequence number within the frame?
hold on. My mistake. I was looking at the beginning of the UDP payload, whereas in the code it says: at byte 8. O.K. then there is an increasing seq number. I'll have to check how that gets read by the lua code.
strange thing.
If you change the code to this:
and then run tshark like this:
The output look like this:
So, P#1 gets printed, but not P#2, as if code execution stops after (or with) the declaration of local expected. Currently I have no idea what's going wrong (maybe a bug), but if code execution really stops there, your code to analyze the sequence number will not be executed either!
If you remove the declaration of local expected, the output looks like this.
So, now P#2 gets printed and the rest of the code gets executed as well, although with wrong result, due to the missing variable.
Looks like a strange bug to me.
BTW: The seq is extracted correctly by the code.
O.K. the problem is the data type of seq. It gets extracted as type userdata (see: warn("Seq type: " .. type(seq)). Even if you make it a uint64, it's type is still userdata
Apparently there is no + operator defined for that data type and thus the code
fails.
So, we need to find a way to make seq a number object. Unfortunately I have not found a way to do that yet. tonumber() does not work.
well, there seems to be a problem with unit64(). If I change the code to this
it works well, as the data type of seq is then a number instead of userdata (with uint64())
HOWEVER: That's just 4 bytes of your sequence!!
Test:
Output:
I don't know if this is a bug or if there are internal representation problems with 64 bit values in Lua !?! Please file a bug report at https://bugs.wireshark.org with a reference to this question and my 'findings'.
Excellent troubleshooting! Thanks for taking the time.
I've submitted Bug ID 9162
Thanks for submitting the bug.
Hint: If a supplied answer resolves your question can you please "accept" it by clicking the checkmark icon next to it. This highlights good answers for the benefit of subsequent users with the same or similar questions.