8627aa25f06315ffcf8495fa32407ae05a40bfd0
[pingpong.git] / Code / Projects / PacketLevelSignatureExtractor / src / main / java / edu / uci / iotproject / detection / layer2 / Layer2SignatureDetector.java
1 package edu.uci.iotproject.detection.layer2;
2
3 import edu.uci.iotproject.analysis.TriggerTrafficExtractor;
4 import edu.uci.iotproject.analysis.UserAction;
5 import edu.uci.iotproject.detection.AbstractClusterMatcher;
6 import edu.uci.iotproject.detection.ClusterMatcherObserver;
7 import edu.uci.iotproject.detection.SignatureDetectorObserver;
8 import edu.uci.iotproject.io.PcapHandleReader;
9 import edu.uci.iotproject.io.PrintWriterUtils;
10 import edu.uci.iotproject.trafficreassembly.layer2.Layer2Flow;
11 import edu.uci.iotproject.trafficreassembly.layer2.Layer2FlowReassembler;
12 import edu.uci.iotproject.util.PcapPacketUtils;
13 import edu.uci.iotproject.util.PrintUtils;
14 import org.jgrapht.GraphPath;
15 import org.jgrapht.alg.shortestpath.DijkstraShortestPath;
16 import org.jgrapht.graph.DefaultWeightedEdge;
17 import org.jgrapht.graph.SimpleDirectedWeightedGraph;
18 import org.pcap4j.core.*;
19
20 import java.io.File;
21 import java.io.FileWriter;
22 import java.io.IOException;
23 import java.io.PrintWriter;
24 import java.time.Duration;
25 import java.util.*;
26 import java.util.function.Function;
27 import java.util.regex.Pattern;
28
29 /**
30  * Performs layer 2 signature detection.
31  *
32  * @author Janus Varmarken {@literal <jvarmark@uci.edu>}
33  * @author Rahmadi Trimananda {@literal <rtrimana@uci.edu>}
34  */
35 public class Layer2SignatureDetector implements PacketListener, ClusterMatcherObserver {
36
37     /**
38      * If set to {@code true}, output written to the results file is also dumped to standard out.
39      */
40     private static boolean DUPLICATE_OUTPUT_TO_STD_OUT = true;
41
42     private static List<Function<Layer2Flow, Boolean>> parseSignatureMacFilters(String filtersString) {
43         List<Function<Layer2Flow, Boolean>> filters = new ArrayList<>();
44         String[] filterRegexes = filtersString.split(";");
45         for (String filterRegex : filterRegexes) {
46             final Pattern regex = Pattern.compile(filterRegex);
47             // Create a filter that includes all flows where one of the two MAC addresses match the regex.
48             filters.add(flow -> regex.matcher(flow.getEndpoint1().toString()).matches() || regex.matcher(flow.getEndpoint2().toString()).matches());
49         }
50         return filters;
51     }
52
53     public static void main(String[] args) throws PcapNativeException, NotOpenException, IOException {
54         // Parse required parameters.
55         if (args.length < 8) {
56             String errMsg = String.format("SPECTO version 1.0\n" +
57                             "Copyright (C) 2018-2019 Janus Varmarken and Rahmadi Trimananda.\n" +
58                             "University of California, Irvine.\n" +
59                             "All rights reserved.\n\n" +
60                             "Usage: %s inputPcapFile onAnalysisFile offAnalysisFile onSignatureFile offSignatureFile resultsFile" +
61                             "\n  inputPcapFile: the target of the detection" +
62                             "\n  onAnalysisFile: the file that contains the ON clusters analysis" +
63                             "\n  offAnalysisFile: the file that contains the OFF clusters analysis" +
64                             "\n  onSignatureFile: the file that contains the ON signature to search for" +
65                             "\n  offSignatureFile: the file that contains the OFF signature to search for" +
66                             "\n  resultsFile: where to write the results of the detection" +
67                             "\n  signatureDuration: the maximum duration of signature detection",
68                     Layer2SignatureDetector.class.getSimpleName());
69             System.out.println(errMsg);
70             String optParamsExplained = "Above are the required, positional arguments. In addition to these, the " +
71                     "following options and associated positional arguments may be used:\n" +
72                     "  '-onmacfilters <regex>;<regex>;...;<regex>' which specifies that sequence matching should ONLY" +
73                     " be performed on flows where the MAC of one of the two endpoints matches the given regex. Note " +
74                     "that you MUST specify a regex for each cluster of the signature. This is to facilitate more " +
75                     "aggressive filtering on parts of the signature (e.g., the communication that involves the " +
76                     "smart home device itself as one can drop all flows that do not include an endpoint with a MAC " +
77                     "that matches the vendor's prefix).\n" +
78                     "  '-offmacfilters <regex>;<regex>;...;<regex>' works exactly the same as onmacfilters, but " +
79                     "applies to the OFF signature instead of the ON signature.\n" +
80                     "  '-sout <boolean literal>' true/false literal indicating if output should also be printed to std out; default is true.";
81             System.out.println(optParamsExplained);
82             return;
83         }
84         // TODO: We could take 7 inputs if we decided to use the cluster analyses.
85         final String pcapFile = args[0];
86         final String onClusterAnalysisFile = args[1];
87         final String offClusterAnalysisFile = args[2];
88         final String onSignatureFile = args[3];
89         final String offSignatureFile = args[4];
90         final String resultsFile = args[5];
91         final int signatureDuration = Integer.parseInt(args[6]);
92         final double eps = Double.parseDouble(args[7]);
93
94         // Parse optional parameters.
95         List<Function<Layer2Flow, Boolean>> onSignatureMacFilters = null, offSignatureMacFilters = null;
96         final int optParamsStartIdx = 7;
97         if (args.length > optParamsStartIdx) {
98             for (int i = optParamsStartIdx; i < args.length; i++) {
99                 if (args[i].equalsIgnoreCase("-onMacFilters")) {
100                     // Next argument is the cluster-wise MAC filters (separated by semicolons).
101                     onSignatureMacFilters = parseSignatureMacFilters(args[i+1]);
102                 } else if (args[i].equalsIgnoreCase("-offMacFilters")) {
103                     // Next argument is the cluster-wise MAC filters (separated by semicolons).
104                     offSignatureMacFilters = parseSignatureMacFilters(args[i+1]);
105                 } else if (args[i].equalsIgnoreCase("-sout")) {
106                     // Next argument is a boolean true/false literal.
107                     DUPLICATE_OUTPUT_TO_STD_OUT = Boolean.parseBoolean(args[i+1]);
108                 }
109             }
110         }
111
112         // Prepare file outputter.
113         File outputFile = new File(resultsFile);
114         outputFile.getParentFile().mkdirs();
115         final PrintWriter resultsWriter = new PrintWriter(new FileWriter(outputFile));
116         // Include metadata as comments at the top
117         PrintWriterUtils.println("# Detection results for:", resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
118         PrintWriterUtils.println("# - inputPcapFile: " + pcapFile, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
119         PrintWriterUtils.println("# - onAnalysisFile: " + onClusterAnalysisFile, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
120         PrintWriterUtils.println("# - offAnalysisFile: " + offClusterAnalysisFile, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
121         PrintWriterUtils.println("# - onSignatureFile: " + onSignatureFile, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
122         PrintWriterUtils.println("# - offSignatureFile: " + offSignatureFile, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
123         resultsWriter.flush();
124
125         // Create signature detectors and add observers that output their detected events.
126         List<List<List<PcapPacket>>> onSignature = PrintUtils.deserializeFromFile(onSignatureFile);
127         List<List<List<PcapPacket>>> offSignature = PrintUtils.deserializeFromFile(offSignatureFile);
128         // Load signature analyses
129         List<List<List<PcapPacket>>> onClusterAnalysis = PrintUtils.deserializeFromFile(onClusterAnalysisFile);
130         List<List<List<PcapPacket>>> offClusterAnalysis = PrintUtils.deserializeFromFile(offClusterAnalysisFile);
131         // TODO: FOR NOW WE DECIDE PER SIGNATURE AND THEN WE OR THE BOOLEANS
132         // TODO: SINCE WE ONLY HAVE 2 SIGNATURES FOR NOW (ON AND OFF), THEN IT IS USUALLY EITHER RANGE-BASED OR
133         // TODO: STRICT MATCHING
134         // Check if we should use range-based matching
135         boolean isRangeBasedForOn = PcapPacketUtils.isRangeBasedMatching(onSignature, eps, offSignature);
136         boolean isRangeBasedForOff = PcapPacketUtils.isRangeBasedMatching(offSignature, eps, onSignature);
137         // TODO: WE DON'T DO RANGE-BASED FOR NOW BECAUSE THE RESULTS ARE TERRIBLE FOR LAYER 2 MATCHING
138         // TODO: THIS WOULD ONLY WORK FOR SIGNATURES LONGER THAN 2 PACKETS
139 //        boolean isRangeBasedForOn = false;
140 //        boolean isRangeBasedForOff = false;
141         // Update the signature with ranges if it is range-based
142         if (isRangeBasedForOn) {
143             onSignature = PcapPacketUtils.useRangeBasedMatching(onSignature, onClusterAnalysis);
144         }
145         if (isRangeBasedForOff) {
146             offSignature = PcapPacketUtils.useRangeBasedMatching(offSignature, offClusterAnalysis);
147         }
148         Layer2SignatureDetector onDetector = onSignatureMacFilters == null ?
149                 new Layer2SignatureDetector(onSignature, signatureDuration, isRangeBasedForOn, eps) :
150                 new Layer2SignatureDetector(onSignature, onSignatureMacFilters, signatureDuration, isRangeBasedForOn, eps);
151         Layer2SignatureDetector offDetector = offSignatureMacFilters == null ?
152                 new Layer2SignatureDetector(offSignature, signatureDuration, isRangeBasedForOff, eps) :
153                 new Layer2SignatureDetector(offSignature, offSignatureMacFilters, signatureDuration, isRangeBasedForOff, eps);
154         final List<UserAction> detectedEvents = new ArrayList<>();
155         onDetector.addObserver((signature, match) -> {
156             UserAction event = new UserAction(UserAction.Type.TOGGLE_ON, match.get(0).get(0).getTimestamp());
157             PrintWriterUtils.println(event, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
158             detectedEvents.add(event);
159         });
160         offDetector.addObserver((signature, match) -> {
161             UserAction event = new UserAction(UserAction.Type.TOGGLE_OFF, match.get(0).get(0).getTimestamp());
162             PrintWriterUtils.println(event, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
163             detectedEvents.add(event);
164         });
165
166         // Load the PCAP file
167         PcapHandle handle;
168         try {
169             handle = Pcaps.openOffline(pcapFile, PcapHandle.TimestampPrecision.NANO);
170         } catch (PcapNativeException pne) {
171             handle = Pcaps.openOffline(pcapFile);
172         }
173         PcapHandleReader reader = new PcapHandleReader(handle, p -> true, onDetector, offDetector);
174         // Parse the file
175         reader.readFromHandle();
176
177         String resultOn = "# Number of detected events of type " + UserAction.Type.TOGGLE_ON + ": " +
178                 detectedEvents.stream().filter(ua -> ua.getType() == UserAction.Type.TOGGLE_ON).count();
179         String resultOff = "# Number of detected events of type " + UserAction.Type.TOGGLE_OFF + ": " +
180                 detectedEvents.stream().filter(ua -> ua.getType() == UserAction.Type.TOGGLE_OFF).count();
181 //        String onMaxSkippedPackets = "# Number of skipped packets in ON signature " +
182 //                Integer.toString(onDetector.getMaxSkippedPackets());
183         String onMaxSkippedPackets = "# Number of skipped packets in ON signature: ";
184         for(Integer skippedPackets : onDetector.getMaxSkippedPackets()) {
185             System.out.println(skippedPackets);
186         }
187 //        String offMaxSkippedPackets = "# Number of skipped packets in OFF signature " +
188 //                Integer.toString(offDetector.getMaxSkippedPackets());
189         String offMaxSkippedPackets = "# Number of skipped packets in OFF signature: ";
190         for(Integer skippedPackets : offDetector.getMaxSkippedPackets()) {
191             System.out.println(skippedPackets);
192         }
193         PrintWriterUtils.println(resultOn, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
194         PrintWriterUtils.println(resultOff, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
195         PrintWriterUtils.println(onMaxSkippedPackets, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
196         PrintWriterUtils.println(offMaxSkippedPackets, resultsWriter, DUPLICATE_OUTPUT_TO_STD_OUT);
197
198         // Flush output to results file and close it.
199         resultsWriter.flush();
200         resultsWriter.close();
201     }
202
203     /**
204      * The signature that this {@link Layer2SignatureDetector} is searching for.
205      */
206     private final List<List<List<PcapPacket>>> mSignature;
207
208     /**
209      * The {@link Layer2ClusterMatcher}s in charge of detecting each individual sequence of packets that together make
210      * up the the signature.
211      */
212     private final List<Layer2ClusterMatcher> mClusterMatchers;
213
214     /**
215      * For each {@code i} ({@code i >= 0 && i < mPendingMatches.length}), {@code mPendingMatches[i]} holds the matches
216      * found by the {@link Layer2ClusterMatcher} at {@code mClusterMatchers.get(i)} that have yet to be "consumed",
217      * i.e., have yet to be included in a signature detected by this {@link Layer2SignatureDetector} (a signature can
218      * be encompassed of multiple packet sequences occurring shortly after one another on multiple connections).
219      */
220     private final List<List<PcapPacket>>[] mPendingMatches;
221
222     /**
223      * Maps a {@link Layer2ClusterMatcher} to its corresponding index in {@link #mPendingMatches}.
224      */
225     private final Map<Layer2ClusterMatcher, Integer> mClusterMatcherIds;
226
227     /**
228      * In charge of reassembling layer 2 packet flows.
229      */
230     private final Layer2FlowReassembler mFlowReassembler = new Layer2FlowReassembler();
231
232     private final List<SignatureDetectorObserver> mObservers = new ArrayList<>();
233
234     private int mInclusionTimeMillis;
235
236     //private int mMaxSkippedPackets;
237     private List<Integer> mMaxSkippedPackets;
238
239     public Layer2SignatureDetector(List<List<List<PcapPacket>>> searchedSignature, int signatureDuration, boolean isRangeBased, double eps) {
240         this(searchedSignature, null, signatureDuration, isRangeBased, eps);
241     }
242
243     public Layer2SignatureDetector(List<List<List<PcapPacket>>> searchedSignature, List<Function<Layer2Flow,
244             Boolean>> flowFilters, int inclusionTimeMillis, boolean isRangeBased, double eps) {
245         if (flowFilters != null && flowFilters.size() != searchedSignature.size()) {
246             throw new IllegalArgumentException("If flow filters are used, there must be a flow filter for each cluster " +
247                     "of the signature.");
248         }
249         mSignature = Collections.unmodifiableList(searchedSignature);
250         List<Layer2ClusterMatcher> clusterMatchers = new ArrayList<>();
251         for (int i = 0; i < mSignature.size(); i++) {
252             List<List<PcapPacket>> cluster = mSignature.get(i);
253             Layer2ClusterMatcher clusterMatcher = flowFilters == null ?
254                     new Layer2ClusterMatcher(cluster, inclusionTimeMillis, isRangeBased, eps) :
255                     new Layer2ClusterMatcher(cluster, flowFilters.get(i), inclusionTimeMillis, isRangeBased, eps);
256             clusterMatcher.addObserver(this);
257             clusterMatchers.add(clusterMatcher);
258         }
259         mClusterMatchers = Collections.unmodifiableList(clusterMatchers);
260         mPendingMatches = new List[mClusterMatchers.size()];
261         for (int i = 0; i < mPendingMatches.length; i++) {
262             mPendingMatches[i] = new ArrayList<>();
263         }
264         Map<Layer2ClusterMatcher, Integer> clusterMatcherIds = new HashMap<>();
265         for (int i = 0; i < mClusterMatchers.size(); i++) {
266             clusterMatcherIds.put(mClusterMatchers.get(i), i);
267         }
268         mClusterMatcherIds = Collections.unmodifiableMap(clusterMatcherIds);
269         // Register all cluster matchers to receive a notification whenever a new flow is encountered.
270         mClusterMatchers.forEach(cm -> mFlowReassembler.addObserver(cm));
271         mInclusionTimeMillis =
272                 inclusionTimeMillis == 0 ? TriggerTrafficExtractor.INCLUSION_WINDOW_MILLIS : inclusionTimeMillis;
273         //mMaxSkippedPackets = 0;
274         mMaxSkippedPackets = new ArrayList<>();
275     }
276
277 //    public int getMaxSkippedPackets() {
278 //        return mMaxSkippedPackets;
279 //    }
280     public List<Integer> getMaxSkippedPackets() {
281         return mMaxSkippedPackets;
282     }
283
284     @Override
285     public void gotPacket(PcapPacket packet) {
286         // Forward packet processing to the flow reassembler that in turn notifies the cluster matchers as appropriate
287         mFlowReassembler.gotPacket(packet);
288     }
289
290     @Override
291     public void onMatch(AbstractClusterMatcher clusterMatcher, List<PcapPacket> match) {
292         // TODO: a cluster matcher found a match
293         if (clusterMatcher instanceof Layer2ClusterMatcher) {
294             // Add the match at the corresponding index
295             mPendingMatches[mClusterMatcherIds.get(clusterMatcher)].add(match);
296             checkSignatureMatch();
297             // Update maximum number of skipped packets
298             //if (mMaxSkippedPackets < ((Layer2ClusterMatcher) clusterMatcher).getMaxSkippedPackets()) {
299             //    mMaxSkippedPackets = ((Layer2ClusterMatcher) clusterMatcher).getMaxSkippedPackets();
300             //}
301             mMaxSkippedPackets = ((Layer2ClusterMatcher) clusterMatcher).getMaxSkippedPackets();
302         }
303     }
304
305     public void addObserver(SignatureDetectorObserver observer) {
306         mObservers.add(observer);
307     }
308
309     public boolean removeObserver(SignatureDetectorObserver observer) {
310         return mObservers.remove(observer);
311     }
312
313
314     @SuppressWarnings("Duplicates")
315     private void checkSignatureMatch() {
316         // << Graph-based approach using Balint's idea. >>
317         // This implementation assumes that the packets in the inner lists (the sequences) are ordered by asc timestamp.
318
319         // There cannot be a signature match until each Layer3ClusterMatcher has found a match of its respective sequence.
320         if (Arrays.stream(mPendingMatches).noneMatch(l -> l.isEmpty())) {
321             // Construct the DAG
322             final SimpleDirectedWeightedGraph<Vertex, DefaultWeightedEdge> graph =
323                     new SimpleDirectedWeightedGraph<>(DefaultWeightedEdge.class);
324             // Add a vertex for each match found by all cluster matchers.
325             // And maintain an array to keep track of what cluster matcher each vertex corresponds to
326             final List<Vertex>[] vertices = new List[mPendingMatches.length];
327             for (int i = 0; i < mPendingMatches.length; i++) {
328                 vertices[i] = new ArrayList<>();
329                 for (List<PcapPacket> sequence : mPendingMatches[i]) {
330                     Vertex v = new Vertex(sequence);
331                     vertices[i].add(v); // retain reference for later when we are to add edges
332                     graph.addVertex(v); // add to vertex to graph
333                 }
334             }
335             // Add dummy source and sink vertices to facilitate search.
336             final Vertex source = new Vertex(null);
337             final Vertex sink = new Vertex(null);
338             graph.addVertex(source);
339             graph.addVertex(sink);
340             // The source is connected to all vertices that wrap the sequences detected by cluster matcher at index 0.
341             // Note: zero cost edges as this is just a dummy link to facilitate search from a common start node.
342             for (Vertex v : vertices[0]) {
343                 DefaultWeightedEdge edge = graph.addEdge(source, v);
344                 graph.setEdgeWeight(edge, 0.0);
345             }
346             // Similarly, all vertices that wrap the sequences detected by the last cluster matcher of the signature
347             // are connected to the sink node.
348             for (Vertex v : vertices[vertices.length-1]) {
349                 DefaultWeightedEdge edge = graph.addEdge(v, sink);
350                 graph.setEdgeWeight(edge, 0.0);
351             }
352             // Now link sequences detected by the cluster matcher at index i to sequences detected by the cluster
353             // matcher at index i+1 if they obey the timestamp constraint (i.e., that the latter is later in time than
354             // the former).
355             for (int i = 0; i < vertices.length; i++) {
356                 int j = i + 1;
357                 if (j < vertices.length) {
358                     for (Vertex iv : vertices[i]) {
359                         PcapPacket ivLast = iv.sequence.get(iv.sequence.size()-1);
360                         for (Vertex jv : vertices[j]) {
361                             PcapPacket jvFirst = jv.sequence.get(jv.sequence.size()-1);
362                             if (ivLast.getTimestamp().isBefore(jvFirst.getTimestamp())) {
363                                 DefaultWeightedEdge edge = graph.addEdge(iv, jv);
364                                 // The weight is the duration of the i'th sequence plus the duration between the i'th
365                                 // and i+1'th sequence.
366                                 Duration d = Duration.
367                                         between(iv.sequence.get(0).getTimestamp(), jvFirst.getTimestamp());
368                                 // Unfortunately weights are double values, so must convert from long to double.
369                                 // TODO: need nano second precision? If so, use d.toNanos().
370                                 // TODO: risk of overflow when converting from long to double..?
371                                 graph.setEdgeWeight(edge, Long.valueOf(d.toMillis()).doubleValue());
372                             }
373                             // Alternative version if we cannot assume that sequences are ordered by timestamp:
374 //                            if (iv.sequence.stream().max(Comparator.comparing(PcapPacket::getTimestamp)).get()
375 //                                    .getTimestamp().isBefore(jv.sequence.stream().min(
376 //                                            Comparator.comparing(PcapPacket::getTimestamp)).get().getTimestamp())) {
377 //
378 //                            }
379                         }
380                     }
381                 }
382             }
383             // Graph construction complete, run shortest-path to find a (potential) signature match.
384             DijkstraShortestPath<Vertex, DefaultWeightedEdge> dijkstra = new DijkstraShortestPath<>(graph);
385             GraphPath<Vertex, DefaultWeightedEdge> shortestPath = dijkstra.getPath(source, sink);
386             if (shortestPath != null) {
387                 // The total weight is the duration between the first packet of the first sequence and the last packet
388                 // of the last sequence, so we simply have to compare the weight against the timeframe that we allow
389                 // the signature to span. For now we just use the inclusion window we defined for training purposes.
390                 // Note however, that we must convert back from double to long as the weight is stored as a double in
391                 // JGraphT's API.
392                 if (((long)shortestPath.getWeight()) < mInclusionTimeMillis) {
393                     // There's a signature match!
394                     // Extract the match from the vertices
395                     List<List<PcapPacket>> signatureMatch = new ArrayList<>();
396                     for(Vertex v : shortestPath.getVertexList()) {
397                         if (v == source || v == sink) {
398                             // Skip the dummy source and sink nodes.
399                             continue;
400                         }
401                         signatureMatch.add(v.sequence);
402                         // As there is a one-to-one correspondence between vertices[] and pendingMatches[], we know that
403                         // the sequence we've "consumed" for index i of the matched signature is also at index i in
404                         // pendingMatches. We must remove it from pendingMatches so that we don't use it to construct
405                         // another signature match in a later call.
406                         mPendingMatches[signatureMatch.size()-1].remove(v.sequence);
407                     }
408                     // Declare success: notify observers
409                     mObservers.forEach(obs -> obs.onSignatureDetected(mSignature,
410                             Collections.unmodifiableList(signatureMatch)));
411                 }
412             }
413         }
414     }
415
416     /**
417      * Encapsulates a {@code List<PcapPacket>} so as to allow the list to be used as a vertex in a graph while avoiding
418      * the expensive {@link AbstractList#equals(Object)} calls when adding vertices to the graph.
419      * Using this wrapper makes the incurred {@code equals(Object)} calls delegate to {@link Object#equals(Object)}
420      * instead of {@link AbstractList#equals(Object)}. The net effect is a faster implementation, but the graph will not
421      * recognize two lists that contain the same items--from a value and not reference point of view--as the same
422      * vertex. However, this is fine for our purposes -- in fact restricting it to reference equality seems more
423      * appropriate.
424      */
425     private static class Vertex {
426         private final List<PcapPacket> sequence;
427         private Vertex(List<PcapPacket> wrappedSequence) {
428             sequence = wrappedSequence;
429         }
430     }
431 }