Guest User

Untitled

a guest
Apr 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. /* NTPQ REXX Get raw time from NTPD (RFC-5905) */
  2. /* Author: Rob van der Heij, 25 Apr 2014 */
  3.  
  4. arg stack . /* The TCPIP stack to use */
  5. parse value stack 'TCPIP' with stack .
  6.  
  7. 'callpipe (end \ name NTPQ.REXX:7)', /* Use TOD as unsigned 64-bit */
  8. '\ literal :tod u64 u 1.8',
  9. '| literal :tod4 t1 u 1.8 t2 u 9.8 t3 u 17.8 t4 u 25.8',
  10. '| literal :time secs u 1.4 frac u 5.4',
  11. '| structure add'
  12.  
  13. 'callpipe (end \ name NTPQ.REXX:7)',
  14. '\ *:', /* NTPD server address */
  15. '| p: fanout',
  16. '| copy',
  17. '| pad 16',
  18. '| x: spec 1-* 1 select 1 1-* n',
  19. '| *:',
  20. '\ p:',
  21. '| spec ,AF_INET 123, 1 w1 nw ', /* UDP port 123 */
  22. '| ip2socka ', /* Build socket descriptor */
  23. '| spec pad 00 x05 4 1-* 9',
  24. 'xe30006ec 25 x494e4954 37', /* INIT */
  25. 'tod 65',
  26. '| spec 1-* 1 qual tod 65',
  27. 'print ((u64%4096)%1000000) u2c 65.4', /* Seconds */
  28. 'print (((u64%4096)//1000000)*4294.967296%1)',
  29. 'u2c 69.4', /* Fraction */
  30. '| udp 0' stack,
  31. '| z: locate', /* Discard null timeout */
  32. '| spec 41.24 1',
  33. '| fblock 8',
  34. '| spec qual time print d2c((secs+frac/4294967296)*4096e6%1) 1',
  35. '| join 2', /* Keep 3 TOD clocks */
  36. '| spec 1-* 1 tod n', /* Plus our own clock */
  37. '| o: fanout',
  38. '| copy',
  39. '| spec 17.8 c2t(*) 2.23', /* NTP transmit time */
  40. '| s: gather | join',
  41. '| i: faninany',
  42. '| x:',
  43. '\ o:',
  44. '| spec qual tod4',
  45. ', Off:, 1',
  46. 'print (t2-t1+t3-t4)/8192e6 pic ---9.999 nw ,s, nw',
  47. ',RTT:, nw print (t4-t1)/8192e3 pic zzz9.9 nw ,ms, nw',
  48. '| s:',
  49. '\ z: | spec ,-, | i:',
  50.  
  51. return
Add Comment
Please, Sign In to add comment