Basing on multicast receiver from: How do you UDP multicast in Python?
I adjusted it to my needs considering the fact I wanted to stream 10,5 MB test file video using VLC and analyse packets sent by it. Here is configuration of VLC: https://i.stack.imgur.com/l0wsd.jpg
The problem is that I see on wireshark 769 captured packets where python prints out that he received a little bit above 600. What may be cause? I believe my method of calculating packets may be wrong in python. Do you have any solutions? Here is python vs wireshark packets shown:
https://i.stack.imgur.com/8QIjA.jpg
import socket
import struct
MCAST_GRP = '239.200.200.1'
MCAST_PORT = 5252
IS_ALL_GROUPS = True
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
if IS_ALL_GROUPS:
# on this port, receives ALL multicast groups
sock.bind(('', MCAST_PORT))
else:
# on this port, listen ONLY to MCAST_GRP
sock.bind((MCAST_GRP, MCAST_PORT))
mreq = struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY)
sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)
counter = 0
print("Entering while loop")
while True:
datagram = sock.recv(1328)
counter +=1
print(counter)
I would like to calculate bitrate by knowing amount of captured packets sent by multicast streamer and dividing this number by time of observation. But the thing is I want to be sure if amount of captured packets by python is correct, but so big divergence between wireshark and python looks like it is not correct.
The interesting thing is that if I'm understanding it correctly, even 769 packets are not enough. 769 * 1328 = 1.021.232 bytes which is about 1MB where video is 10.5MB. Am I thinking correctly?