Ping is simple. When you type /ctcp <nick> ping, you actually send:
PRIVMSG nick :PING 1046714259
Where equals to $chr(1), which identifies CTCP and /me messages, and 104671425 is the local $ctime value.
When the destination nick receives the Ping, it can decide whether to reply or ignore. In case it replies, it simply sends back the same message but by notice, instead of a privmsg.
Rule: ctcp request = privmsg; ctcp reply = notice.
NOTICE yournick :PING 1046714259
Now that you receive the reply, you'll have to substract the numeric parameter from the current $ctime, so that you can know how many seconds left since it was sent.
For more info check
this page. As for highscan, sorry no idea.