midol
Posts: 14
Joined: Wed Feb 05, 2014 6:38 pm

mirror packets to two IP addresses?

Tue Sep 05, 2017 12:50 am

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

SurferTim
Posts: 1769
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: mirror packets to two IP addresses?

Tue Sep 05, 2017 2:17 am

I don't know about the protocol you want, but you can use UDP packets sent to the localnet broadcast address.


User avatar
karrika
Posts: 1124
Joined: Mon Oct 19, 2015 6:21 am
Location: Finland

Re: mirror packets to two IP addresses?

Tue Sep 05, 2017 10:47 am

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()

midol
Posts: 14
Joined: Wed Feb 05, 2014 6:38 pm

Re: mirror packets to two IP addresses?

Wed Sep 06, 2017 1:24 am

That looks good, karrika, I'll make a note and try it. Thanks very much!

d

Return to “Advanced users”