Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
4c76b2a
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
3af22ee
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
c686f75
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
b9056d3
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
d9ef6e0
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
be0691a
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
ecdaba1
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
04571c6
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
af2ee33
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
958cae9
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
bb0e1e6
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
8a95155
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
d800316
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
0f919b9
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
072d70c
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
706a7a3
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
16f8f89
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
eff7eca
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
6e8eccf
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
ccffd25
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
de790fd
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
e79b5bc
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
3b71d59
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
0fdc1d8
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
dc45f5d
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
3cb8605
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
91614a3
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
8ba4922
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
0bdb4e5
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
328b333
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
7c31e55
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
51fc51c
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
9e631e9
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
9b99a8a
vlan support
RamProsad2 Sep 17, 2025
c619cea
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
a50b4a5
Add dynamic VLAN subinterface configuration with ARP proxy support
RamProsad2 Oct 28, 2025
137f6a2
Update ARP Proxy and VLAN handling in network modules
RamProsad2 Oct 28, 2025
2c8fdce
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
c4bffc0
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
fb7b792
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
5fd366c
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
208b760
Enhance network setup with VLAN and ARP proxy support
RamProsad2 Sep 16, 2025
bde7bfc
Enhance network setup with VLAN and ARP proxy support
RamProsad2 Sep 16, 2025
740223a
vlan for ARP proxy support
RamProsad2 Sep 16, 2025
6e36b7e
vlan update
RamProsad2 Sep 16, 2025
6549d26
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
84a22a6
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
dfdc016
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
696950d
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
dd23384
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
3175840
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
349220c
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 16, 2025
5840943
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
0253fac
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
fa85690
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
a9a7bd8
support and update VLAN handling
RamProsad2 Oct 28, 2025
d6d09f7
Add vlan.py, update network.py and jobs.py with ARP proxy support
RamProsad2 Sep 17, 2025
980cc39
fix rebases
RamProsad2 Oct 28, 2025
086b486
Vlan update
RamProsad2 Oct 29, 2025
94db28c
Update VLAN and ARP proxy handling
RamProsad2 Oct 29, 2025
38dc97e
Update VLAN support and network jobs
RamProsad2 Oct 29, 2025
8efd963
delete duplicates
RamProsad2 Nov 4, 2025
75aeb24
Update VLAN, and job logic
RamProsad2 Nov 19, 2025
428405a
Restore local changes after repo reinit
RamProsad2 Nov 19, 2025
d664b90
Update jobs and VLAN logic
RamProsad2 Nov 19, 2025
f20a2f6
Resolve merge conflict in vlan.py
RamProsad2 Dec 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 35 additions & 179 deletions back/src/jobs.py
Original file line number Diff line number Diff line change
@@ -1,189 +1,12 @@
import re
import shlex
import ipaddress

from netaddr import EUI, AddrFormatError
from typing import Any, Callable, List, Dict
from network_schema import Job


def filter_arg_for_options(
arg: str, flags_without_args: List[str], flags_with_args: Dict[str, str]
) -> str:
"""Get from str only whitelist options"""
parts = shlex.split(re.sub(r"[^A-Za-z0-9._\-]+", " ", arg))

res = ""

for idx, token in enumerate(parts):
if token in res:
continue

if token in flags_with_args and idx + 1 < len(parts):
next_arg = parts[idx + 1]
if re.fullmatch(flags_with_args[token], next_arg):
res += f"{token} {next_arg} "

elif token in flags_without_args:
res += f"{token} "

return res


def ping_options_filter(arg: str) -> str:
"""Get only whitelist options from ping options"""
flags_without_args = ["-b"]
flags_with_args = {"-c": r"([1-9]|10)", "-t": r"\d+", "-i": r"\d+", "-s": r"\d+"}

return filter_arg_for_options(arg, flags_without_args, flags_with_args)


def traceroute_options_filter(arg: str) -> str:
"""Get only whitelist options from traceout options"""
flags_without_args = ["-F", "-n"]
flags_with_args = {
"-i": r"\d+",
"-f": r"\d+",
"-g": r"\d+",
"-m": r"\d+",
"-p": r"\d+",
}
return filter_arg_for_options(arg, flags_without_args, flags_with_args)


def udp_tcp_args_checker(ip, size, port) -> bool:
"""Check all args in tcp and udp data handler on correct"""
if not valid_ip(ip):
return False

try:
_ = int(size)
_ = int(port)
except (ValueError, TypeError):
return False

return True


def net_dev_checker(dev) -> bool:
"""Checker for net interface"""
if not re.match(r"^[a-z][a-z0-9:_\-\.]{,14}$", dev):
return False
return True


