public static String referenceIdentifierToString ( byte [ ] ref , short stratum , byte version ) { // From the RFC 2030: // In the case of NTP Version 3 or Version 4 stratum-0 (unspecified) // or stratum-1 (primary) servers, this is a four-character ASCII // string, left justified and zero padded to 32 bits. if ( stratum == 0 || stratum == 1 ) { return new String ( ref ) ; } // In NTP Version 3 secondary servers, this is the 32-bit IPv4 // address of the reference source. else if ( version == 3 ) { return unsignedByteToShort ( ref [ 0 ] ) + "." + unsignedByteToShort ( ref [ 1 ] ) + "." + unsignedByteToShort ( ref [ 2 ] ) + "." + unsignedByteToShort ( ref [ 3 ] ) ; } // In NTP Version 4 secondary servers, this is the low order 32 bits // of the latest transmit timestamp of the reference source. else if ( version == 4 ) { return "" + ( ( unsignedByteToShort ( ref [ 0 ] ) / 256.0 ) + ( unsignedByteToShort ( ref [ 1 ] ) / 65536.0 ) + ( unsignedByteToShort ( ref [ 2 ] ) / 16777216.0 ) + ( unsignedByteToShort ( ref [ 3 ] ) / 4294967296.0 ) ) ; } return "" ; }
Returns a string representation of a reference identifier according to the rules set out in RFC 2030 .