# 6.2.2.3.1 ISTG Selection

First, the KCC on a writable DC determines whether it acts as an ISTG for its site.

Let

*s*be the object such that*s*!lDAPDisplayName = nTDSDSA and classSchema in*s*!objectClass.Let

*D*be the sequence of objects*o*in the site of the local DC such that*o*!objectCategory =*s*.*D*is sorted in ascending order by objectGUID.Let

*o*be the site settings object for the site of the local DC, or NULL if no such*o*exists.Let

*f*be the duration*o*!interSiteTopologyFailover seconds, or 2 hours if*o*!interSiteTopologyFailover is 0 or has no value.If

*o*≠ NULL and*o*!interSiteTopologyGenerator is not the nTDSDSA object for the local DC and*o*!interSiteTopologyGenerator is an element*d*_{j}of sequence*D*:Let

*c*be the cursor in the*pUpToDateVector*variable associated with the NC replica of the config NC such that*c.uuidDsa = d*_{j}!invocationId. If no such*c*exists*(No evidence of replication from current ITSG):*Let

*i*=*j*.Let

*t*= 0.

Else if the current time <

*c.timeLastSyncSuccess - f*(*Evidence of time sync problem on current ISTG*):Let

*i*= 0.Let

*t*= 0.

Else (

*Evidence of replication from current ITSG)*:Let

*i*=*j*.Let

*t*=*c.timeLastSyncSuccess*.

Otherwise (

*Nominate local DC as ISTG*):Let

*i*be the integer such that*d*_{i}is the nTDSDSA object for the local DC.Let

*t*= the current time.

(

*Compute a function that maintains the current ISTG if it is alive, cycles through other candidates if not*.) Let*k*be the integer (*i*+ ((current time -*t*) /*o*!interSiteTopologyFailover)) MOD |*D*|.The local writable DC acts as an ISTG for its site if and only if

*d*_{k}is the nTDSDSA object for the local DC. If the local DC does not act as an ISTG, the KCC skips the remainder of this task.

If the local DC does act as an ISTG and *o* exists but *o*!interSiteTopologyGenerator
is not the dsname of the local
DC's nTDSDSA object, the KCC performs an originating update
to set *o*!interSiteTopologyGenerator to this value.

The KCC on an RODC always acts as an ISTG for itself.