From: rtrimana Date: Wed, 25 Apr 2018 18:55:48 +0000 (-0700) Subject: Skipping packets that do not have etherType, e.g. XID, EAPOL, etc. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=pingpong.git;a=commitdiff_plain;h=629be6c90b7f02843b7879dc82e0875328e49964 Skipping packets that do not have etherType, e.g. XID, EAPOL, etc. --- diff --git a/Code/Projects/SmartPlugDetector/pcap/wlan1.local.dns.pcap b/Code/Projects/SmartPlugDetector/pcap/wlan1.local.dns.pcap new file mode 100644 index 0000000..8c945a0 Binary files /dev/null and b/Code/Projects/SmartPlugDetector/pcap/wlan1.local.dns.pcap differ diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/EthernetFrame.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/EthernetFrame.java index 7c380ce..c575a82 100644 --- a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/EthernetFrame.java +++ b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/EthernetFrame.java @@ -52,23 +52,29 @@ public class EthernetFrame extends KaitaiStruct { this.dstMac = this._io.readBytes(6); this.srcMac = this._io.readBytes(6); this.etherType = EtherTypeEnum.byId(this._io.readU2be()); - switch (etherType()) { - case IPV4: { - this._raw_body = this._io.readBytesFull(); - KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body); - this.body = new Ipv4Packet(_io__raw_body); - break; - } - case IPV6: { - this._raw_body = this._io.readBytesFull(); - KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body); - this.body = new Ipv6Packet(_io__raw_body); - break; - } - default: { - this.body = this._io.readBytesFull(); - break; - } + + // We skip if etherType is NULL + // Some packets, e.g. EAPOL and XID do not have etherType + // and we are not interested in these packets + if(etherType() != null) { + switch (etherType()) { + case IPV4: { + this._raw_body = this._io.readBytesFull(); + KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body); + this.body = new Ipv4Packet(_io__raw_body); + break; + } + case IPV6: { + this._raw_body = this._io.readBytesFull(); + KaitaiStream _io__raw_body = new ByteBufferKaitaiStream(_raw_body); + this.body = new Ipv6Packet(_io__raw_body); + break; + } + default: { + this.body = this._io.readBytesFull(); + break; + } + } } } private byte[] dstMac; diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java index c724874..6fb5e9f 100644 --- a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java +++ b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/Main.java @@ -12,11 +12,12 @@ public class Main { public static void main(String[] args) throws Exception { System.out.println("it works"); - String file = "/home/rtrimana/pcap_processing/smart_home_traffic/Code/Projects/SmartPlugDetector/pcap/wlan1.local.dns.pcapdump"; + //String file = "/home/rtrimana/pcap_processing/smart_home_traffic/Code/Projects/SmartPlugDetector/pcap/gre-sample.pcap"; + String file = "/home/rtrimana/pcap_processing/smart_home_traffic/Code/Projects/SmartPlugDetector/pcap/wlan1.local.dns.pcap"; try { Pcap data = Pcap.fromFile(file); - //data.hdr(); + data.hdr(); } catch (Exception e) { e.printStackTrace(); }