def ip_addr_add_checker(ip, mask, dev) -> bool:
"""Checker all args in ip addr add job"""

if not valid_ip(ip):
return False

try:
_ = int(mask)
except (ValueError, TypeError):
return False
if not net_dev_checker(dev):
return False
return True


def ip_route_add_checker(ip, mask, router) -> bool:
"""Checker all args in ip route add job"""

if not valid_ip(ip):
return False

try:
_ = int(mask)
except (ValueError, TypeError):
return False

if not valid_ip(router):
return False

return True


def subinterface_vlan_checker(intf, ip, mask, vlan, intf_name) -> bool:
"""Checker for subinterface_vlan args"""

if not net_dev_checker(intf):
return False

if not valid_ip(ip):
return False

try:
_ = int(mask)
_ = int(vlan)
except (ValueError, TypeError):
return False

if not intf_name:
return False

return True


def ipip_interface_checker(ip_start, ip_end, ip_int, name_int) -> bool:
"""Checker args for ipip_interface"""

if not valid_ip(ip_start) or not valid_ip(ip_end) or not valid_ip(ip_int):
return False

if not valid_iface(name_int):
return False

return True


def add_gre_checker(ip_start, ip_end, ip_iface, name_iface) -> bool:
"""Checker args for add_gre"""

if not valid_ip(ip_start) or not valid_ip(ip_iface) or not valid_ip(ip_end):
return False

if not valid_iface(name_iface):
return False

return True


def valid_port(port) -> bool:
"""Check if given arg is port or not"""
try:
_ = int(port)
except (ValueError, TypeError):
return False

return True


def valid_ip(ip) -> bool:
"""Check if given arg is ip or not"""

try:
ipaddress.ip_address(str(ip))
return True
except ValueError:
return False


def valid_mac(mac) -> bool:
"""Check if given arg is mac or not"""
try:
EUI(mac)
except AddrFormatError:
return False

return True


def valid_iface(iface) -> bool:
"""Check if arg have only valid symbols for iface"""
if not re.match(r"^[a-z][a-z0-9_-]{0,14}$", iface):
return False
return True
from typing import Any, Callable, Optional, Tuple
from net_utils.vlan import IPSwitch, IPOVSSwitch


def ping_handler(job: Job, job_host: Any) -> None:
Expand All @@ -194,6 +17,7 @@ def ping_handler(job: Job, job_host: Any) -> None:
return

job_host.cmd(f"ping -c 1 {arg_ip}")



def ping_with_options_handler(job: Job, job_host: Any) -> None:
Expand Down Expand Up @@ -463,3 +287,35 @@ def strategy(self, job_id: int) -> None:

def handler(self) -> None:
self._strategy(self._job, self._job_host)


# VLAN helpers
def enable_arp_proxy(job: Job, job_host: Any) -> None:
"""Enable ARP proxying on an interface (VLAN subinterface or direct)."""

arg_iface = str(job.arg_1)

if "." in arg_iface:
# Already a subinterface
subinterface = arg_iface
else:
# Need to create VLAN subinterface
arg_vlan = str(job.arg_2) # VLAN ID
arg_ip = str(job.arg_3) # IP Address
arg_mask = str(job.arg_4) # Subnet Mask

subinterface = f"{arg_iface}.{arg_vlan}"


job_host.cmd(f"ip link add link {arg_iface} name {subinterface} type vlan id {arg_vlan}")
job_host.cmd(f"ip link set dev {subinterface} up")



job_host.cmd(f"sysctl -w net.ipv4.conf.{subinterface}.proxy_arp=1")

# Enable ARP proxying on the parent interface (if not already a subinterface)
if "." not in arg_iface:
job_host.cmd(f"sysctl -w net.ipv4.conf.{arg_iface}.proxy_arp=1")

print(f"ARP Proxy enabled on {subinterface}")
File renamed without changes.
35 changes: 35 additions & 0 deletions back/src/net_utils/arp_proxy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
def setup_arp_proxy_on_subinterface(node, sub_intf):


node.cmd(f"sysctl -w net.ipv4.conf.{sub_intf}.proxy_arp=1")

node.cmd("sysctl -w net.ipv4.ip_forward=1")



node.cmd(f"sysctl -w net.ipv4.conf.{sub_intf}.arp_ignore=0")
node.cmd(f"sysctl -w net.ipv4.conf.{sub_intf}.arp_announce=2")


parent_iface = sub_intf.split(".")[0]
node.cmd(f"sysctl -w net.ipv4.conf.{parent_iface}.proxy_arp=1")


node.cmd(f"ip link set {sub_intf} up")

print(f"[ARP-PROXY] Enabled on {sub_intf} (parent: {parent_iface})")

