osociety / network_tools

Networking Tools library which can help you discover open ports, devices on subnet and many other things.
https://pub.dev/packages/network_tools
BSD 3-Clause "New" or "Revised" License
45 stars 13 forks source link

Support for getting Mac Address of host with ip #7

Closed guyluz11 closed 1 year ago

guyluz11 commented 2 years ago

Getting Mac Address is very popular.

Will be nice to have.

guyluz11 commented 2 years ago

Not sure if a dart package exist for that.

I have found from small research that this can be done using ARP (Address Resolution Protocol).

git-elliot commented 2 years ago

Programmatically we can't get the mac address of devices above ios 7 and android 6. Source

get_mac package is there in pub.dev website but only supports Android and iOS, which is used to get mac_address of the device itself.

I also want to refer the issue from dart-sdk.

guyluz11 commented 2 years ago

Interesting findings.

As the MAC address that we are searching are mainly of other devices in the local network I think the last link is more relevant to us. It have closed-not-planned label so let's not count on it. Let's just keep it with the platform limitation label that you have added :( and work in the meantime on the rest of the issues.

guyluz11 commented 2 years ago

Found a flutter android only package arp_scanner, it comes with its limitations. (not sure if also above or below)

Support only for Android Sdk Version 29 and above or below.

For Linux dart native as well as Linux Flutter I think we can execute terminal commands like arp -a, ip neigh.

I think For Mac dart native and Mac Flutter we can execute the command arp -a

For Windows dart native as well as Windows Flutter I think we can also execute the command arp -a.

I don't have a solution for ios but we can keep it for later.

I am saving this stack overflow issue here to post an answer if we solve it for that guy.

guyluz11 commented 2 years ago

There are two ways to get an arp table.

  1. arp table stored on the device that is currently running,
  2. arp table that is stored on the router.

The first option looks like it has a few problems but can be possible on some of the platforms.

If I understand correctly from the question here it sounds like to get the arp table from the router we can use snmp (Simple Network Management Protocol).

I have found 2 dart packages for snmp dart_snmp, snmp.

So it seems that there is another path that we can take to add support for it.

git-elliot commented 1 year ago

Added mac address support for Desktop. Please open another issue to track specific platform limitations and possibilities