Apple's Finder.app is able to consistently determine the exact model of each physical computer that uses bonjour (as evidenced by the icons being unique for each individual device type: iMac, MacPro, MBP, etc). How do they do this and what APIs do they use?
On a side note, Bonjour provides Name, Service Type, Domain and Port for all services on the network - but I haven't been able to find information on how to find the device model itself.
Bonjour, also known as zero-configuration networking, enables automatic discovery of devices and services on a local network using industry standard IP protocols.
Bonjour uses multicast DNS (mDNS) and link-local addressing to allow systems to assign and recognize IP addresses without automated dynamic host configuration protocols (DHCP). It can work with both IPv6 and IPv4 addressing and uses the native local-link addressing support on Windows.
I believe this uses the _device-info._tcp. mDNS record for the IP address. You can see this for yourself. In the terminal, you can use dig @224.0.0.251 -p5353
to perform mDNS requests. You can use dig @224.0.0.251 -p5353 Foo.local.
to resolve the IP address of the computer Foo.local. Take that IP and plug it back into dig @224.0.0.251 -p5353 -x $IP
and you should see something like the following:
> dig @224.0.0.251 -p5353 -x 10.0.1.1
; <<>> DiG 9.6.0-APPLE-P2 <<>> @224.0.0.251 -p5353 -x 10.0.1.1
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22887
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; QUESTION SECTION:
;1.0.0.10.in-addr.arpa. IN PTR
;; ANSWER SECTION:
1.0.0.10.in-addr.arpa. 10 IN PTR Foo.local.
;; ADDITIONAL SECTION:
Foo._device-info._tcp.local. 10 IN TXT "model=MacBookPro5,3"
;; Query time: 4 msec
;; SERVER: 10.0.0.1#5353(224.0.0.251)
;; WHEN: Mon Nov 29 18:00:23 2010
;; MSG SIZE rcvd: 131
Notice the ADDITIONAL SECTION.
Unfortunately, I don't know how to get at this information using the Bonjour APIs.
Edit: You can also get this info in a single query with dig @224.0.0.251 -p5353 Foo._device-info._tcp.local. TXT
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With