如何诊断我们的 java IP 多播应用程序?
由于某种原因,我运行的每个多播示例(计算机运行 OpenSUSE Linux)都可以工作。顾客们都静静地坐着。如何找出多播被阻止/忽略的原因?
一些示例:
示例 1
http://www.roseindia。 net/java/example/java/net/udp/UDPMulticastServer.java
示例 2
http://docs.oracle.com/javase/tutorial/networking/datagrams/broadcasting.html (使用这些文件:) http://docs.oracle.com/javase/tutorial/networking /datagrams/examples/MulticastServer.java http://docs.oracle.com/javase/tutorial/networking/datagrams/examples/MulticastServerThread.java http://docs.oracle.com/javase/tutorial/networking /datagrams/examples/MulticastClient.java http://docs.oracle.com/javase/tutorial/networking/datagrams/examples/one-liners.txt
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 blocked/ignored?
Some of the examples:
EXAMPLE 1
http://www.roseindia.net/java/example/java/net/udp/UDPMulticastServer.java
Example 2
http://docs.oracle.com/javase/tutorial/networking/datagrams/broadcasting.html
(uses these files:)
http://docs.oracle.com/javase/tutorial/networking/datagrams/examples/MulticastServer.java
http://docs.oracle.com/javase/tutorial/networking/datagrams/examples/MulticastServerThread.java
http://docs.oracle.com/javase/tutorial/networking/datagrams/examples/MulticastClient.java
http://docs.oracle.com/javase/tutorial/networking/datagrams/examples/one-liners.txt
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在排除 IP 多播故障时,您可以采取一些总体措施来确定这是主机问题、软件问题还是网络问题:
ping
测试(使用 Linux 的socat
工具)每个步骤的详细信息概述如下...
步骤 1
首先,确保 Linux 多播接收器正确地广播其组成员身份报告;请记住,多播中的许多内容都是与单播相反的。例如,多播要求您发送包含要接收的多播组的 IGMP 加入数据包。
使用
tcpdump
或tshark
检查有问题的接口...在下面的示例中,我在192.168.12.238
上有一台机器正在宣布(通过igmp
)它想要从239.255.0.1
接收多播流量现在检查多播源的流量是否到达此接口(我假设它是 eth0,如下):
如果您看到流量发送到正确的多播组,则直接继续步骤 3;否则请转至步骤 2。
步骤 2
接下来确保您的多播服务器将流量发送到正确的组。在下面的示例中,我运行命令来嗅探
eth0
发送到239.255.0.1
的流量。如果多播源在步骤 2 中将流量发送到正确的组,您在步骤 1 中看到 IGMP 组加入,而步骤 1 在多播接收者的接口上没有看到流量,那么请联系您的网络管理员了解此问题。
步骤 3
假设所有这些都有效,并且您仍然需要进行严格测试,以防您的多播接收器软件以某种方式丢弃从 IP 堆栈接收到的多播...确保您的计算机上安装了
socat
并且执行以下操作...在组播发送方(服务器)上,使用此命令将测试组播数据包发送到
239.255.0.1
:在组播接收方(客户端)上,使用此命令侦听测试组播数据包发送到
eth0
上的239.255.0.1
:假设您的网络管理员允许在
239.255.0.1
上进行多播,您将在多播接收者的终端窗口:注意:不要使用网络上已在生产使用的多播组地址尝试此操作。
步骤 4
如果步骤 1、2 和 3 显示正在通过您的网络发送和接收多播流量,请致电软件开发人员并告诉他们您认为应用程序存在问题,并解释您迄今为止所采取的步骤。
如果步骤 1、2 或 3 不起作用,请重新配置您的软件/主机/网络,直到它们起作用为止。警告,在 IP 网络中正确实施多播的难度是 IP 单播的 3 倍。
祝你好运...
When troubleshooting IP multicast, there are some big-picture things you can do to isolate whether this is a host issue, software issue, or network issue:
ping
test for IP multicast (using linux'ssocat
tool)The details for each step are outlined below...
Step 1
First, ensure that the linux multicast receivers are correctly advertising their group membership reports; keep in mind that a lot of things in multicast work backwards from unicast. For instance, multicasting requires that you send an IGMP join packet that contains the multicast group you want to receive.
Use
tcpdump
ortshark
to examine the interface in question... In the example below, I have a machine on192.168.12.238
that is announcing (viaigmp
) that it wants to receive multicast traffic from239.255.0.1
Now check and see whether the multicast source's traffic is getting to this interface (I'm assuming it was eth0, below):
If you see traffic sent to the proper multicast group, then proceed directly to Step 3; otherwise go to Step 2.
Step 2
Next ensure that your multicast server is sending the traffic to the correct group. In the example below, I run a command to sniff
eth0
for traffic sent to239.255.0.1
.If the multicast source is sending traffic to the right group here in Step 2, you saw IGMP group joins in Step 1, and Step 1 did not see traffic at the multicast receiver's interface, then contact your network administrators about this problem.
Step 3
Assuming all that works, and you still want an acid test in case your multicast receiver software is somehow discarding multicast it receives from the IP stack... make sure you have
socat
installed on your machine and do the following...On the multicast sender (server), use this command to send test multicast packets to
239.255.0.1
:On the multicast receiver (client), use this command to listen to test multicast packets sent to
239.255.0.1
oneth0
:Assuming your network administrators are allowing multicast on
239.255.0.1
, you will see a lot of traffic like this in the multicast receiver's terminal window:NOTE: do not try this with a multicast group address that is already in production use on your network.
Step 4
If steps 1, 2, and 3 reveal that multicast traffic is being sent and received through your network, then call up the software developer and tell them you think there is a problem with the application and explain the steps you have taken so far.
If steps 1, 2, or 3 do not work, reconfigure your software / hosts / network until they do. Warning, multicast in IP networks is 3x harder to implement correctly than IP unicast.
Best of luck to you...
如何检查多播?
当集群中断时,可能是由于多种原因造成的。其中之一是多播(应用程序订阅某个 IP 地址并侦听消息)。如果用户发现自己间歇性地注销,则可能表明存在此类问题。
多播 IP 地址的范围为 224.0.0.0 到 239.255.255.255。
这篇文章只是提醒我在 Linux 级别要做什么检查:
运行 netstat -g 来获取该主机订阅的多播地址。
注意,RefCnt 列中显示有 2 个成员属于组 239.128.4.0
Ping 该多播地址可显示哪些成员订阅了该组(或集群):
< /i>
jgroups
测试多播的一个好方法是使用 jgroups。请参阅http://www.jgroups.org/manual/html/ch02.html#它不起作用
下载 jgroups-3.3.3.Final.jar
消息出现在接收者窗口中并显示发送者:
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.
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):
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
The message appears in the receiver window and displays the sender:
防火墙阻止了多播。打开端口就可以了!
There was a firewall blocking the multicasts. Opened a port and it works!