An SRP Replication Peer MUST maintain an ongoing DNS-SD browse on the service name '_srpl-tls._tcp' within the local browsing domain. The ongoing browse will produce two different types of events: "add" events and "remove" events. When the browse is started, it should produce an 'add' event for every SRP replication partner currently present on the network, including the peer that is doing the browsing. Whenever a partner goes offline, a 'remove' event should be produced. 'remove' events are not guaranteed, however.¶
When a new service is added, the SRP peer checks to see if it is in a compatible domain. If the SRP peer has a domain to advertise, it compares that domain to the domain advertised in the added service instance: if they are not the same, then this instance is not a candidate for connection, and should be ignored.¶
If the SRP peer does not have a domain to advertise, then when it begins to browse for partners, it sets a timer for DOMAIN_DISCOVERY_TIMEOUT seconds.¶
If the SRP peer does not have a domain to advertise, and is therefore willing to join an existing domain, it checks to see if the TXT record for the service indicates that joining is permitted. If so, the SRP peer adopts the provided domain name. Once it has adopted such a domain name, it updates its own TXT record to indicate that domain name, and sets the 'join=yes' key/value pair in the TXT record. It also cancels the DOMAIN_DISCOVERY_TIMEOUT timer.¶
If the DOMAIN_DISCOVERY_TIMEOUT timer goes off, then the SRP peer MUST propose a zone name using one of the methods mentioned previously. It advertises that zone name in its TXT record, with 'join=yes'. It then sets a new timer for DOMAIN_PROPOSE_TIMEOUT seconds.¶
While waiting for the DOMAIN_PROPOSE_TIMEOUT timer to go off, any new 'add' events that arrive are examined to see if they are potential domains to join. If a potential domain to join is seen, and it is the same as the proposed domain, then the peer adopts that domain and treats it as its domain to advertise. It then cancels the DOMAIN_DISCOVERY_TIMEOUT timer.¶
When the DOMAIN_DISCOVERY_TIMEOUT timer expires, the peer initializes the domain to be advertised using the one that it chose, and the chosen server-id to be its own. It then iterates across the list of 'add' events that have been seen. Each advertisement is examined, comparing its server-id to the chosen server-id. If the chosen server-id is numerically greater than the server-id in the advertisement, then the domain to be advertised and the chosen server-id are updated from the advertisement. At the end of this process, the peer adopts whatever domain is now set as the domain to be advertised.¶
Once a domain has been chosen, a list of partners in that domain can be generated from the list of add events previously seen. When a new add event is seen that advertises the peer's domain to be advertised, that partner is added to the list of partners, if not already present. When a remove event is seen, if that partner is on the list of partners, a timer is set for DOMAIN_INSTANCE_TIMEOUT seconds.¶
When the timer for DOMAIN_INSTANCE_TIMEOUT timer expires, if the partner that was removed has not been re-added, it is removed from the list of partners and any connection to it is dropped.¶