def configure_vlan_subinterface(node, vlan_id):
"""
Create a VLAN subinterface and enable ARP proxying on it.
Does not assign any IP address — purely for ARP Proxy demonstration.
"""
parent_intf = f"{node.name}-eth1"
sub_intf = f"{parent_intf}.{vlan_id}"


node.cmd(f"ip link add link {parent_intf} name {sub_intf} type vlan id {vlan_id}")
node.cmd(f"ip link set {sub_intf} up")


setup_arp_proxy_on_subinterface(node, sub_intf)
5 changes: 4 additions & 1 deletion back/src/net_utils/vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,7 @@ def add_bridge(switch: IPSwitch, interface: list[NodeInterface]) -> None:
else:
switch.cmd(f'ip link add name {f"br-{switch.name}"} type bridge')
switch.cmd(f'ip link set dev {f"br-{switch.name}"} up')
switch.cmd(f'ip link set dev {f"br-{switch.name}"} type bridge vlan_filtering 1')




11 changes: 11 additions & 0 deletions back/src/net_utils/vxlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,14 @@ def teardown_vtep_bridges(net: "IPNet", nodes: list["Node"]) -> None:
router.cmd(f"brctl delbr {bridge_name}")
router.cmd(f"ip link set {vxlan_name} down")
router.cmd(f"ip link del {vxlan_name}")

def configure_access_with_arp(switch: IPSwitch, intf: str, vlan: int) -> None:
"""Configure access VLAN and enable ARP proxying."""
switch.cmd(f'ip link set {intf} master {f"br-{switch.name}"}')
switch.cmd(f"bridge vlan del dev {intf} vid 1")
switch.cmd(f"bridge vlan add dev {intf} vid {vlan} pvid untagged")

# Enable ARP Proxy for VLAN sub-interface (if created)
sub_intf = f"{intf}.{vlan}"
switch.cmd(f"sysctl -w net.ipv4.conf.{sub_intf}.proxy_arp=1")
switch.cmd(f"sysctl -w net.ipv4.conf.{sub_intf}.forwarding=1")
27 changes: 22 additions & 5 deletions back/src/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

from net_utils.vlan import setup_vlans, clean_bridges
from net_utils.vxlan import setup_vtep_interfaces, teardown_vtep_bridges


from net_utils.arp_proxy import configure_vlan_subinterface
class MiminetNetwork(IPNet):
def __init__(self, topo: MiminetTopology, network: Network):
super().__init__(topo=topo, use_v6=False, autoSetMacs=True, allocate_IPs=False)
Expand All @@ -26,10 +25,27 @@ def start(self):
setup_vlans(self, self.__network_schema.nodes)
setup_vtep_interfaces(self, self.__network_schema.nodes)


# Enable ARP Proxy for VLAN subinterfaces dynamically
for host in self.hosts:
node_info = self.__network_schema.nodes.get(host.name, {})
vlan_id = node_info.get("vlan_id")
if vlan_id is not None:
self.create_vlan_subinterface(host, parent="eth0", vlan_id=vlan_id)
info(f"Configured VLAN {vlan_id} on host {host.name}\n")

# Waiting for network setup
time.sleep(self.__network_topology.network_configuration_time)

self.__check_files()
@staticmethod
def create_vlan_subinterface(host, parent, vlan_id):
"""Create VLAN subinterface and enable ARP proxy."""
sub_intf = f"{parent}.{vlan_id}"
host.cmd(f"ip link add link {parent} name {sub_intf} type vlan id {vlan_id}")
host.cmd(f"ip link set dev {sub_intf} up")
host.cmd(f"sysctl -w net.ipv4.conf.{sub_intf}.proxy_arp=1")
return sub_intf

def stop(self):
# Wait before stop
Expand Down Expand Up @@ -72,7 +88,7 @@ def __clean_services(self):
"""
Processes running inside virtual devices don't terminate using default mininet functions.

This function kill them manually.
This function kills them manually.
"""
info("Starting processes cleanup... ")
current_process = Process()
Expand All @@ -85,6 +101,7 @@ def __clean_services(self):
child.wait()
elif child.name() not in allowed:
# finish other processes
info(f"Killed: {child.name()} {child.pid}")
info(f"Killed: {child.name()} {child.pid}\n")
child.kill()
child.wait()


3 changes: 3 additions & 0 deletions back/tests/test_miminet_back.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def normalize_packet_data(packet_data: str) -> str:
def extract_important_fields(packets_json: str) -> list[dict[str, str]]:
"""Extracts relevant fields from emulation packets, excluding uninformative ones."""

if not packets_json.strip():
raise ValueError("Empty JSON string provided to extract_important_fields")

packets = json.loads(packets_json)
important_packets = []

Expand Down
Loading
Loading