Each service provisioning device advertises available services to an mDNS gateway, so the mDNS gateway can record information about all available services. A host name identifies a service provisioning device; a service name identifies a service provided by service provisioning device and records the service type. For example, the service name Officejet Pro 8100 [C12FFA] (7)._printer._tcp.local indicates that the service provisioning device can provide the printing service. Each service provisioning device can provide various services. Figure 1 shows how a service provisioning device, for example, an Apple TV, advertises services to the mDNS gateway.
After the Apple TV is powered on, it generates a host name and sends an mDNS request packet with the destination multicast address of 224.0.0.251 to check whether the host name is unique. After receiving the mDNS request packet, the mDNS gateway queries its recorded host name lists. If the host name already exists, it is used by another service provisioning device. The mDNS gateway then sends a response packet to the Apple TV indicating the host name conflict. After receiving the response packet, the Apple TV regenerates a new host name and sends an mDNS request packet again to check whether the host name is unique. If the Apple TV does not receive the response packet from the mDNS gateway within the detection period, the host name is available. If the host name conflict persists within the detection period, the Apple TV continues to send an mDNS request packet in the next detection period.
The Apple TV multicasts an mDNS request packet to advertise its host name and IP address. After receiving the mDNS request packet, the mDNS gateway records the host name and IP address of the Apple TV.
The Apple TV sends an mDNS request packet with the destination multicast address of 224.0.0.251 to check whether the service name is unique. After receiving the mDNS request packet, the mDNS gateway queries its recorded service lists. If the service name already exists, it is used by another service provisioning device. The mDNS gateway then sends a response packet indicating the service name conflict. After receiving the response packet, the Apple TV regenerates a new service name and sends an mDNS request packet again to check whether the service name is unique. If the Apple TV does not receive the response packet from the mDNS gateway within the detection period, the service name is available. If the host name conflict persists within the detection period, the Apple TV continues to send an mDNS request packet in the next detection period.
The Apple TV multicasts an mDNS request packet to advertise its service information. After receiving the mDNS request packet, the mDNS gateway records the service information, including the service name, service type, TTL, host name, and IP address.
The TTL is provided by a service provisioning device to the mDNS gateway. The TTL in a service list recorded on the mDNS gateway indicates the aging time of a service. If the mDNS gateway receives mDNS response packets from a service provisioning device within the aging time, the mDNS gateway updates its service information. If the mDNS gateway does not receive mDNS response packets from a service provisioning device within the aging time, the mDNS gateway deletes its service information.
Figure 2 shows how a user terminal, for example, an iPhone, discovers services.
iPhone multicasts an mDNS request packet to query required services.
After receiving the mDNS request packet, the mDNS gateway searches its service lists and sends the host name and IP address of the device that can provide the required service to the iPhone. The iPhone can establish a connection with the service provisioning device.
When the device functions as an mDNS gateway, it can only send response packets in multicast mode. When the device sends request packets and detection packets, it also requests the remote end to send response packets in multicast mode.
The mDNS gateway supports the periodical service discovery function and periodically multicasts an mDNS request packet to detect services. After receiving the mDNS request packet, the service provisioning devices send response packets of service information. The mDNS gateway updates its service lists after receiving the response packets. With the periodic service discovery function, service provisioning devices can immediately advertise service information to the mDNS gateway, and the mDNS gateway can maintain integrity of its service lists in a timely manner.
After a client accesses the network, it can detect all service provisioning devices connected to the mDNS gateway. The clients and service provisioning devices cannot be precisely matched. For example, when a smartphone is connected to the network through an AP, the smartphone identifies both the Apple TV connected to the AP and the Apple TVs associated with other APs. It is not easy for the smartphone to distinguish between these Apple TVs, and security risks exist. The mDNS gateway provides the policy control function, which enables clients to precisely discover mDNS service provisioning devices based on preconfigured policies. Such a policy is implemented based on AP locations. Therefore, this function is applicable only to clients that access a network in wireless mode. When a client moves to another location, the location information changes accordingly. Location information types include the AP name, AP group, AP location, and AP neighbor. AP names, AP groups, and AP locations are specified when APs are deployed on the network. AP neighbors are discovered by APs. There are two types of control policies:
Control policies based on service types and AP locations
A policy of this type is configured on the mDNS gateway based on the service type and AP location. A client can discover a specific service configured in a policy only when location information of the AP associated with the client and service provisioning device matches the policy.
For example, on the preceding network, AP1 and AP2 belong to group 1, and AP3 belongs to group 2. Apple TV_1 and Apple TV_2 are associated with AP1 and AP3 respectively. iPhone1, iPhone2, and iPhone3 are associated with AP1, AP2, and AP3, respectively. A control policy based on the service type _airplay._tcp.local and location type AP Group is configured, so that STAs and service provisioning devices belonging to the same AP group can discover each other. In this example, iPhone1 and iPhone2 can discover only Apple TV_1, and iPhone3 can discover only Apple TV_2 in the same AP group.
Control policies based on service provisioning devices and AP locations
A policy of this type is configured on the mDNS gateway based on the MAC addresses of service provisioning devices and AP locations. A client can discover services only when location information about the client and service provisioning device matches a control policy.
For example, on the preceding network, AP1 and AP2 are located at 5F-1. A control policy can be configured to allow only clients with location information being 5F-1 (iPhone1 and iPhone2) to discover Apple TV_1 with MAC address 0001-0001-0001. iPhone3 with location information being 3F-1 cannot discover Apple TV_1.