LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How to write a Program to get the address of a device by ARP? (https://www.linuxquestions.org/questions/programming-9/how-to-write-a-program-to-get-the-address-of-a-device-by-arp-4175415173/)

pradiptart 07-06-2012 12:34 AM

How to write a Program to get the address of a device by ARP?
 
Hi,
hello,I have to write a program to get a simple details of a mobile device(cell phone).

That moblile device is having an IP in it by a wi-fi connection with it.The major thing is that i pinged that IP and I am getting connection packets getting back to my pc,means I can communicate with the devices. so can I able to get the details of the device.

details means
1.its name what user sets on it.
2.some address like mac in computers.
3.model name.
4.type of os in it.
etc

I really find this interesting but,no idea how to do but i got something like ARP protocol for getting the mac address but I do not know how to communicate with a phone with this ARP protocol.

can any one have some idea ,kindly tell me,it is very important for my project.

Thanks

unSpawn 07-06-2012 03:16 PM

Quote:

Originally Posted by pradiptart (Post 4720529)
I am getting connection packets getting back to my pc,means I can communicate with the devices. so can I able to get the details of the device.
details means
1.its name what user sets on it.
2.some address like mac in computers.
3.model name.
4.type of os in it.
etc

(..) I do not know how to communicate with a phone with this ARP protocol.

MAC-to-IP mappings are a question of eliciting ARP "WHO-HAS" replies, the OS could be done with any active scanner like Nmap (probably crudely and not if nobody donated signatures) or a passive scanner like p0f (requires sigs plus connection, probably even less feasible) but unless a phone provides an interface to query it (I mean like this) you AFAIK won't be able to get user-set name or model over IP.

theNbomr 07-06-2012 07:12 PM

I think what unSpawn is trying to say is that just because a device has an IP, it doesn't mean the device is going to provide all the information you want. Unless you know of a certain protocol that does provide what you want, or if the phone has an installed app that does that, I think you'll be out of luck. ARP is always available on IP networks, because at the lowest level, all traffic travels as network datagrams, and the destination address is (normally) expressed in terms of the MAC. On most hosts, ARP data is cached for a short time, and Linux allows you to look at the cache with the command 'arp' (probably in /usr/sbin).

--- rod.

pradiptart 07-07-2012 05:37 AM

Hi unSpawn and theNbomr,

Yes, I understand this,but I want to communicate to it by a program first,like ping .

I got something like arping one command is there where we can ping to a device which gives you a mac address,means it is getting the mac address of the device with in a network or a WLAN ,so is it a good idea to write a arping program to get the MAC address of the mobile.

Just give a right direction,or is there any other way to do so.

I am trying upon an android phone so can is there any method to create an application which talk with the phone from pc,means can we create a client application which will always sending some information from a mobile and our pc having a server application which will listen to it and get the data.

Thanks

theNbomr 07-07-2012 05:26 PM

To get the MAC, make a shell script that pings the host, and then immediately dumps the arp cache. Use grep to locate the desired entry.

If you are able to write applications for Android, it shouldn't be too difficult to write the client/server aspects. I don't know what, if any, API Android might provide for determining host-specific information. You could probably make the Android app an HTTP server, and use any web browser as a client.

--- rod.


All times are GMT -5. The time now is 09:52 AM.