Chinaunix首页 | 论坛 | 博客
  • 博客访问: 350892
  • 博文数量: 77
  • 博客积分: 1447
  • 博客等级: 中尉
  • 技术积分: 885
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-21 21:48
文章分类

全部博文(77)

文章存档

2021年(2)

2020年(2)

2016年(3)

2015年(1)

2014年(4)

2013年(1)

2012年(23)

2011年(15)

2010年(26)

分类: LINUX

2016-08-15 13:58:50

linux环境处理方法:
如果是多网卡多网段,在接收组播时有时收不到UDP包,可以考虑修改/etc/sysctl.conf文件,把 net.ipv4.conf.all.rp_filter和net.ipv4.conf.default.rp_filter设为0即可

系统配置文件
1. /etc/sysctl.conf
把 net.ipv4.conf.all.rp_filter和net.ipv4.conf.default.rp_filter设为0即可
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
系统启动后,会自动加载这个配置文件,内核会使用这个变量

2. 命令行
显示一个内核变量 sysctl net.ipv4.conf.all.rp_filter
设置一个内核变量 sysctl -w net.ipv4.conf.all.rp_filter=0
设置完后,会更新内核(实时的内存)中的变量的值,但不会修改sysctl.conf的值

3. 使用/proc文件系统
查看 cat /proc/sys/net/ipv4/conf/all/rp_filter
设置 echo "0">/proc/sys/net/ipv4/conf/all/rp_filter

Windows处理方法

IP_MULTICAST_IF.

Usually, the system administrator specifies the default interface multicast datagrams should be sent from. The programmer can override this and choose a concrete outgoing interface for a given socket with this option.

struct in_addr interface_addr;
setsockopt (socket, IPPROTO_IP, IP_MULTICAST_IF, &interface_addr, sizeof(interface_addr));

>From now on, all multicast traffic generated in this socket will be output from the interface chosen. To revert to the original behavior and let the kernel choose the outgoing interface based on the system administrator's configuration, it is enough to call setsockopt() with this same option and INADDR_ANY in the interface field.

In determining or selecting outgoing interfaces, the following ioctls might be useful: SIOCGIFADDR (to get an interface's address), SIOCGIFCONF (to get the list of all the interfaces) and SIOCGIFFLAGS (to get an interface's flags and, thus, determine whether the interface is multicast capable or not -the IFF_MULTICAST flag-).

If the host has more than one interface and the IP_MULTICAST_IF option is not set, multicast transmissions are sent from the default interface, although the remainding interfaces might be used for multicast forwarding if the host is acting as a multicast router.

虽然使用上面的参数以期望来绑定IP 甚至采用bind动作也没能成功, 唯一的方法还是调整组播的缺省路由。
下面几个命令非常有用:

查看当前各个网卡有那些在绑定的组播IP
netsh interface ip show joins    

查看路由表
route print

先删除缺省组播kht

route delete 224.0.0.0 mask 240.0.0.0          

添加路由
route add destinationmask subnetmask gateway metriccost metric if interface      
示例:   route add 224.0.0.0 mask 240.0.0.0 192.168.50.186




阅读(2722) | 评论(0) | 转发(0) |
0

上一篇:linux date命令

下一篇:查看cpu的cache

给主人留下些什么吧!~~