I have some spicy code that works on a pcap until I have some lost data. Then I want it to resync when it sees the sequence I have set with the synchronize-at. It’s not working, and doesn’t resync at all. Any help is appreciated.
public type Control = unit {
pkts: (Message &synchronize)[] &eod;
};
public type Message = unit {
%synchronize-at = /\x00\x01\x02\x03\x04/;
a: uint8;
b: uint8;
on %synced { print "Synced: %s" % self;
confirm; }
};
sorry for not getting back to you earlier. You can use the spicy-verbose debug stream to observe what the parser is doing, e.g., by running your parser with
$ HILTI_DEBUG=spicy-verbose zeek ...
Before entering synchronization this will log
[...] failed to parse, will try to synchronize at ...
and once it has synchronized (this shouldn’t be reached since your %synced hook does not get invoked)
We very recently fixed a bug around %synchronize-at which might have caused what you saw. This is not yet in a release, but available in the main branch of Spicy (in the Zeek tree as a submodule under auxil/spicy).
@Benjamin_Bannier I ran it with verbose, and I don’t get any synchronize message at all. Right before my parsing ends, I see the following:
[spicy-verbose] suspending to wait for more input for stream 0x56272e32bd40, currently have 0
[spicy-verbose] resuming after insufficient input, now have 140864 for stream 0x56272e32bd40
In looking at the pcap I’m parsing, that is the amount of bytes it says is missing. Everything parses correctly right up until that, with no synchronize necessary.