2

In my Linux, I have an interface eth5 with IP 10.46.55.106.
I see the multicast stream on eth5:

$ tcpdump -i eth5 host 233.113.216.61 and port 21001  

11:18:19.416631 IP 194.0.142.188.48253 > 233.113.216.61.21001: UDP, length 20
11:18:19.450577 IP 194.0.142.188.48253 > 233.113.216.61.21001: UDP, length 20
11:18:19.498923 IP 194.0.142.188.48253 > 233.113.216.61.21001: UDP, length 20
11:18:19.546345 IP 194.0.142.188.48253 > 233.113.216.61.21001: UDP, length 20

But I can not see the multicast packets with my Python code below :

import socket
import struct
import sys


# create a UDP socket
my_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

# allow reuse of addresses
my_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

# set multicast interface to local_ip
my_socket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton('10.46.55.106'))

# Set multicast time-to-live to 2...should keep our multicast packets from escaping the local network
my_socket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)

# Construct a membership request...tells router what multicast group we want to subscribe to
membership_request = socket.inet_aton('233.113.216.51') + socket.inet_aton('10.46.55.106')

# Send add membership request to socket
# See http://www.tldp.org/HOWTO/Multicast-HOWTO-6.html for explanation of sockopts
my_socket.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, membership_request)

my_socket.bind(('0.0.0.0', 21001))

while True:
    data, address = my_socket.recvfrom(20)
    print "%s says the time is %s" % (address, data)

Do I miss something?

xyzt
  • 1,201
  • 4
  • 18
  • 44

0 Answers0