Better choice of example UDP multicast group address.
This commit is contained in:
parent
f6ed330a0d
commit
f3645b9081
|
@ -8,20 +8,37 @@
|
||||||
(spawn-timer-driver)
|
(spawn-timer-driver)
|
||||||
(spawn-udp-driver)
|
(spawn-udp-driver)
|
||||||
|
|
||||||
|
;; IANA offers guidelines for choosing multicast addresses [1].
|
||||||
|
;;
|
||||||
|
;; Reasonable candidates for local experimentation include:
|
||||||
|
;; - 224.0.1.20, "any private experiment"
|
||||||
|
;; - 233.252.0.0 - 233.252.0.255, "MCAST-TEST-NET", for examples and documentation (only)
|
||||||
|
;;
|
||||||
|
;; For production and semi-production use, registering an address may
|
||||||
|
;; be an option; failing that, the Administratively Scoped Block
|
||||||
|
;; (239/8; see RFC 2365) may be used:
|
||||||
|
;; - 239.255.0.0 - 239.255.255.255, "IPv4 Local Scope"
|
||||||
|
;; - 239.192.0.0 - 239.195.255.255, "Organization Local Scope"
|
||||||
|
;;
|
||||||
|
;; [1] http://www.iana.org/assignments/multicast-addresses/
|
||||||
|
|
||||||
|
(define group-address "233.252.0.101") ;; falls within MCAST-TEST-NET
|
||||||
|
(define group-port 5999) ;; make sure your firewall is open to UDP on this port
|
||||||
|
|
||||||
(actor (define me (bytes->hex-string (crypto-random-bytes 8)))
|
(actor (define me (bytes->hex-string (crypto-random-bytes 8)))
|
||||||
(define h (udp-listener 5999))
|
(define h (udp-listener group-port))
|
||||||
|
|
||||||
(define (rearm!) (send! (set-timer h 1000 'relative)))
|
(define (rearm!) (send! (set-timer h 1000 'relative)))
|
||||||
|
|
||||||
(rearm!)
|
(rearm!)
|
||||||
|
|
||||||
(forever
|
(forever
|
||||||
(assert (udp-multicast-group-member h "224.0.0.251" #f))
|
(assert (udp-multicast-group-member h group-address #f))
|
||||||
(assert (udp-multicast-loopback h #t))
|
(assert (udp-multicast-loopback h #t))
|
||||||
(on (message (udp-packet $source h $body))
|
(on (message (udp-packet $source h $body))
|
||||||
(printf "~a: ~a\n" source body))
|
(printf "~a: ~a\n" source body))
|
||||||
(on (message (timer-expired h $now))
|
(on (message (timer-expired h $now))
|
||||||
(rearm!)
|
(rearm!)
|
||||||
(send! (udp-packet h
|
(send! (udp-packet h
|
||||||
(udp-remote-address "224.0.0.251" 5999)
|
(udp-remote-address group-address group-port)
|
||||||
(string->bytes/utf-8 (format "~a ~a" me now)))))))
|
(string->bytes/utf-8 (format "~a ~a" me now)))))))
|
||||||
|
|
Loading…
Reference in New Issue