How can I diagnose our java IP multicast application?

后端 未结 3 806
时光说笑
时光说笑 2021-02-11 11:50

For some reason, every multicast example I run (the computer runs OpenSUSE Linux) will work. The clients all just sit silently. How do I figure out why the multicast is being bl

3条回答
  •  攒了一身酷
    2021-02-11 12:15

    How to check Multicasting ?

    When clustering breaks, it could be due to a number of reasons. One of them is multicasting (where applications subscribe to a certain IP address and listen for messages). If users find themselves intermittently logged out, this might indicate such a problem.

    A multicast IP address will be in the range 224.0.0.0 to 239.255.255.255. This post is just a reminder to me what checks to do at the linux level:

    Run netstat -g to get the multicast addresses this host subscribes to.

    [root@bruatwls001 ~]$ netstat -g
    IPv6/IPv4 Group Memberships
    Interface       RefCnt Group
    --------------- ------ ---------------------
    lo              1      all-systems.mcast.net
    eth0            2      239.128.4.0
    eth0            1      all-systems.mcast.net
    

    Note in the RefCnt column it shows 2 members belong to the group 239.128.4.0

    Pinging this multicast address reveals which members subscribe to the group (or cluster):

    [root@bruatwls001 ~]$ ping 239.128.4.0
    PING 239.128.4.0 (239.128.4.0) 56(84) bytes of data.
    64 bytes from 10.35.8.12: icmp_seq=0 ttl=64 time=0.032 ms
    64 bytes from 10.35.8.13: icmp_seq=0 ttl=64 time=0.207 ms (DUP!)
    64 bytes from 10.35.8.12: icmp_seq=1 ttl=64 time=0.029 ms
    64 bytes from 10.35.8.13: icmp_seq=1 ttl=64 time=0.193 ms (DUP!)
    64 bytes from 10.35.8.12: icmp_seq=2 ttl=64 time=0.028 ms
    64 bytes from 10.35.8.13: icmp_seq=2 ttl=64 time=0.241 ms (DUP!)
    

    jgroups

    A good way to test multicasting is using jgroups. See http://www.jgroups.org/manual/html/ch02.html#ItDoesntWork Download jgroups-3.3.3.Final.jar

    • Start the receiver:

    [quick@laptop]$ java -cp jgroups-3.3.3.Final.jar org.jgroups.tests.McastReceiverTest -mcast_addr 231.12.21.132 -port 45566
    Socket=0.0.0.0/0.0.0.0:45566, bind interface=/fe80:0:0:0:201:4aff:fe5e:5331%2
    Socket=0.0.0.0/0.0.0.0:45566, bind interface=/192.168.1.5
    Socket=0.0.0.0/0.0.0.0:45566, bind interface=/0:0:0:0:0:0:0:1%1
    Socket=0.0.0.0/0.0.0.0:45566, bind interface=/127.0.0.1
    

    • Start the sender and type something:

     [quick@centos ~]$ java -cp jgroups-3.3.3.Final.jar org.jgroups.tests.McastSenderTest -mcast_addr 231.12.21.132 -port 45566
    Socket #1=0.0.0.0/0.0.0.0:45566, ttl=32, bind interface=/fe80:0:0:0:fc54:ff:fedc:d6da%7  
    Socket #2=0.0.0.0/0.0.0.0:45566, ttl=32, bind interface=/fe80:0:0:0:21d:7dff:fe03:4cf5%2  
    Socket #7=0.0.0.0/0.0.0.0:45566, ttl=32, bind interface=/192.168.122.1  
    Socket #8=0.0.0.0/0.0.0.0:45566, ttl=32, bind interface=/fe80:0:0:0:21d:7dff:fe03:4cf5%2  
    Socket #9=0.0.0.0/0.0.0.0:45566, ttl=32, bind interface=/fe80:0:0:0:21d:7dff:fe03:4cf5%3  
    Socket #10=0.0.0.0/0.0.0.0:45566, ttl=32, bind interface=/0:0:0:0:0:0:0:1%1  
    Socket #11=0.0.0.0/0.0.0.0:45566, ttl=32, bind interface=/127.0.0.1  
    > helloworld  
    > quit
    

    The message appears in the receiver window and displays the sender:

    helloworld [sender=192.168.1.20:45566]  
    helloworld [sender=192.168.1.20:45566]  
    helloworld [sender=192.168.1.20:45566]  
    helloworld [sender=192.168.1.20:45566]  
    helloworld [sender=192.168.1.20:45566]  
    

提交回复
热议问题