+ /**
+ * Checks for overlapping between two packet sequences.
+ * @param compare Current comparison value between packet sequences p1 and p2
+ * @param comparePrev Previous comparison value between packet sequences p1 and p2
+ * @param sequence1 The packet sequence ({@link List} of {@link PcapPacket} objects).
+ * @param sequence2 The packet sequence ({@link List} of {@link PcapPacket} objects).
+ */
+ private static void overlapChecking(int compare, int comparePrev, List<PcapPacket> sequence1, List<PcapPacket> sequence2) {
+
+ // Check if p1 occurs before p2 but both have same overlap
+ if (comparePrev != 0) { // First time since it is 0
+ if (Integer.signum(compare) != Integer.signum(comparePrev)) {
+ // Throw an exception if the order of the two signatures is not consistent,
+ // E.g., 111, 222, 333 in one occassion and 222, 333, 111 in the other.
+ throw new Error("OVERLAP WARNING: " + "" +
+ "Two sequences have some overlap. Please remove one of the sequences: " +
+ sequence1.get(0).length() + "... OR " +
+ sequence2.get(0).length() + "...");
+ }
+ }
+ // Check if p1 is longer than p2 and p2 occurs during the occurrence of p1
+ int lastIndexOfSequence1 = sequence1.size() - 1;
+ int lastIndexOfSequence2 = sequence2.size() - 1;
+ int compareLast =
+ sequence1.get(lastIndexOfSequence1).getTimestamp().compareTo(sequence2.get(lastIndexOfSequence2).getTimestamp());
+ // Check the signs of compare and compareLast
+ if ((compare <= 0 && compareLast > 0) ||
+ (compareLast <= 0 && compare > 0)) {
+ throw new Error("OVERLAP WARNING: " + "" +
+ "One sequence is in the other. Please remove one of the sequences: " +
+ sequence1.get(0).length() + "... OR " +
+ sequence2.get(0).length() + "...");
+ }
+
+ }
+