Simple to understand [reprint] mDNS principle

Simple to understand the principles of mDNS

HTTPS: // binkery.com/archives/318.html 

found that there avahi - daemon 

mDNS 

setting ip addresses, etc. Matters 

network or part of their learning enough, need to enhance learning.

 

  • Android, Java, DNS, LAN, mDNS, multicast, Java mDNS, Multicast DNS, mDNS principle, mDNS Multicast
  • 2016-03-21 08:53:39

mDNS, multicast DNS, can be understood as an internal LAN DNS system, DNS, and it has a lot of similarities, which can be achieved within the LAN service discovery, finding and broadcasting. At the same time it is based on the multicast protocol.

mDNS: multicast DNS, specification documents address:  http://www.ietf.org/rfc/rfc6762.txt .

In the LAN, you have to be through a host and communicate with other hosts, you need to know each other's ip address, but there are times when you do not know each other's ip address, because the general LAN to use DHCP dynamically assigned ip addresses, each IP address of the host is to help you by the DHCP server to assign IP addresses. So in many cases, you have to know each other's IP address is more trouble.

In view of the recent article found that views are more in the evening there are many reprinted, in particular statement about the level of the article may not be enough, but I had some understanding, so I hope everyone with a critical perspective, then what is the problem Welcome to the discussion. Really I do not want to mislead you ^ _ ^

Works of mDNS

First, in the IP protocol provides a number of reserved addresses, one of which is 224.0.0.251, the corresponding IPv6 address is [FF02 :: FB].

mDNS protocol specifies port 5353, the port is 53 and DNS.

mDNS UDP-based protocol. DNS are generally based on UDP, but you can also use the TCP protocol.

If you understand the DNS protocol, go mDNS protocol is very simple to understand, the difference is only mDNS general role within a local area network, there is a specific IP address is 224.0.0.251, port 5353 has a specific role is to achieve mDNS services within the local area network discovery, inquiry, registration, DNS role is to achieve resolve domain names, the role is probably the same.

Each host enters the LAN, if opened mDNS service, it will be multicast to all hosts within a local area network news, who I am, and my IP address is. Then there are other hosts of the service will respond, and will tell you who it is, its IP address is. Of course, the specific implementation more complex than this.

For example, A host enters the LAN, opened mDNS service, and mDNS service registration the following information: FTP service I provide, my IP is 192.168.1.101, port 21. When the host B to enter the local area network, and a host of B mDNS service requests, I am looking LAN FTP server, mDNS B host within the LAN will go to other mDNS inquiry, and finally tell you, there is an IP address is 192.168.1.101 , host port number is 21, that is, a host provides FTP service, so you know the host B IP address and port number of the host a.

Probably principle it is like this, mDNS service offers much more than this, of course, but not multi-service complex.

On Apple devices (computer, notebook, iphone, ipad and other equipment) provides this service. Many Linux devices also offer this service. Windows devices may not be available, but if you like the iTunes software installed, also provides this service.

So you can use this service to develop some auto-discovery within the LAN, then provide some applications that interact within a local area network.

jmDNS is a JAVA platform, third-party libraries mDNS services. In this jar package into the Android project, you can get the mDNS service. Android 3.x or 4.x after the API has been provided automatic found in the LAN, so no need to use third-party libraries will be able to achieve a jmDNS.

Hereinafter from  http://www.multicastdns.org/  described.

Multicast DNS is a way of using familiar DNS programming interfaces, packet formats and operating semantics, in a small network where no conventional DNS server has been installed.

Multicast DNS is a joint effort by participants of the IETF Zero Configuration Networking (zeroconf) and DNS Extensions (dnsext) working groups. The requirements are driven by the Zeroconf working group; the implementation details are a chartered work item for the DNSEXT group. Most of the people working on mDNS are active participants of both working groups.

While the requirements for Zeroconf name resolution could be met by designing an entirely new protocol, it is better to provide this functionality by making minimal changes to the current standard DNS protocol. This saves application programmers from having to learn new APIs, and saves application programmers from having to write application code two different ways — one way for large configured networks and a different way for small Zeroconf networks. It means that most current applications need no changes at all to work correctly using mDNS in a Zeroconf network. It also means that engineers do not have to learn an entirely new protocol, and current network packet capture tools can already decode and display DNS packets, so they do not have to be updated to understand new packet formats.

- EOF -

This link  https://binkery.com/archives/318.html , welcome to reprint, please indicate the source.

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/12060249.html