Пример #1
0
 def test_packetparserlegacy(self):
     string = open('test/data/BeaconRequest.txt', 'r').read()
     packet = NwPacket(string)
     self.assertTrue(
         NwPacket.verify(
             packet, {
                 "WPAN.Command Identifier": "Beacon Request",
                 "WPAN.Destination Addressing Mode": "Short/16-bit",
                 "WPAN.Destination PAN": "0xffff",
                 "WPAN.Frame Version": "0"
             }))
     self.assertFalse(NwPacket.verify(  # Unsuccessful
         packet,
         {
             "WPAN.Command Identifier": "Bacon Request",
             "WPAN.Destination Addressing Moda": "Short/16-bit",
             "WPAN.Destination PAN": "0xffff"
         }
     ))
Пример #2
0
 def test_packetParser(self):
     str = open('test/data/BeaconRequest.txt', 'r').read()
     p = NwPacket(str)
     self.assertTrue(NwPacket.verify( # Successful
         p,
         {"WPAN":{
             "Command Identifier": "Beacon Request",
             "Destination Addressing Mode": "Short/16-bit",
             "Destination PAN": "0xffff",
             "Frame Version": "0"
         }}
     ))
     self.assertFalse(NwPacket.verify( # Unsuccessful
         p,
         {"WPAN":{
             "Command Identifier": "Bacon Request",
             "Destination Addressing Moda": "Short/16-bit",
             "Destination PAN": "0xffff"
         }}
     ))
Пример #3
0
 def test_packetParser6Lowpan3(self):
     str = open('test/data/6lowpanudp.txt', 'r').read()
     p = NwPacket(str)
     self.assertTrue(NwPacket.verify( # Successful
         p,
         {"6LOWPAN": {
            "Destination": "fd00:db8::ff:fe00:face",
         }, "IPV6":{
             "RPLInstanceID": "0x82",
         }, "UDP":{
             "Destination Port": "7"
         }}
     ))
Пример #4
0
 def test_packetParser6Lowpan(self):
     str = open('test/data/6lowpanping.txt', 'r').read()
     p = NwPacket(str)
     self.assertTrue(NwPacket.verify( # Successful
         p,
         {"6LOWPAN":{
             "Destination": "fe80::166e:a00:0:2",
             "Source address compression": "Stateless",
             "Context identifier extension": "False"
         }, "ICMPV6":{
             "Response To": "17"
         }}
     ))
Пример #5
0
 def test_packetParserRegexValue(self):
     str = open('test/data/BeaconRequest.txt', 'r').read()
     p = NwPacket(str)
     self.assertTrue(
         NwPacket.verify(
             p, {
                 "WPAN": {
                     "Destination PAN": "0xfff[abcdef]"
                 },
                 "IP": {
                     "Protocol": "KGB|UDP|VH1"
                 }
             }))
Пример #6
0
 def test_packetParserMultilayer(self):
     str = open('test/data/BeaconRequest.txt', 'r').read()
     p = NwPacket(str)
     self.assertTrue(
         NwPacket.verify(  # Successful
             p, {
                 "WPAN": {
                     "Destination PAN": "0xffff"
                 },
                 "IP": {
                     "Protocol": "UDP"
                 }
             }))
     self.assertFalse(
         NwPacket.verify(  # Unsuccessful
             p, {
                 "WPAN": {
                     "Destination PAN": "0xffff"
                 },
                 "IP": {
                     "Protocol": "XXX"
                 }
             }))
Пример #7
0
 def test_packetParserFullRow(self):
     str = open('test/data/rpl_dio.txt', 'r').read()
     p = NwPacket(str)
     self.assertTrue(NwPacket.verify( # Successful
         p,
         {"IPV6":{
             "Source": "fe80::ff:fe00:face",
             "Destination": "ff02::1a",
         }, "ICMPV6":{
             "Code": "1",
             "*1": "ICMPv6 RPL Option \(Routing Information fd00:db8::/64\)",
             "*2": "ICMPv6 RPL Option \(Prefix Information fd00:db8::ff:fe00:face/64\)",
             "*3": "ICMPv6 RPL Option \(Routing Information ::/0\)"
         }}
     ))
Пример #8
0
 def test_packetParser6Lowpan2(self):
     str = open('test/data/6lowpanping2.txt', 'r').read()
     p = NwPacket(str)
     self.assertTrue(NwPacket.verify( # Successful
         p,
         {"6LOWPAN":{
             "Destination": "fe80::166e:a00:0:2",
             "Source address compression": "Stateless",
             "Context identifier extension": "False"
         }, "UDP":{
             "Source Port": "65534"
         }, "IPV6":{
             "Source": "fe80::ff:fe00:0"
         }}
     ))
Пример #9
0
 def test_packetparser6lowpan3(self):
     string = open('test/data/6lowpanudp.txt', 'r').read()
     packet = NwPacket(string)
     self.assertTrue(
         NwPacket.verify(
             packet, {
                 "6LOWPAN": {
                     "Destination": "fd00:db8::ff:fe00:face"
                 },
                 "IPV6": {
                     "RPLInstanceID": "0x82"
                 },
                 "UDP": {
                     "Destination Port": "7"
                 }
             }))