[Openmcl-devel] Blocking problem with UDP broadcast on a LAN with macOSX

barthes barthes at utc.fr
Mon Feb 1 01:14:18 PST 2021


Hi

I have several machines on a LAN 192.168.1.0/24 (some of them unknown) and need to send 
broadcast messages to all of them. I encounter a problem with UDP broadcast. I have been 
running a number of tests and always end up with the same problem, although UDP 
point-to-point works well. 

The following example is one of the simplest tests I ran: A and B are 2 machines on the 
loop.

A: CCL 1.11.6 DarwinX8664 on macOS Sierra 10.12.6, sending UDP messages

A.1. P2P

(defparameter *s* (make-socket :type :datagram 
                               :remote-host "192.168.1.14"
                               :remote-port 35005))

(let* ((text (format nil "UDP Test Message"))
       (buf (encode-string-to-octets text))
       )
  (send-to *s* buf (length buf) :remote-host "192.168.1.14")
  )


A.2. Broadcast

(defparameter *ss* 
  (make-socket :type :datagram :broadcast t
               :remote-host "192.168.1.255" :remote-port 35005))

(let* ((text (format nil "UDP Test Broadcast Message"))
       (buf (encode-string-to-octets text))
       )
  (send-to *ss* buf (length buf))
  )


B: CCL 1.11.8 DarwinX8664 on macOS Mojave 10.14.6 receiving

(defparameter *s* (make-socket :type :datagram {:broadcast t} ; tried with and without
                               :local-host "192.168.1.14" :local-port 35005))
(defun s-receive ()
 (let (buf)
   (loop
     (print "Ready")
     (setq buf (receive-from *s* 1000 :extract t))
     (print buf))
   ))

(setq proc (process-run-function "UDP test" #'s-receive))


Results
=======
Test A1 (P2P) works like a breeze, B prints the content of the buffer.

Test A2 (Broadcast): the messages is sent by A and appears on the LAN (as checked with 
tcpdump from the terminal) but does not reach the B Lisp environment. Nothing is printed 
and B keeps waiting.

tcpdump on B shows that the message is received...
> sudo tcpdump udp port 35005
10:02:00.244874 IP notebook.home.54899 > 192.168.1.255.35005: UDP, length 26

None of the machine has a firewall up. Both machines were rebooted before each test.

I am probably missing something trivial (in that case sorry for wasting your time), 
but I ran out of ideas. Could anyone tell me what I am doing wrong?

Thank you.
J-Paul




More information about the Openmcl-devel mailing list