Page 1 of 1

mirror packets to two IP addresses?

Posted: Tue Sep 05, 2017 12:50 am
by midol
I want to connect a sensor by wifi to a pi zero w. I'd like all incoming sensor packets (which is all the traffic there will be) to be sent to two outbound IP addresses. Can anyone point me to a howto?

Thanks!

Dave

Re: mirror packets to two IP addresses?

Posted: Tue Sep 05, 2017 2:17 am
by SurferTim
I don't know about the protocol you want, but you can use UDP packets sent to the localnet broadcast address.

Re: mirror packets to two IP addresses?

Posted: Tue Sep 05, 2017 8:54 am
by drgeoff

Re: mirror packets to two IP addresses?

Posted: Tue Sep 05, 2017 10:47 am
by karrika
And the final suggestion is unicast, twice.

All these methods has their pro's and con's.

Broadcasts will not penetrate routers. You can only send to computers on the same local network.

Multicasts require IGMP subscriptions from the receivers. It very often takes up to a minute before the routers on the path react to the igmp subscription. If you send a multicast on a local network with just switches it becomes a broadcast and no igmp subscription is required.

Unicast is the easiest one and it works always. Just send the data twice.

Code: Select all

from socket import socket

sock = socket()
sock.connect(('1.2.3.4', 1234))
sock.send('Hello world!\n')
sock.close()

Re: mirror packets to two IP addresses?

Posted: Wed Sep 06, 2017 1:24 am
by midol
That looks good, karrika, I'll make a note and try it. Thanks very much!

d