7ec2a74379554e955b5d363a642be1716d7cea75
[pingpong.git] / Code / Projects / SmartPlugDetector / src / main / java / edu / uci / iotproject / FlowPattern.java
1 package edu.uci.iotproject;
2
3 import java.util.ArrayList;
4 import java.util.Arrays;
5 import java.util.Collections;
6 import java.util.List;
7
8
9 /**
10  * TODO add class documentation.
11  *
12  * @author Janus Varmarken
13  */
14 public class FlowPattern {
15
16     static {
17         // TP-Link Local ON packet lengths (TCP payload only), extracted from ON event at Feb 13, 2018 13:38:04
18         // of the 5 switch data collection:
19         // 517 1448 1448 1448 855 191 51 490 1027 31
20
21         ArrayList<Integer> packetLengths = new ArrayList<>();
22         packetLengths.addAll(Arrays.asList(new Integer[] {517, 1448, 1448, 1448, 855, 191, 51, 490, 1027, 31}));
23         TP_LINK_LOCAL_ON = new FlowPattern("TP_LINK_LOCAL_ON", "events.tplinkra.com", packetLengths);
24     }
25
26     public static final FlowPattern TP_LINK_LOCAL_ON;
27
28     private final String patternId;
29
30     /**
31      * The hostname that this {@code FlowPattern} is associated with.
32      */
33     private final String hostname;
34
35     /**
36      * The order of packet lengths that defines this {@link FlowPattern}
37      * TODO: this is a simplified representation, we should also include information about direction of each packet.
38      */
39     private final List<Integer> flowPacketOrder;
40
41     public FlowPattern(String patternId, String hostname, List<Integer> flowPacketOrder) {
42         this.patternId = patternId;
43         this.hostname = hostname;
44         this.flowPacketOrder = Collections.unmodifiableList(flowPacketOrder);
45     }
46
47     public String getPatternId() {
48         return patternId;
49     }
50
51     public String getHostname() {
52         return hostname;
53     }
54
55     /**
56      * Get the the sequence of packet lengths that defines this {@code FlowPattern}.
57      * @return the the sequence of packet lengths that defines this {@code FlowPattern}.
58      */
59     public List<Integer> getPacketOrder() {
60         return flowPacketOrder;
61     }
62
63 }