From f3645b9081ee1beb30a150084298049d3f241ac9 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sat, 28 May 2016 10:32:03 -0400 Subject: [PATCH] Better choice of example UDP multicast group address. --- racket/syndicate/examples/udp-multicast.rkt | 23 ++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/racket/syndicate/examples/udp-multicast.rkt b/racket/syndicate/examples/udp-multicast.rkt index 4a18002..cc25e69 100644 --- a/racket/syndicate/examples/udp-multicast.rkt +++ b/racket/syndicate/examples/udp-multicast.rkt @@ -8,20 +8,37 @@ (spawn-timer-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))) - (define h (udp-listener 5999)) + (define h (udp-listener group-port)) (define (rearm!) (send! (set-timer h 1000 'relative))) (rearm!) (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)) (on (message (udp-packet $source h $body)) (printf "~a: ~a\n" source body)) (on (message (timer-expired h $now)) (rearm!) (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)))))))