Question

I'm trying to build an RTP packet metric analyzer in C, but i ended up in a strange issue, I'm cutting down implementation details for ease of exposure:

Since the RTP packets are contained in UDP my socket is initalized with the following parameters:

sock_domain = AF_INET;
sock_type = SOCK_DGRAM;
sock_proto = IPPROTO_UDP;

and binded with those parameters:

socket_addr.sin_family = AF_INET;
socket_addr.sin_port = 10000; // My server is streaming on 10000
socket_addr.sin_addr.s_addr = INADDR_ANY;

and joined the multicast group:

mgroup_req.imr_multiaddr.s_addr = inet_addr("224.1.0.1"); // Multicast group of the stream
mgroup_req.imr_interface.s_addr = INADDR_ANY;

set the multicast group from which i receive to:

mgroup_addr.sin_family = socket_addr.sin_family;
mgroup_addr.sin_port = socket_addr.sin_port;
mgroup_addr.sin_addr.s_addr = mgroup_req.imr_multiaddr.s_addr;

receiving packets with recvfrom function:

errcode = recvfrom(sockfd, &recvbuff, IPMAXSIZE, 0, (struct sockaddr *)&mgroup_addr, &mgroup_addr_len)

Something goes wrong, while i can receive standard UDP packets addressed to the multicast group 224.1.0.1, the RTP packets are not received the first time, but sending them again makes the trick.

Scenario 1:

I send n UDP packets: They are correctly received

Scenario 2:

I send n RTP packets: Nothing happens

I send again the same n RTP packets: They are correctly received

whatever the n number of packets is... so weird but true.

edit: At the analyzer side I'm running a sniffer and it shows both the packet bursts, so messages arrives at the analyzer side, it's not a sender related problem.

Question:

the code is exactly the same (read: Same executable) for the RTP scenario AND the UDP scenario. What am I doing wrong?

Side notes:

RTP manage libraries or high-level RTP libraries suggestions are a no-no, I MUST work at this level of abstraction because of the metrics i need to analyze.

Also Network metrics analyzer are a no-no, I MUST do this with my own code.

Thanks in advance.

Was it helpful?

Solution 2

The issue was due to the board i was working on, it was set (not my code) for redirecting RTP packets directly to the MPEG decoder. Turns out that packets in the decoder are not to be forwarded to the Kernel. Still has to understand why the double send was working.

OTHER TIPS

I'm not convinced that you need to name the mcast group address again as the recvfrom address, as you've already joined the group. Is receiving packets from elsewhere a genuine concern? I would just use recv().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top