From 5f09967138240187e2159b1ab9ac7911f0c11d63 Mon Sep 17 00:00:00 2001 From: kirill Date: Sat, 29 Mar 2025 18:44:15 +0300 Subject: [PATCH 1/4] Add test --- back/src/test_json/arp_proxy_answer.json | 1 + back/src/test_json/arp_proxy_network.json | 136 ++++++++++++++++++++++ back/src/test_miminet_example_works.py | 3 +- 3 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 back/src/test_json/arp_proxy_answer.json create mode 100644 back/src/test_json/arp_proxy_network.json diff --git a/back/src/test_json/arp_proxy_answer.json b/back/src/test_json/arp_proxy_answer.json new file mode 100644 index 00000000..2c0873a5 --- /dev/null +++ b/back/src/test_json/arp_proxy_answer.json @@ -0,0 +1 @@ +[[{"data":{"id":"pkt_30UQ62T3","label":"ARP-request\nWho has 10.0.1.2? Tell 10.0.0.1","type":"packet"},"config":{"type":"ARP-request\nWho has 10.0.1.2? Tell 10.0.0.1","path":"edge_m8u7gssjgno35ir8b3","source":"host_1","target":"router_1"},"timestamp":"1743252524956497"}],[{"data":{"id":"pkt_DX5S7CYE","label":"ARP-response\n10.0.1.2 at 3a:1f:9a:4c:0c:1a","type":"packet"},"config":{"type":"ARP-response\n10.0.1.2 at 3a:1f:9a:4c:0c:1a","path":"edge_m8u7gssjgno35ir8b3","source":"router_1","target":"host_1"},"timestamp":"1743252525155087"}],[{"data":{"id":"pkt_ADJGEGRT","label":"ICMP echo-request\n10.0.0.1 > 10.0.1.2","type":"packet"},"config":{"type":"ICMP echo-request\n10.0.0.1 > 10.0.1.2","path":"edge_m8u7gssjgno35ir8b3","source":"host_1","target":"router_1"},"timestamp":"1743252525170923"}],[{"data":{"id":"pkt_C3XMUXXA","label":"ARP-request\nWho has 10.0.1.2? Tell 10.0.1.1","type":"packet"},"config":{"type":"ARP-request\nWho has 10.0.1.2? Tell 10.0.1.1","path":"edge_m8u7gui9n4nyg3jko6","source":"router_1","target":"host_2"},"timestamp":"1743252525186583"}],[{"data":{"id":"pkt_YNNRTQ11","label":"ARP-response\n10.0.1.2 at 00:00:00:00:00:02","type":"packet"},"config":{"type":"ARP-response\n10.0.1.2 at 00:00:00:00:00:02","path":"edge_m8u7gui9n4nyg3jko6","source":"host_2","target":"router_1"},"timestamp":"1743252525202021"}],[{"data":{"id":"pkt_JW3G6O8Y","label":"ICMP echo-request\n10.0.0.1 > 10.0.1.2","type":"packet"},"config":{"type":"ICMP echo-request\n10.0.0.1 > 10.0.1.2","path":"edge_m8u7gui9n4nyg3jko6","source":"router_1","target":"host_2"},"timestamp":"1743252525217772"}],[{"data":{"id":"pkt_LMWCGNJ0","label":"ARP-request\nWho has 10.0.0.1? Tell 10.0.1.2","type":"packet"},"config":{"type":"ARP-request\nWho has 10.0.0.1? Tell 10.0.1.2","path":"edge_m8u7gui9n4nyg3jko6","source":"host_2","target":"router_1"},"timestamp":"1743252525233332"}],[{"data":{"id":"pkt_FJ9Q4QVI","label":"ARP-response\n10.0.0.1 at 4e:bb:49:e6:43:1a","type":"packet"},"config":{"type":"ARP-response\n10.0.0.1 at 4e:bb:49:e6:43:1a","path":"edge_m8u7gui9n4nyg3jko6","source":"router_1","target":"host_2"},"timestamp":"1743252525578950"}],[{"data":{"id":"pkt_9EZT052B","label":"ICMP echo-reply\n10.0.1.2 > 10.0.0.1","type":"packet"},"config":{"type":"ICMP echo-reply\n10.0.1.2 > 10.0.0.1","path":"edge_m8u7gui9n4nyg3jko6","source":"host_2","target":"router_1"},"timestamp":"1743252525594378"}],[{"data":{"id":"pkt_G1N1MM6S","label":"ICMP echo-reply\n10.0.1.2 > 10.0.0.1","type":"packet"},"config":{"type":"ICMP echo-reply\n10.0.1.2 > 10.0.0.1","path":"edge_m8u7gssjgno35ir8b3","source":"router_1","target":"host_1"},"timestamp":"1743252525610329"}]] \ No newline at end of file diff --git a/back/src/test_json/arp_proxy_network.json b/back/src/test_json/arp_proxy_network.json new file mode 100644 index 00000000..8af14b19 --- /dev/null +++ b/back/src/test_json/arp_proxy_network.json @@ -0,0 +1,136 @@ +{ + "jobs": [ + { + "arg_1": "10.0.1.2", + "host_id": "host_1", + "id": "866e0a6e9de9450dba6e9a12c55f762e", + "job_id": 1, + "level": 0, + "print_cmd": "ping -c 1 10.0.1.2" + }, + { + "arg_1": "iface_74627000", + "arg_2": "host_1", + "host_id": "router_1", + "id": "9eb7c8b8a5d44a7bbf8d9dd40a7c568b", + "job_id": 107, + "level": 1, + "print_cmd": "arp proxy: host_1" + }, + { + "arg_1": "iface_36584304", + "arg_2": "host_2", + "host_id": "router_1", + "id": "8a8ac1210bd54902a7b81b555b5e9d0a", + "job_id": 107, + "level": 2, + "print_cmd": "arp proxy: host_2" + } + ], + "nodes": [ + { + "classes": [ "host" ], + "config": { + "default_gw": "", + "label": "host_1", + "type": "host" + }, + "data": { + "id": "host_1", + "label": "host_1" + }, + "interface": [ + { + "connect": "edge_m8u7gssjgno35ir8b3", + "id": "iface_37257110", + "ip": "10.0.0.1", + "name": "iface_37257110", + "netmask": 12 + } + ], + "position": { + "x": 126.25, + "y": 193 + } + }, + { + "classes": [ "l3_router" ], + "config": { + "default_gw": "", + "label": "router_1", + "type": "router" + }, + "data": { + "id": "router_1", + "label": "router_1" + }, + "interface": [ + { + "connect": "edge_m8u7gssjgno35ir8b3", + "id": "iface_74627000", + "ip": "10.0.0.2", + "name": "iface_74627000", + "netmask": 24 + }, + { + "connect": "edge_m8u7gui9n4nyg3jko6", + "id": "iface_36584304", + "ip": "10.0.1.1", + "name": "iface_36584304", + "netmask": 24 + } + ], + "position": { + "x": 210.25, + "y": 119.796875 + } + }, + { + "classes": [ "host" ], + "config": { + "default_gw": "", + "label": "host_2", + "type": "host" + }, + "data": { + "id": "host_2", + "label": "host_2" + }, + "interface": [ + { + "connect": "edge_m8u7gui9n4nyg3jko6", + "id": "iface_16763880", + "ip": "10.0.1.2", + "name": "iface_16763880", + "netmask": 12 + } + ], + "position": { + "x": 291.25, + "y": 188.5 + } + } + ], + "edges": [ + { + "data": { + "id": "edge_m8u7gssjgno35ir8b3", + "source": "host_1", + "target": "router_1" + } + }, + { + "data": { + "id": "edge_m8u7gui9n4nyg3jko6", + "source": "router_1", + "target": "host_2" + } + } + ], + "config": { + "zoom": 2, + "pan_x": 0, + "pan_y": 0 + }, + "pcap": [] +} \ No newline at end of file diff --git a/back/src/test_miminet_example_works.py b/back/src/test_miminet_example_works.py index b0bfe999..cf8c37c9 100644 --- a/back/src/test_miminet_example_works.py +++ b/back/src/test_miminet_example_works.py @@ -35,6 +35,7 @@ def read_files(network_filename: str, answer_filename: str): ("vlan_with_access_switches_network.json", "vlan_with_access_switches_answer.json"), ("rstp_simple_network.json", "rstp_simple_answer.json"), ("rstp_four_switch_network.json", "rstp_four_switch_answer.json"), + ("arp_proxy_network.json", "arp_proxy_answer.json") ] DINAMYC_PORT_FILE_NAMES = [ @@ -82,7 +83,7 @@ def read_files(network_filename: str, answer_filename: str): ] TEST_CASES = [ - Case(network, answer) + Case(network, answer)п for (network, answer) in [read_files(file[0], file[1]) for file in FILE_NAMES] ] From 7c0971662a0eb8add8228dee16da29a90976e3c5 Mon Sep 17 00:00:00 2001 From: kirill Date: Sat, 29 Mar 2025 18:48:44 +0300 Subject: [PATCH 2/4] Fix symbol --- back/src/test_miminet_example_works.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/src/test_miminet_example_works.py b/back/src/test_miminet_example_works.py index cf8c37c9..ba78c5d5 100644 --- a/back/src/test_miminet_example_works.py +++ b/back/src/test_miminet_example_works.py @@ -83,7 +83,7 @@ def read_files(network_filename: str, answer_filename: str): ] TEST_CASES = [ - Case(network, answer)п + Case(network, answer) for (network, answer) in [read_files(file[0], file[1]) for file in FILE_NAMES] ] From 719cc3887216357551f9a77d44d0a99d966e822d Mon Sep 17 00:00:00 2001 From: kirill Date: Sat, 29 Mar 2025 18:58:55 +0300 Subject: [PATCH 3/4] Fix test --- back/src/test_miminet_example_works.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/back/src/test_miminet_example_works.py b/back/src/test_miminet_example_works.py index ba78c5d5..dd58bd49 100644 --- a/back/src/test_miminet_example_works.py +++ b/back/src/test_miminet_example_works.py @@ -56,6 +56,13 @@ def read_files(network_filename: str, answer_filename: str): len("ARP-response\\n10.0.0.1 at "), r"mac", ), + ( + "arp_proxy_network.json", + "arp_proxy_answer.json", + r"ARP-response\\n.+ at ([0-9a-fA-F]{2}[:]){6}", + len("ARP-response\\n10.0.0.1 at "), + r"mac", + ), ] From e3faf45c1101fbbb146c3f7be5621f4c12d1a80d Mon Sep 17 00:00:00 2001 From: kirill Date: Sat, 29 Mar 2025 19:38:10 +0300 Subject: [PATCH 4/4] Fix answer --- back/src/test_json/arp_proxy_answer.json | 163 ++++++++++++++++++++++- back/src/test_miminet_example_works.py | 1 - 2 files changed, 162 insertions(+), 2 deletions(-) diff --git a/back/src/test_json/arp_proxy_answer.json b/back/src/test_json/arp_proxy_answer.json index 2c0873a5..1dfcce37 100644 --- a/back/src/test_json/arp_proxy_answer.json +++ b/back/src/test_json/arp_proxy_answer.json @@ -1 +1,162 @@ -[[{"data":{"id":"pkt_30UQ62T3","label":"ARP-request\nWho has 10.0.1.2? Tell 10.0.0.1","type":"packet"},"config":{"type":"ARP-request\nWho has 10.0.1.2? Tell 10.0.0.1","path":"edge_m8u7gssjgno35ir8b3","source":"host_1","target":"router_1"},"timestamp":"1743252524956497"}],[{"data":{"id":"pkt_DX5S7CYE","label":"ARP-response\n10.0.1.2 at 3a:1f:9a:4c:0c:1a","type":"packet"},"config":{"type":"ARP-response\n10.0.1.2 at 3a:1f:9a:4c:0c:1a","path":"edge_m8u7gssjgno35ir8b3","source":"router_1","target":"host_1"},"timestamp":"1743252525155087"}],[{"data":{"id":"pkt_ADJGEGRT","label":"ICMP echo-request\n10.0.0.1 > 10.0.1.2","type":"packet"},"config":{"type":"ICMP echo-request\n10.0.0.1 > 10.0.1.2","path":"edge_m8u7gssjgno35ir8b3","source":"host_1","target":"router_1"},"timestamp":"1743252525170923"}],[{"data":{"id":"pkt_C3XMUXXA","label":"ARP-request\nWho has 10.0.1.2? Tell 10.0.1.1","type":"packet"},"config":{"type":"ARP-request\nWho has 10.0.1.2? Tell 10.0.1.1","path":"edge_m8u7gui9n4nyg3jko6","source":"router_1","target":"host_2"},"timestamp":"1743252525186583"}],[{"data":{"id":"pkt_YNNRTQ11","label":"ARP-response\n10.0.1.2 at 00:00:00:00:00:02","type":"packet"},"config":{"type":"ARP-response\n10.0.1.2 at 00:00:00:00:00:02","path":"edge_m8u7gui9n4nyg3jko6","source":"host_2","target":"router_1"},"timestamp":"1743252525202021"}],[{"data":{"id":"pkt_JW3G6O8Y","label":"ICMP echo-request\n10.0.0.1 > 10.0.1.2","type":"packet"},"config":{"type":"ICMP echo-request\n10.0.0.1 > 10.0.1.2","path":"edge_m8u7gui9n4nyg3jko6","source":"router_1","target":"host_2"},"timestamp":"1743252525217772"}],[{"data":{"id":"pkt_LMWCGNJ0","label":"ARP-request\nWho has 10.0.0.1? Tell 10.0.1.2","type":"packet"},"config":{"type":"ARP-request\nWho has 10.0.0.1? Tell 10.0.1.2","path":"edge_m8u7gui9n4nyg3jko6","source":"host_2","target":"router_1"},"timestamp":"1743252525233332"}],[{"data":{"id":"pkt_FJ9Q4QVI","label":"ARP-response\n10.0.0.1 at 4e:bb:49:e6:43:1a","type":"packet"},"config":{"type":"ARP-response\n10.0.0.1 at 4e:bb:49:e6:43:1a","path":"edge_m8u7gui9n4nyg3jko6","source":"router_1","target":"host_2"},"timestamp":"1743252525578950"}],[{"data":{"id":"pkt_9EZT052B","label":"ICMP echo-reply\n10.0.1.2 > 10.0.0.1","type":"packet"},"config":{"type":"ICMP echo-reply\n10.0.1.2 > 10.0.0.1","path":"edge_m8u7gui9n4nyg3jko6","source":"host_2","target":"router_1"},"timestamp":"1743252525594378"}],[{"data":{"id":"pkt_G1N1MM6S","label":"ICMP echo-reply\n10.0.1.2 > 10.0.0.1","type":"packet"},"config":{"type":"ICMP echo-reply\n10.0.1.2 > 10.0.0.1","path":"edge_m8u7gssjgno35ir8b3","source":"router_1","target":"host_1"},"timestamp":"1743252525610329"}]] \ No newline at end of file +[ + [ + { + "data": { + "id": "", + "label": "ARP-request\nWho has 10.0.1.2? Tell 10.0.0.1", + "type": "packet" + }, + "config": { + "type": "ARP-request\nWho has 10.0.1.2? Tell 10.0.0.1", + "path": "edge_m8u7gssjgno35ir8b3", + "source": "host_1", + "target": "router_1" + }, + "timestamp": "" + } + ], + [ + { + "data": { + "id": "", + "label": "ARP-response", + "type": "packet" + }, + "config": { + "type": "ARP-response", + "path": "edge_m8u7gssjgno35ir8b3", + "source": "router_1", + "target": "host_1" + }, + "timestamp": "" + } + ], + [ + { + "data": { + "id": "", + "label": "ICMP echo-request\n10.0.0.1 > 10.0.1.2", + "type": "packet" + }, + "config": { + "type": "ICMP echo-request\n10.0.0.1 > 10.0.1.2", + "path": "edge_m8u7gssjgno35ir8b3", + "source": "host_1", + "target": "router_1" + }, + "timestamp": "" + } + ], + [ + { + "data": { + "id": "", + "label": "ARP-request\nWho has 10.0.1.2? Tell 10.0.1.1", + "type": "packet" + }, + "config": { + "type": "ARP-request\nWho has 10.0.1.2? Tell 10.0.1.1", + "path": "edge_m8u7gui9n4nyg3jko6", + "source": "router_1", + "target": "host_2" + }, + "timestamp": "" + } + ], + [ + { + "data": { + "id": "", + "label": "ARP-response", + "type": "packet" + }, + "config": { + "type": "ARP-response", + "path": "edge_m8u7gui9n4nyg3jko6", + "source": "host_2", + "target": "router_1" + }, + "timestamp": "" + } + ], + [ + { + "data": { + "id": "", + "label": "ICMP echo-request\n10.0.0.1 > 10.0.1.2", + "type": "packet" + }, + "config": { + "type": "ICMP echo-request\n10.0.0.1 > 10.0.1.2", + "path": "edge_m8u7gui9n4nyg3jko6", + "source": "router_1", + "target": "host_2" + }, + "timestamp": "" + } + ], + [ + { + "data": { + "id": "", + "label": "ARP-request\nWho has 10.0.0.1? Tell 10.0.1.2", + "type": "packet" + }, + "config": { + "type": "ARP-request\nWho has 10.0.0.1? Tell 10.0.1.2", + "path": "edge_m8u7gui9n4nyg3jko6", + "source": "host_2", + "target": "router_1" + }, + "timestamp": "" + } + ], + [ + { + "data": { + "id": "", + "label": "ARP-response", + "type": "packet" + }, + "config": { + "type": "ARP-response", + "path": "edge_m8u7gui9n4nyg3jko6", + "source": "router_1", + "target": "host_2" + }, + "timestamp": "" + } + ], + [ + { + "data": { + "id": "", + "label": "ICMP echo-reply\n10.0.1.2 > 10.0.0.1", + "type": "packet" + }, + "config": { + "type": "ICMP echo-reply\n10.0.1.2 > 10.0.0.1", + "path": "edge_m8u7gui9n4nyg3jko6", + "source": "host_2", + "target": "router_1" + }, + "timestamp": "" + } + ], + [ + { + "config": { + "type": "ICMP echo-reply\n10.0.1.2 > 10.0.0.1", + "path": "edge_m8u7gssjgno35ir8b3", + "source": "router_1", + "target": "host_1" + }, + "data": { + "id": "", + "label": "ICMP echo-reply\n10.0.1.2 > 10.0.0.1", + "type": "packet" + }, + "timestamp": "" + } + ] +] \ No newline at end of file diff --git a/back/src/test_miminet_example_works.py b/back/src/test_miminet_example_works.py index dd58bd49..1e5830ea 100644 --- a/back/src/test_miminet_example_works.py +++ b/back/src/test_miminet_example_works.py @@ -35,7 +35,6 @@ def read_files(network_filename: str, answer_filename: str): ("vlan_with_access_switches_network.json", "vlan_with_access_switches_answer.json"), ("rstp_simple_network.json", "rstp_simple_answer.json"), ("rstp_four_switch_network.json", "rstp_four_switch_answer.json"), - ("arp_proxy_network.json", "arp_proxy_answer.json") ] DINAMYC_PORT_FILE_NAMES = [