Reputation: 547
I'm fairly new to python programming and linux / raspian in general and I've had an absolute a**e of a problem for the last couple of weeks. I've been trying to persevere but after the last couple of nights until 1 in the morning trying to get it to work I thought it was time to ask for help.
So I have a raspberry pi that I have set up to receive data from an owl intuition (an electricity and pv monitor) that sends out data via multicast on 224.192.32.19 and port 22600.
I'm using iptables and fail2ban but I have a rule set up to allow all multicast traffic and the source ip address isn't on the fail2ban list.
The iptables rule is as follows:
target prot opt in out source destination
ACCEPT all -- any any anywhere anywhere PKTTYPE = multicast
I'm using some really basic python scripts to try to receive the datagrams but to no avail.
I've tried those same scripts to try to receive datagrams from 239.255.255.250 : 1900 and it works fine.
I've also tried "mcsend 224.192.32.19 22600" on a windows machine which can receive the data using "rtpqual 224.192.32.19 22600" but the raspi still can't.
EDIT: Turns out I'd left a script running in a console window at work. None the less, it didn't receive anything.
IPv6/IPv4 Group Memberships
Interface RefCnt Group
lo 1 all-systems.mcast.net
eth0 1 224.192.32.19
eth0 1 all-systems.mcast.net
Also if I run "ifconfig eth0", I get:
eth0 Link encap:Ethernet HWaddr b8:27:eb:4c:46:71
inet addr:192.168.0.20 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:27645 errors:0 dropped:0 overruns:0 frame:0
TX packets:11846 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1701082 (1.6 MiB) TX bytes:2027974 (1.9 MiB)
so I think I can safely assume that multicast is supported / enabled on the pi.
The py script is as follows (default ip address / port doesn't work, the ip address / port in the 'help' does work):
from socket import socket, inet_aton, IPPROTO_IP, IP_ADD_MEMBERSHIP
from socket import AF_INET, SOCK_DGRAM, SOL_SOCKET, SO_REUSEADDR, INADDR_ANY
from optparse import OptionParser
import struct
parser = OptionParser()
parser.add_option("-g", "--group", dest="group", default="224.192.32.19", help="IP Multicast Group (default: 239.255.255.250)")
parser.add_option("-p", "--port", dest="port", default=22600, help="IP Multicast UDP port number (default: 1900)")
parser.add_option("-b", "--buffer", dest="buffer", default=1500, help="IP Socket buffer size (default: 1500 bytes)")
options, args = parser.parse_args()
MCAST_GRP = options.group
MCAST_PORT = options.port
BUFFER_SIZE = options.buffer
sock = socket(AF_INET, SOCK_DGRAM)
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
mreq = struct.pack('=4sl', inet_aton(MCAST_GRP), INADDR_ANY) # pack MCAST_GRP correctly
sock.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq) # Request MCAST_GRP
sock.bind((MCAST_GRP, MCAST_PORT)) # Bind to all intfs
while True:
data, srv_sock = sock.recvfrom(BUFFER_SIZE) # Receive data (blocking)
srv_addr, srv_srcport = srv_sock[0], srv_sock[1]
print "%s sent: %s" % (srv_addr, data)
I can't work out whether the issue is with
Thanks for any help on this one, it's really doing my head in.
Russell.
Upvotes: 1
Views: 3203
Reputation: 547
Yay! It seems that the issue lies with my sky router!
It would appear that the answer to the OP's question is yes. Yes it is that bad.
:(
No idea where to go from here...
Upvotes: 0