ArpScanner
MAC-to-IP resolution + L2 IP-occupancy probe via Win32 SendARP P/Invoke. Used for Hyper-V VM IP discovery and flash-mikrotik MAC→IP resolution.
public static class ArpScanner
1. Methods
1.1. FindIPByMAC(string, string)
Scan UP IPv4 NIC subnets and return the IP that responds to ARP with the given MAC.
public static string FindIPByMAC(string targetMAC, string switchAdapterNamePattern = null)
| Name | Type | Description |
|---|---|---|
targetMAC |
string |
MAC in any common format (XX:XX:XX:XX:XX:XX or XX-XX-XX-XX-XX-XX). |
switchAdapterNamePattern |
string |
Optional NIC name/description filter. |
Returns: string
1.2. FormatMAC(byte[])
6-byte MAC → "XX:XX:XX:XX:XX:XX" uppercase.
public static string FormatMAC(byte[] macBytes)
| Name | Type | Description |
|---|---|---|
macBytes |
byte[] |
Returns: string
1.3. IsIpOccupied(string)
Robust L2 occupancy probe for ip. Uses SendARP (ignores ICMP-blocking firewalls) with a ping fallback. Retries 3x with 150 ms spacing.
public static bool IsIpOccupied(string ip)
| Name | Type | Description |
|---|---|---|
ip |
string |
Returns: bool
1.4. NormalizeMAC(string)
Any-format MAC → "XX:XX:XX:XX:XX:XX" uppercase.
public static string NormalizeMAC(string mac)
| Name | Type | Description |
|---|---|---|
mac |
string |
Returns: string