MAC Address is a Unique identification of a Device. Computer, Mobile, Tablet, PC all have a Unique MAC Address. If you want to know about MAC Address here is some, MAC on Wiki. MAC Address is generally 48 bits long eg, 00:ff:a3:f0:76:ae
Here we are going to discuss about How to get that address by using supplied IP Address over the network.
Here is the Java Code
GetMACAddress.java
import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.Arrays;
import jpcap.*;
import jpcap.packet.*;
public class GetMACAddress{
public static byte[] arp(InetAddress ip) throws java.io.IOException{
//find network interface
NetworkInterface[] devices=JpcapCaptor.getDeviceList();
NetworkInterface device=null;
loop: for(NetworkInterface d:devices){
for(NetworkInterfaceAddress addr:d.addresses){
if(!(addr.address instanceof Inet4Address)) continue;
byte[] bip=ip.getAddress();
byte[] subnet=addr.subnet.getAddress();
…
Here we are going to discuss about How to get that address by using supplied IP Address over the network.
Here is the Java Code
GetMACAddress.java
import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.Arrays;
import jpcap.*;
import jpcap.packet.*;
public class GetMACAddress{
public static byte[] arp(InetAddress ip) throws java.io.IOException{
//find network interface
NetworkInterface[] devices=JpcapCaptor.getDeviceList();
NetworkInterface device=null;
loop: for(NetworkInterface d:devices){
for(NetworkInterfaceAddress addr:d.addresses){
if(!(addr.address instanceof Inet4Address)) continue;
byte[] bip=ip.getAddress();
byte[] subnet=addr.subnet.getAddress();
…