* List of RST packets associated with this conversation.
*/
private final List<PcapPacket> mRstPackets;
+
+ /**
+ * Boolean to mark the packet as Application Data based on the previous packet that reaches MTU
+ */
+ private boolean mApplicationData;
/* End instance properties */
/**
this.mSynPackets = new ArrayList<>();
this.mFinPackets = new ArrayList<>();
this.mRstPackets = new ArrayList<>();
+ this.mApplicationData = false;
}
/**
byte[] rawPayload = tcpPayload.getRawData();
// The SSL record header is at the front of the payload and is 5 bytes long.
// The SSL record header type field (the first byte) is set to 23 if it is an Application Data packet.
- if (rawPayload != null && rawPayload.length >= 5 && rawPayload[0] == 23) {
- mTlsApplicationDataPackets.add(packet);
+ if (rawPayload != null && rawPayload.length >= 5) {
+ if (rawPayload[0] == 23) {
+ mTlsApplicationDataPackets.add(packet);
+ // Consider the following packet a data packet if this packet's size == MTU size 1448
+ if (rawPayload.length >= 1448)
+ mApplicationData = true;
+ } else if (rawPayload[0] == 20) {
+ // Do nothing for now - CHANGE_CIPHER_SPEC
+ } else if (rawPayload[0] == 21) {
+ // Do nothing for now - ALERT
+ } else if (rawPayload[0] == 22) {
+ // Do nothing for now - HANDSHAKE
+ } else {
+ // If it is TLS with payload, but rawPayload[0] != 23
+ if (mApplicationData == true) {
+ // It is a continuation of the previous packet if the previous packet reaches MTU size 1448 and
+ // it is not either type 20, 21, or 22
+ mTlsApplicationDataPackets.add(packet);
+ if (rawPayload.length < 1448)
+ mApplicationData = false;
+ }
+ }
}
}
}
final String offPairsPath = "/scratch/July-2018/off.txt";
// 1) D-Link July 26 experiment
- final String inputPcapFile = path + "/2018-07/dlink/dlink.wlan1.local.pcap";
- final String outputPcapFile = path + "/2018-07/dlink/dlink-processed.pcap";
- final String triggerTimesFile = path + "/2018-07/dlink/dlink-july-26-2018.timestamps";
- final String deviceIp = "192.168.1.246"; // .246 == phone; .199 == dlink plug?
+// final String inputPcapFile = path + "/2018-07/dlink/dlink.wlan1.local.pcap";
+// final String outputPcapFile = path + "/2018-07/dlink/dlink-processed.pcap";
+// final String triggerTimesFile = path + "/2018-07/dlink/dlink-july-26-2018.timestamps";
+// final String deviceIp = "192.168.1.246"; // .246 == phone; .199 == dlink plug?
// 2) TP-Link July 25 experiment
// final String inputPcapFile = path + "/2018-07/tplink/tplink.wlan1.local.pcap";
// final String inputPcapFile = path + "/2018-08/tplink-bulb/tplinkbulb.wlan1.local.pcap";
// final String outputPcapFile = path + "/2018-08/tplink-bulb/tplinkbulb-processed.pcap";
// final String triggerTimesFile = path + "/2018-08/tplink-bulb/tplink-bulb-aug-3-2018.timestamps";
-// final String deviceIp = "192.168.1.140";
+// final String deviceIp = "192.168.1.246";
// 7) Kwikset Doorlock August 6 experiment
// final String inputPcapFile = path + "/2018-08/kwikset-doorlock/kwikset-doorlock.wlan1.local.pcap";
// final String inputPcapFile = path + "/2018-08/lifx-bulb/lifx-bulb.wlan1.local.pcap";
// final String outputPcapFile = path + "/2018-08/lifx-bulb/lifx-bulb-processed.pcap";
// final String triggerTimesFile = path + "/2018-08/lifx-bulb/lifx-bulb-aug-8-2018.timestamps";
-// final String deviceIp = "192.168.1.246"; // .246 == phone; .231 == Lifx
+// final String deviceIp = "192.168.1.231"; // .246 == phone; .231 == Lifx
// 10) Amcrest Camera August 9 experiment
// final String inputPcapFile = path + "/2018-08/amcrest-camera/amcrest-camera.wlan1.local.pcap";
// final String inputPcapFile = path + "/2018-08/blossom/blossom.wlan1.local.pcap";
// final String outputPcapFile = path + "/2018-08/blossom/blossom-processed.pcap";
// final String triggerTimesFile = path + "/2018-08/blossom/blossom-aug-13-2018.timestamps";
-// final String deviceIp = "192.168.1.229"; // .246 == phone; .229 == sprinkler
+// final String deviceIp = "192.168.1.246"; // .246 == phone; .229 == sprinkler
// 13) DLink siren August 14 experiment
// final String inputPcapFile = path + "/2018-08/dlink-siren/dlink-siren.wlan1.local.pcap";
// final String deviceIp = "192.168.1.246"; // .246 == phone; .127 == Nest thermostat
// 15) Alexa August 16 experiment
-// final String inputPcapFile = path + "/2018-08/alexa/alexa.wlan1.local.pcap";
-// final String outputPcapFile = path + "/2018-08/alexa/alexa-processed.pcap";
-// final String triggerTimesFile = path + "/2018-08/alexa/alexa-aug-16-2018.timestamps";
-// final String deviceIp = "192.168.1.225"; // .246 == phone; .225 == Alexa
+ final String inputPcapFile = path + "/2018-08/alexa/alexa.wlan1.local.pcap";
+ final String outputPcapFile = path + "/2018-08/alexa/alexa-processed.pcap";
+ final String triggerTimesFile = path + "/2018-08/alexa/alexa-aug-16-2018.timestamps";
+ final String deviceIp = "192.168.1.225"; // .246 == phone; .225 == Alexa
// August 17
// final String inputPcapFile = path + "/2018-08/alexa/alexa2.wlan1.local.pcap";
// final String outputPcapFile = path + "/2018-08/alexa/alexa2-processed.pcap";
# TODO: Just change the following path and filename
# when needed to read from a different file
path = "/scratch/July-2018/Pairs/"
-filename = "dlink-off.txt"
+filename = "alexa-off.txt"
# Read and create an array of pairs
with open(path + filename, "r") as pairs:
#print(pairsArr)
X = np.array(pairsArr);
-clusters = 9
+clusters = 25
# Plot the data points based on the clusters
clusterer = KMeans(n_clusters=clusters, random_state=10)
for i, c in enumerate(centers):
mark = '[' + str(int(c[0])) + ', ' + str(int(c[1])) + ']' + ', ' + str(clusterer.labels_.tolist().count(i))
ax2.scatter(c[0], c[1], marker='$%s$' % mark, alpha=1, s=3000, edgecolor='k')
+ print('[' + str(int(c[0])) + ', ' + str(int(c[1])) + ']' + ', ' + str(clusterer.labels_.tolist().count(i)))
ax2.set_title("The visualization of the clustered data.")
ax2.set_xlabel("Feature space for the 1st feature")