+
+ /**
+ * Compute the direction of a packet based on the previous packet. If no previous packet is provided, the direction
+ * of {@code currPkt} is {@code true} by definition.
+ * @param prevPkt The previous packet, if any.
+ * @param prevPktDirection The computed direction of the previous packet
+ * @param currPkt The current packet for which the direction is to be determined.
+ * @return The direction of {@code currPkt}.
+ */
+ private boolean getPacketDirection(PcapPacket prevPkt, boolean prevPktDirection, PcapPacket currPkt) {
+ if (prevPkt == null) {
+ // By definition, use true as direction marker for first packet
+ return true;
+ }
+ if (PcapPacketUtils.getEthSrcAddr(prevPkt).equals(PcapPacketUtils.getEthSrcAddr(currPkt))) {
+ // Current packet goes in same direction as previous packet.
+ return prevPktDirection;
+ } else {
+ // Current packet goes in opposite direction of previous packet.
+ return !prevPktDirection;
+ }
+ }
+
+