X-Git-Url: http://plrg.eecs.uci.edu/git/?p=pingpong.git;a=blobdiff_plain;f=Code%2FProjects%2FSmartPlugDetector%2Fsrc%2Fmain%2Fjava%2Fedu%2Fuci%2Fiotproject%2Fdetection%2Flayer2%2FLayer2SequenceMatcher.java;h=db7295d553ee0f1a41f8c1d228d49d21efd03546;hp=de5c14a5fbcc1cf7f7b2b84acff5b3e9cc52ce31;hb=1b524a7b2071d6e660164e9f1d61cb80b70ca696;hpb=a315a7187514946ab1a40b973dae2e9f6b2dfad3 diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SequenceMatcher.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SequenceMatcher.java index de5c14a..db7295d 100644 --- a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SequenceMatcher.java +++ b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/detection/layer2/Layer2SequenceMatcher.java @@ -7,9 +7,11 @@ import java.util.ArrayList; import java.util.List; /** - * TODO add class documentation. + * Attempts to detect the presence of a specific packet sequence in the set of packets provided through multiple calls + * to {@link #matchPacket(PcapPacket)}, considering only layer 2 information. * - * @author Janus Varmarken + * @author Janus Varmarken {@literal } + * @author Rahmadi Trimananda {@literal } */ public class Layer2SequenceMatcher { @@ -24,10 +26,21 @@ public class Layer2SequenceMatcher { */ private final List mMatchedPackets = new ArrayList<>(); + /** + * Create a {@code Layer2SequenceMatcher}. + * @param sequence The sequence to match against (search for). + */ public Layer2SequenceMatcher(List sequence) { mSequence = sequence; } + /** + * Attempt to advance this {@code Layer2SequenceMatcher} by matching {@code packet} against the packet that this + * {@code Layer2SequenceMatcher} expects as the next packet of the sequence it is searching for. + * @param packet + * @return {@code true} if this {@code Layer2SequenceMatcher} could advance by adding {@code packet} to its set of + * matched packets, {@code false} otherwise. + */ public boolean matchPacket(PcapPacket packet) { // The packet we want to match next. PcapPacket expected = mSequence.get(mMatchedPackets.size());