我希望将UDP组播数据包发送到环回地址,并在其他应用程序中接收相同的数据包.所有测试都在fedora core 17 Linux上完成.
我们的想法是通过RTSP/HTTP或任何其他网络协议接收视频流,并将其多播到环回地址,以便我可以使用VLC使用多播地址播放流.暂且不谈其他比特率和受控多播问题,我尝试在环回设备上读取一个视频文件和多播.但是当试图在vlc上播放同样的内容时它没有用.我能够看到数据包在wireshark中传输,但src ip取自我的默认网络接口(即接口,这是我的默认网关)
我已经尝试过以下命令
sudo ifconfig lo multicast
sudo ip route add 239.252.10.10 dev lo
Run Code Online (Sandbox Code Playgroud)
在这方面的任何建议都会非常有帮助.
测试程序代码粘贴在下面
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define MULTICAST_ADDRESS "239.252.10.10"
#define UDP_PORT 1234
#define INTERFACE_IP "127.0.0.1"
#define MTU 1474
#define DATA_BUFFER_SIZE (1024*1024)
static int socket_init(char *intf_ip) {
int sd;
struct in_addr localInterface;
sd = socket (AF_INET, SOCK_DGRAM, 0);
if (sd < 0) {
perror ("Opening datagram socket error");
return -1;
} …Run Code Online (Sandbox Code Playgroud)