multicast-trace-receiver.rb 781 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/ruby
  2. #
  3. # This can be used with the debug build option ZT_TRACE_MULTICAST to trace
  4. # a multicast cascade.
  5. #
  6. # Define ZT_TRACE_MULTICAST to the IP/port where this script will be listening.
  7. # The default port here is 6060, so an example would be to add:
  8. #
  9. # -DZT_TRACE_MULTICAST=\"10.0.0.1/6060\"
  10. #
  11. # ... to DEFS in the Makefile. Then build and run ZeroTier One on a testnet and
  12. # the box defined as the trace endpoint will get spammed with UDP packets
  13. # containing trace information for multicast propagation. This script then dumps
  14. # these trace packets to stdout. Look at the code in PacketDecoder.cpp to see
  15. # what this information entails.
  16. #
  17. require 'socket'
  18. s = UDPSocket.new
  19. s.bind('0.0.0.0',6060)
  20. loop {
  21. m = s.recvfrom(4096)[0].chomp
  22. puts m if m.length > 0
  23. }