+ // BUG: found on May 29, 2019
+ // We need to remove a previous match if the current match is later in time.
+ // This is done only if we have matched at least 1 packet (we are about to match the second or
+ // later packets) and we match for the same packet position in the signature (check the size!).
+ if (previousMatcher != null && sm.getMatchedPacketsCount() > 1 &&
+ previousMatcher.getMatchedPacketsCount() == sm.getMatchedPacketsCount()) {
+ List<PcapPacket> previouslyMatchedPackets = previousMatcher.getMatchedPackets();
+ List<PcapPacket> currentlyMatchedPackets = sm.getMatchedPackets();
+ // We need to check 1 packet before the last matched packet from the previous matcher.
+ int packetIndexToCheck = (sm.getMatchedPacketsCount() - 1) - 1;
+ if (currentlyMatchedPackets.get(packetIndexToCheck).getTimestamp().
+ isAfter(previouslyMatchedPackets.get(packetIndexToCheck).getTimestamp())) {
+ listMatchers.remove(previousMatcher);
+ }
+ }