I am trying to implement, using Lua, a dissector which tells me whether the packets sent are arriving or not. To achieve this, on top of UDP I have implemented a custom protocol with a field "ID" which is auto-incremented by one on each packet.
I got the dissector to process the fields, but I am not able to make it read the previous packet ID and report whether the current packet ID is in the expected order.
My code:
packet_counter=0
function ogg.init()
packet_counter=0
end
function ogg.dissector(buffer, pinfo, tree)
local index
--Get the expected index and store it to a global (and unique per packet) variable
if (not pinfo.private.expected) then
pinfo.private.expected=packet_counter+1
--Get the new index (the current packet ID field)
index=buffer(2,2):uint()
--Set it as the new expected packet
packet_counter=index
end
if (tree) then
--Make all the packet processing here. Somewhere among this:
if (tonumber(pinfo.private.expected) ~= index) then
pinfo.cols.info = "ID: "..index.." is Invalid! Expected ".. pinfo.private.expected
end
end
end
I am getting several packets with the information correct, but other packets are getting the packet_counter
variable different than what it should be, i.e. the previous packet was 100, current is 101, and it is saying that expected is 154, as if the processing order of the packets weren’t sequential.
What is wrong here?
asked 23 Oct ‘12, 08:31
LoPiTaL
16●1●1●3
accept rate: 0%
edited 23 Oct ‘12, 18:18
helloworld
3.1k●4●20●41
(Comment only) First, I believe you should be using a Lua tap for your purposes, not a dissector. A packet can be dissected (and re-dissected) several times in one session (e.g., clicking between packets in the Packet List Pane causes the packet to be dissected), which might be a contributor to your problem. Try a tap instead.
Hi helloworld! Thanks for your comment. I’ve been looking for taps, but I am not able to pass info from the tap to the dissector. It seems like the dissector is processed BEFORE the tap, is this right?So at the momment of dissection,there is no information about packet ordering,thus I can’t know if it is out of order or not. Also from the tap I haven’t got the tree info, nor the GUI columns info, so I cannot print the msg “out of order” anywhere. How can this be made? Note that I want to see the information using the Wireshark GUI, not the command line version. Thanks in advance, LoPiTaL
I don’t know why the
didn’t worked between passes of the dissector. Somebody can help here? Finally I have worked around this with a global array variable in wich I store the same info: