diff --git a/.gitignore b/.gitignore index 21e929f..7b3fb92 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ data.* __pycache__ -*.json data/* .DS_Store .ipynb_checkpoints/ diff --git a/example/compressed_tree.json b/example/compressed_tree.json new file mode 100644 index 0000000..4d1fee8 --- /dev/null +++ b/example/compressed_tree.json @@ -0,0 +1,560 @@ +{ + "paths": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22 + ], + "classes": [ + "Amazon Echo", + "Belkin Motion Sensor", + "Belkin Switch", + "Dropcam", + "HP Printer", + "LiFX Bulb", + "NEST Smoke Sensor", + "Netatmo Camera", + "Netatmo Weather station", + "Pixstart photo frame", + "Samsung Smart Cam", + "Smart Things", + "TP-Link Camera", + "TP-Link Plug", + "Triby Speaker", + "Withings", + "Withings Scale", + "Withings sleep sensor", + "iHome PowerPlug", + "other" + ], + "layers": { + "dst": [ + { + "min": null, + "max": 2136, + "paths": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "classes": [ + 8, + 19, + 4 + ] + }, + { + "min": 2136, + "max": 2224, + "paths": [ + 7 + ], + "classes": [ + 11 + ] + }, + { + "min": 2224, + "max": 5016, + "paths": [ + 8, + 9 + ], + "classes": [ + 1, + 19 + ] + }, + { + "min": 5016, + "max": 25848, + "paths": [ + 10, + 11, + 12 + ], + "classes": [ + 19, + 7 + ] + }, + { + "min": 25848, + "max": 47936, + "paths": [ + 10, + 11, + 13 + ], + "classes": [ + 19, + 7 + ] + }, + { + "min": 47936, + "max": 47944, + "paths": [ + 14 + ], + "classes": [ + 3 + ] + }, + { + "min": 47944, + "max": 49152, + "paths": [ + 16, + 15 + ], + "classes": [ + 10, + 7 + ] + }, + { + "min": 49152, + "max": 49160, + "paths": [ + 17, + 18 + ], + "classes": [ + 16, + 2 + ] + }, + { + "min": 49160, + "max": null, + "paths": [ + 19, + 20, + 21, + 22 + ], + "classes": [ + 17, + 19, + 15 + ] + } + ], + "src": [ + { + "min": null, + "max": 64, + "paths": [ + 0, + 1, + 7, + 8, + 10, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 7, + 11, + 15, + 16, + 19 + ] + }, + { + "min": 64, + "max": 128, + "paths": [ + 3, + 5, + 7, + 8, + 10, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 4, + 7, + 11, + 15, + 16, + 19 + ] + }, + { + "min": 128, + "max": 280, + "paths": [ + 3, + 6, + 7, + 8, + 10, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 4, + 7, + 11, + 15, + 16, + 19 + ] + }, + { + "min": 280, + "max": 816, + "paths": [ + 3, + 6, + 7, + 8, + 11, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 4, + 7, + 11, + 15, + 16, + 19 + ] + }, + { + "min": 816, + "max": 1576, + "paths": [ + 4, + 6, + 7, + 8, + 11, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 7, + 11, + 15, + 16, + 19 + ] + }, + { + "min": 1576, + "max": 2488, + "paths": [ + 4, + 6, + 7, + 8, + 11, + 14, + 15, + 18, + 19 + ], + "classes": [ + 2, + 3, + 7, + 11, + 15, + 19 + ] + }, + { + "min": 2488, + "max": 4776, + "paths": [ + 4, + 6, + 7, + 8, + 11, + 14, + 16, + 18, + 19 + ], + "classes": [ + 2, + 3, + 7, + 10, + 11, + 15, + 19 + ] + }, + { + "min": 4776, + "max": 5224, + "paths": [ + 4, + 6, + 7, + 8, + 11, + 14, + 16, + 18, + 20 + ], + "classes": [ + 2, + 3, + 7, + 10, + 11, + 17, + 19 + ] + }, + { + "min": 5224, + "max": 9048, + "paths": [ + 4, + 6, + 7, + 8, + 12, + 13, + 14, + 16, + 18, + 20 + ], + "classes": [ + 2, + 3, + 10, + 11, + 17, + 19 + ] + }, + { + "min": 9048, + "max": 43008, + "paths": [ + 4, + 6, + 7, + 8, + 12, + 13, + 14, + 16, + 18, + 21 + ], + "classes": [ + 2, + 3, + 10, + 11, + 19 + ] + }, + { + "min": 43008, + "max": 50384, + "paths": [ + 4, + 6, + 7, + 9, + 12, + 13, + 14, + 16, + 18, + 21 + ], + "classes": [ + 1, + 2, + 3, + 10, + 11, + 19 + ] + }, + { + "min": 50384, + "max": null, + "paths": [ + 4, + 6, + 7, + 9, + 12, + 13, + 14, + 16, + 18, + 22 + ], + "classes": [ + 1, + 2, + 3, + 10, + 11, + 19 + ] + } + ], + "protocl": [ + { + "min": null, + "max": 0, + "paths": [ + 0, + 2, + 3, + 4, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22 + ], + "classes": [ + 1, + 2, + 3, + 4, + 7, + 8, + 10, + 11, + 15, + 16, + 17, + 19 + ] + }, + { + "min": 0, + "max": null, + "paths": [ + 1, + 2, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22 + ], + "classes": [ + 1, + 2, + 3, + 7, + 8, + 10, + 11, + 15, + 16, + 17, + 19 + ] + } + ] + }, + "path_to_class": { + "0": 19, + "1": 19, + "2": 8, + "3": 4, + "4": 19, + "5": 19, + "6": 19, + "7": 11, + "8": 19, + "9": 1, + "10": 19, + "11": 7, + "12": 19, + "13": 19, + "14": 3, + "15": 7, + "16": 10, + "17": 16, + "18": 2, + "19": 15, + "20": 17, + "21": 19, + "22": 19 + } +} \ No newline at end of file diff --git a/example/naive_rmt.json b/example/naive_rmt.json new file mode 100644 index 0000000..d8f2b7c --- /dev/null +++ b/example/naive_rmt.json @@ -0,0 +1,734 @@ +[ + { + "id": "dst_range", + "step": 0, + "match": "ternary", + "entries": 68, + "key_size": 16, + "ranges": [ + { + "min": 0, + "max": 2136, + "paths": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "classes": [ + 8, + 19, + 4 + ], + "prefixes": [ + "00000***********", + "0000100000******", + "000010000100****", + "0000100001010***", + "0000100001011000" + ] + }, + { + "min": 2136, + "max": 2224, + "paths": [ + 7 + ], + "classes": [ + 11 + ], + "prefixes": [ + "0000100001011***", + "00001000011*****", + "00001000100*****", + "000010001010****", + "0000100010110000" + ] + }, + { + "min": 2224, + "max": 5016, + "paths": [ + 8, + 9 + ], + "classes": [ + 1, + 19 + ], + "prefixes": [ + "000010001011****", + "0000100011******", + "00001001********", + "0000101*********", + "000011**********", + "0001000*********", + "00010010********", + "000100110*******", + "000100111000****", + "0001001110010***", + "0001001110011000" + ] + }, + { + "min": 5016, + "max": 25848, + "paths": [ + 10, + 11, + 12 + ], + "classes": [ + 19, + 7 + ], + "prefixes": [ + "0001001110011***", + "00010011101*****", + "0001001111******", + "000101**********", + "00011***********", + "001*************", + "010*************", + "011000**********", + "011001000*******", + "0110010010******", + "01100100110*****", + "011001001110****", + "0110010011110***", + "0110010011111000" + ] + }, + { + "min": 25848, + "max": 47936, + "paths": [ + 10, + 11, + 13 + ], + "classes": [ + 19, + 7 + ], + "prefixes": [ + "0110010011111***", + "01100101********", + "0110011*********", + "01101***********", + "0111************", + "100*************", + "1010************", + "10110***********", + "1011100*********", + "10111010********", + "1011101100******", + "1011101101000000" + ] + }, + { + "min": 47936, + "max": 47944, + "paths": [ + 14 + ], + "classes": [ + 3 + ], + "prefixes": [ + "1011101101000***", + "1011101101001000" + ] + }, + { + "min": 47944, + "max": 49152, + "paths": [ + 16, + 15 + ], + "classes": [ + 10, + 7 + ], + "prefixes": [ + "1011101101001***", + "101110110101****", + "10111011011*****", + "101110111*******", + "101111**********", + "1100000000000000" + ] + }, + { + "min": 49152, + "max": 49160, + "paths": [ + 17, + 18 + ], + "classes": [ + 16, + 2 + ], + "prefixes": [ + "1100000000000***", + "1100000000001000" + ] + }, + { + "min": 49160, + "max": 65536, + "paths": [ + 19, + 20, + 21, + 22 + ], + "classes": [ + 17, + 19, + 15 + ], + "prefixes": [ + "1100000000001***", + "110000000001****", + "11000000001*****", + "1100000001******", + "110000001*******", + "11000001********", + "1100001*********", + "110001**********", + "11001***********", + "1101************", + "111*************" + ] + } + ] + }, + { + "id": "dst_meta", + "step": 0, + "match": "exact", + "method": "index", + "key_size": 4, + "data_size": 20 + }, + { + "id": "src_range", + "step": 1, + "match": "ternary", + "entries": 87, + "key_size": 16, + "ranges": [ + { + "min": 0, + "max": 64, + "paths": [ + 0, + 1, + 7, + 8, + 10, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 7, + 11, + 15, + 16, + 19 + ], + "prefixes": [ + "0000000000******", + "0000000001000000" + ] + }, + { + "min": 64, + "max": 128, + "paths": [ + 3, + 5, + 7, + 8, + 10, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 4, + 7, + 11, + 15, + 16, + 19 + ], + "prefixes": [ + "0000000001******", + "0000000010000000" + ] + }, + { + "min": 128, + "max": 280, + "paths": [ + 3, + 6, + 7, + 8, + 10, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 4, + 7, + 11, + 15, + 16, + 19 + ], + "prefixes": [ + "000000001*******", + "000000010000****", + "0000000100010***", + "0000000100011000" + ] + }, + { + "min": 280, + "max": 816, + "paths": [ + 3, + 6, + 7, + 8, + 11, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 4, + 7, + 11, + 15, + 16, + 19 + ], + "prefixes": [ + "0000000100011***", + "00000001001*****", + "0000000101******", + "000000011*******", + "00000010********", + "00000011000*****", + "000000110010****", + "0000001100110000" + ] + }, + { + "min": 816, + "max": 1576, + "paths": [ + 4, + 6, + 7, + 8, + 11, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 7, + 11, + 15, + 16, + 19 + ], + "prefixes": [ + "000000110011****", + "0000001101******", + "000000111*******", + "0000010*********", + "00000110000*****", + "0000011000100***", + "0000011000101000" + ] + }, + { + "min": 1576, + "max": 2488, + "paths": [ + 4, + 6, + 7, + 8, + 11, + 14, + 15, + 18, + 19 + ], + "classes": [ + 2, + 3, + 7, + 11, + 15, + 19 + ], + "prefixes": [ + "0000011000101***", + "000001100011****", + "0000011001******", + "000001101*******", + "00000111********", + "00001000********", + "000010010*******", + "00001001100*****", + "000010011010****", + "0000100110110***", + "0000100110111000" + ] + }, + { + "min": 2488, + "max": 4776, + "paths": [ + 4, + 6, + 7, + 8, + 11, + 14, + 16, + 18, + 19 + ], + "classes": [ + 2, + 3, + 7, + 10, + 11, + 15, + 19 + ], + "prefixes": [ + "0000100110111***", + "0000100111******", + "0000101*********", + "000011**********", + "0001000*********", + "000100100*******", + "00010010100*****", + "0001001010100***", + "0001001010101000" + ] + }, + { + "min": 4776, + "max": 5224, + "paths": [ + 4, + 6, + 7, + 8, + 11, + 14, + 16, + 18, + 20 + ], + "classes": [ + 2, + 3, + 7, + 10, + 11, + 17, + 19 + ], + "prefixes": [ + "0001001010101***", + "000100101011****", + "0001001011******", + "00010011********", + "0001010000******", + "00010100010*****", + "0001010001100***", + "0001010001101000" + ] + }, + { + "min": 5224, + "max": 9048, + "paths": [ + 4, + 6, + 7, + 8, + 12, + 13, + 14, + 16, + 18, + 20 + ], + "classes": [ + 2, + 3, + 10, + 11, + 17, + 19 + ], + "prefixes": [ + "0001010001101***", + "000101000111****", + "000101001*******", + "00010101********", + "0001011*********", + "00011***********", + "0010000*********", + "00100010********", + "0010001100******", + "001000110100****", + "0010001101010***", + "0010001101011000" + ] + }, + { + "min": 9048, + "max": 43008, + "paths": [ + 4, + 6, + 7, + 8, + 12, + 13, + 14, + 16, + 18, + 21 + ], + "classes": [ + 2, + 3, + 10, + 11, + 19 + ], + "prefixes": [ + "0010001101011***", + "00100011011*****", + "001000111*******", + "001001**********", + "00101***********", + "0011************", + "01**************", + "100*************", + "10100***********", + "1010100000000000" + ] + }, + { + "min": 43008, + "max": 50384, + "paths": [ + 4, + 6, + 7, + 9, + 12, + 13, + 14, + 16, + 18, + 21 + ], + "classes": [ + 1, + 2, + 3, + 10, + 11, + 19 + ], + "prefixes": [ + "10101***********", + "1011************", + "110000**********", + "110001000*******", + "1100010010******", + "110001001100****", + "1100010011010000" + ] + }, + { + "min": 50384, + "max": 65536, + "paths": [ + 4, + 6, + 7, + 9, + 12, + 13, + 14, + 16, + 18, + 22 + ], + "classes": [ + 1, + 2, + 3, + 10, + 11, + 19 + ], + "prefixes": [ + "110001001101****", + "11000100111*****", + "11000101********", + "1100011*********", + "11001***********", + "1101************", + "111*************" + ] + } + ] + }, + { + "id": "src_meta", + "step": 1, + "match": "exact", + "method": "index", + "key_size": 4, + "data_size": 20 + }, + { + "id": "protocl_range", + "step": 2, + "match": "ternary", + "entries": 2, + "key_size": 8, + "ranges": [ + { + "min": 0, + "max": 0, + "paths": [ + 0, + 2, + 3, + 4, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22 + ], + "classes": [ + 1, + 2, + 3, + 4, + 7, + 8, + 10, + 11, + 15, + 16, + 17, + 19 + ], + "prefixes": [ + "00000000" + ] + }, + { + "min": 0, + "max": 256, + "paths": [ + 1, + 2, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22 + ], + "classes": [ + 1, + 2, + 3, + 7, + 8, + 10, + 11, + 15, + 16, + 17, + 19 + ], + "prefixes": [ + "********" + ] + } + ] + }, + { + "id": "protocl_meta", + "step": 2, + "match": "exact", + "method": "index", + "key_size": 1, + "data_size": 20 + } +] \ No newline at end of file diff --git a/example/priority_aware.json b/example/priority_aware.json new file mode 100644 index 0000000..868d481 --- /dev/null +++ b/example/priority_aware.json @@ -0,0 +1,700 @@ +[ + { + "id": "dst_range", + "step": 0, + "match": "ternary", + "entries": 42, + "key_size": 16, + "ranges": [ + { + "min": 0, + "max": 2136, + "paths": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "classes": [ + 8, + 19, + 4 + ], + "prefixes": [ + "00000***********", + "0000100000******", + "000010000100****", + "0000100001010***", + "0000100001011000" + ], + "prefix_type": "exact" + }, + { + "min": 2136, + "max": 2224, + "paths": [ + 7 + ], + "classes": [ + 11 + ], + "prefixes": [ + "0000100001011***", + "00001000011*****", + "00001000100*****", + "000010001010****", + "0000100010110000" + ], + "prefix_type": "exact" + }, + { + "min": 2224, + "max": 5016, + "paths": [ + 8, + 9 + ], + "classes": [ + 1, + 19 + ], + "prefixes": [ + "0000************", + "0001000*********", + "00010010********", + "000100110*******", + "000100111000****", + "0001001110010***", + "0001001110011000" + ], + "prefix_type": "zero" + }, + { + "min": 5016, + "max": 25848, + "paths": [ + 10, + 11, + 12 + ], + "classes": [ + 19, + 7 + ], + "prefixes": [ + "00**************", + "010*************", + "011000**********", + "011001000*******", + "0110010010******", + "01100100110*****", + "011001001110****", + "0110010011110***", + "0110010011111000" + ], + "prefix_type": "zero" + }, + { + "min": 25848, + "max": 47936, + "paths": [ + 10, + 11, + 13 + ], + "classes": [ + 19, + 7 + ], + "prefixes": [ + "0***************", + "100*************", + "1010************", + "10110***********", + "1011100*********", + "10111010********", + "1011101100******", + "1011101101000000" + ], + "prefix_type": "zero" + }, + { + "min": 47936, + "max": 47944, + "paths": [ + 14 + ], + "classes": [ + 3 + ], + "prefixes": [ + "1011101101000***", + "1011101101001000" + ], + "prefix_type": "exact" + }, + { + "min": 47944, + "max": 49152, + "paths": [ + 16, + 15 + ], + "classes": [ + 10, + 7 + ], + "prefixes": [ + "0***************", + "10**************", + "1100000000000000" + ], + "prefix_type": "zero" + }, + { + "min": 49152, + "max": 49160, + "paths": [ + 17, + 18 + ], + "classes": [ + 16, + 2 + ], + "prefixes": [ + "1100000000000***", + "1100000000001000" + ], + "prefix_type": "exact" + }, + { + "min": 49160, + "max": 65536, + "paths": [ + 19, + 20, + 21, + 22 + ], + "classes": [ + 17, + 19, + 15 + ], + "prefixes": [ + "****************" + ], + "prefix_type": "zero" + } + ] + }, + { + "id": "dst_meta", + "step": 0, + "match": "exact", + "method": "index", + "key_size": 4, + "data_size": 20 + }, + { + "id": "src_range", + "step": 1, + "match": "ternary", + "entries": 56, + "key_size": 16, + "ranges": [ + { + "min": 0, + "max": 64, + "paths": [ + 0, + 1, + 7, + 8, + 10, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 7, + 11, + 15, + 16, + 19 + ], + "prefixes": [ + "0000000000******", + "0000000001000000" + ], + "prefix_type": "exact" + }, + { + "min": 64, + "max": 128, + "paths": [ + 3, + 5, + 7, + 8, + 10, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 4, + 7, + 11, + 15, + 16, + 19 + ], + "prefixes": [ + "0000000001******", + "0000000010000000" + ], + "prefix_type": "exact" + }, + { + "min": 128, + "max": 280, + "paths": [ + 3, + 6, + 7, + 8, + 10, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 4, + 7, + 11, + 15, + 16, + 19 + ], + "prefixes": [ + "000000001*******", + "000000010000****", + "0000000100010***", + "0000000100011000" + ], + "prefix_type": "exact" + }, + { + "min": 280, + "max": 816, + "paths": [ + 3, + 6, + 7, + 8, + 11, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 4, + 7, + 11, + 15, + 16, + 19 + ], + "prefixes": [ + "0000000*********", + "00000010********", + "00000011000*****", + "000000110010****", + "0000001100110000" + ], + "prefix_type": "zero" + }, + { + "min": 816, + "max": 1576, + "paths": [ + 4, + 6, + 7, + 8, + 11, + 14, + 15, + 17, + 19 + ], + "classes": [ + 3, + 7, + 11, + 15, + 16, + 19 + ], + "prefixes": [ + "000000**********", + "0000010*********", + "00000110000*****", + "0000011000100***", + "0000011000101000" + ], + "prefix_type": "zero" + }, + { + "min": 1576, + "max": 2488, + "paths": [ + 4, + 6, + 7, + 8, + 11, + 14, + 15, + 18, + 19 + ], + "classes": [ + 2, + 3, + 7, + 11, + 15, + 19 + ], + "prefixes": [ + "00000***********", + "00001000********", + "000010010*******", + "00001001100*****", + "000010011010****", + "0000100110110***", + "0000100110111000" + ], + "prefix_type": "zero" + }, + { + "min": 2488, + "max": 4776, + "paths": [ + 4, + 6, + 7, + 8, + 11, + 14, + 16, + 18, + 19 + ], + "classes": [ + 2, + 3, + 7, + 10, + 11, + 15, + 19 + ], + "prefixes": [ + "0000************", + "0001000*********", + "000100100*******", + "00010010100*****", + "0001001010100***", + "0001001010101000" + ], + "prefix_type": "zero" + }, + { + "min": 4776, + "max": 5224, + "paths": [ + 4, + 6, + 7, + 8, + 11, + 14, + 16, + 18, + 20 + ], + "classes": [ + 2, + 3, + 7, + 10, + 11, + 17, + 19 + ], + "prefixes": [ + "0000************", + "000100**********", + "0001010000******", + "00010100010*****", + "0001010001100***", + "0001010001101000" + ], + "prefix_type": "zero" + }, + { + "min": 5224, + "max": 9048, + "paths": [ + 4, + 6, + 7, + 8, + 12, + 13, + 14, + 16, + 18, + 20 + ], + "classes": [ + 2, + 3, + 10, + 11, + 17, + 19 + ], + "prefixes": [ + "000*************", + "0010000*********", + "00100010********", + "0010001100******", + "001000110100****", + "0010001101010***", + "0010001101011000" + ], + "prefix_type": "zero" + }, + { + "min": 9048, + "max": 43008, + "paths": [ + 4, + 6, + 7, + 8, + 12, + 13, + 14, + 16, + 18, + 21 + ], + "classes": [ + 2, + 3, + 10, + 11, + 19 + ], + "prefixes": [ + "0***************", + "100*************", + "10100***********", + "1010100000000000" + ], + "prefix_type": "zero" + }, + { + "min": 43008, + "max": 50384, + "paths": [ + 4, + 6, + 7, + 9, + 12, + 13, + 14, + 16, + 18, + 21 + ], + "classes": [ + 1, + 2, + 3, + 10, + 11, + 19 + ], + "prefixes": [ + "10101***********", + "1011************", + "110000**********", + "110001000*******", + "1100010010******", + "110001001100****", + "1100010011010000" + ], + "prefix_type": "exact" + }, + { + "min": 50384, + "max": 65536, + "paths": [ + 4, + 6, + 7, + 9, + 12, + 13, + 14, + 16, + 18, + 22 + ], + "classes": [ + 1, + 2, + 3, + 10, + 11, + 19 + ], + "prefixes": [ + "****************" + ], + "prefix_type": "zero" + } + ] + }, + { + "id": "src_meta", + "step": 1, + "match": "exact", + "method": "index", + "key_size": 4, + "data_size": 20 + }, + { + "id": "protocl_range", + "step": 2, + "match": "ternary", + "entries": 2, + "key_size": 8, + "ranges": [ + { + "min": 0, + "max": 0, + "paths": [ + 0, + 2, + 3, + 4, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22 + ], + "classes": [ + 1, + 2, + 3, + 4, + 7, + 8, + 10, + 11, + 15, + 16, + 17, + 19 + ], + "prefixes": [ + "00000000" + ], + "prefix_type": "exact" + }, + { + "min": 0, + "max": 256, + "paths": [ + 1, + 2, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22 + ], + "classes": [ + 1, + 2, + 3, + 7, + 8, + 10, + 11, + 15, + 16, + 17, + 19 + ], + "prefixes": [ + "********" + ], + "prefix_type": "exact" + } + ] + }, + { + "id": "protocl_meta", + "step": 2, + "match": "exact", + "method": "index", + "key_size": 1, + "data_size": 20 + } +] \ No newline at end of file diff --git a/example/tree.json b/example/tree.json new file mode 100644 index 0000000..fbd87b3 --- /dev/null +++ b/example/tree.json @@ -0,0 +1,744 @@ +{ + "features": { + "dst": [ + 47936.0, + 2128.0, + 5024.0, + 2224.0, + 25856.0, + 47936.0, + 49168.0, + 49152.0 + ], + "src": [ + 64.0, + 64.0, + 816.0, + 128.0, + 43008.0, + 5232.0, + 288.0, + 2480.0, + 1584.0, + 9040.0, + 4784.0, + 50384.0 + ], + "protocl": [ + 0.0, + 0.0 + ] + }, + "paths": [ + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 2128.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 64.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 64.0 + }, + { + "feature": "protocl", + "operation": "<=", + "value": 0.0 + } + ], + "classification": 19, + "id": 0 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 2128.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 64.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 64.0 + }, + { + "feature": "protocl", + "operation": ">", + "value": 0.0 + } + ], + "classification": 19, + "id": 1 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 2128.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 64.0 + }, + { + "feature": "src", + "operation": ">", + "value": 64.0 + } + ], + "classification": 8, + "id": 2 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 2128.0 + }, + { + "feature": "src", + "operation": ">", + "value": 64.0 + }, + { + "feature": "protocl", + "operation": "<=", + "value": 0.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 816.0 + } + ], + "classification": 4, + "id": 3 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 2128.0 + }, + { + "feature": "src", + "operation": ">", + "value": 64.0 + }, + { + "feature": "protocl", + "operation": "<=", + "value": 0.0 + }, + { + "feature": "src", + "operation": ">", + "value": 816.0 + } + ], + "classification": 19, + "id": 4 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 2128.0 + }, + { + "feature": "src", + "operation": ">", + "value": 64.0 + }, + { + "feature": "protocl", + "operation": ">", + "value": 0.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 128.0 + } + ], + "classification": 19, + "id": 5 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 2128.0 + }, + { + "feature": "src", + "operation": ">", + "value": 64.0 + }, + { + "feature": "protocl", + "operation": ">", + "value": 0.0 + }, + { + "feature": "src", + "operation": ">", + "value": 128.0 + } + ], + "classification": 19, + "id": 6 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 2128.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 5024.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 2224.0 + } + ], + "classification": 11, + "id": 7 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 2128.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 5024.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 2224.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 43008.0 + } + ], + "classification": 19, + "id": 8 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 2128.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 5024.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 2224.0 + }, + { + "feature": "src", + "operation": ">", + "value": 43008.0 + } + ], + "classification": 1, + "id": 9 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 2128.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 5024.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 5232.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 288.0 + } + ], + "classification": 19, + "id": 10 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 2128.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 5024.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 5232.0 + }, + { + "feature": "src", + "operation": ">", + "value": 288.0 + } + ], + "classification": 7, + "id": 11 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 2128.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 5024.0 + }, + { + "feature": "src", + "operation": ">", + "value": 5232.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 25856.0 + } + ], + "classification": 19, + "id": 12 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 2128.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 5024.0 + }, + { + "feature": "src", + "operation": ">", + "value": 5232.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 25856.0 + } + ], + "classification": 19, + "id": 13 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 47936.0 + } + ], + "classification": 3, + "id": 14 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 49168.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 49152.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 2480.0 + } + ], + "classification": 7, + "id": 15 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 49168.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 49152.0 + }, + { + "feature": "src", + "operation": ">", + "value": 2480.0 + } + ], + "classification": 10, + "id": 16 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 49168.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 49152.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 1584.0 + } + ], + "classification": 16, + "id": 17 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": "<=", + "value": 49168.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 49152.0 + }, + { + "feature": "src", + "operation": ">", + "value": 1584.0 + } + ], + "classification": 2, + "id": 18 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 49168.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 9040.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 4784.0 + } + ], + "classification": 15, + "id": 19 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 49168.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 9040.0 + }, + { + "feature": "src", + "operation": ">", + "value": 4784.0 + } + ], + "classification": 17, + "id": 20 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 49168.0 + }, + { + "feature": "src", + "operation": ">", + "value": 9040.0 + }, + { + "feature": "src", + "operation": "<=", + "value": 50384.0 + } + ], + "classification": 19, + "id": 21 + }, + { + "conditions": [ + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 47936.0 + }, + { + "feature": "dst", + "operation": ">", + "value": 49168.0 + }, + { + "feature": "src", + "operation": ">", + "value": 9040.0 + }, + { + "feature": "src", + "operation": ">", + "value": 50384.0 + } + ], + "classification": 19, + "id": 22 + } + ], + "classes": [ + "Amazon Echo", + "Belkin Motion Sensor", + "Belkin Switch", + "Dropcam", + "HP Printer", + "LiFX Bulb", + "NEST Smoke Sensor", + "Netatmo Camera", + "Netatmo Weather station", + "Pixstart photo frame", + "Samsung Smart Cam", + "Smart Things", + "TP-Link Camera", + "TP-Link Plug", + "Triby Speaker", + "Withings", + "Withings Scale", + "Withings sleep sensor", + "iHome PowerPlug", + "other" + ] +} \ No newline at end of file diff --git a/example/worst_case_rmt.json b/example/worst_case_rmt.json new file mode 100644 index 0000000..97e7163 --- /dev/null +++ b/example/worst_case_rmt.json @@ -0,0 +1,47 @@ +[ + { + "id": "dst_range", + "step": 0, + "match": "ternary", + "entries": 288, + "key_size": 16 + }, + { + "id": "dst_meta", + "step": 0, + "match": "exact", + "method": "index", + "key_size": 4, + "data_size": 20 + }, + { + "id": "src_range", + "step": 1, + "match": "ternary", + "entries": 384, + "key_size": 16 + }, + { + "id": "src_meta", + "step": 1, + "match": "exact", + "method": "index", + "key_size": 4, + "data_size": 20 + }, + { + "id": "protocl_range", + "step": 2, + "match": "ternary", + "entries": 32, + "key_size": 8 + }, + { + "id": "protocl_meta", + "step": 2, + "match": "exact", + "method": "index", + "key_size": 1, + "data_size": 20 + } +] \ No newline at end of file