ICMP数据包 [英] ICMP packets

查看:86
本文介绍了ICMP数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在做一项研究,寻找能够做到这一点的Java解决方案。

ping。


我发现了旧消息(而不是那么旧的消息),因为提供的API不支持原始套接字,因此告知Java不能这样做,因为提供的API不支持原始套接字。

我找到的唯一解决方案是模拟。一个ping程序

在端口7上向服务器发出UDP请求。


所以我决定阅读API(1.4.2),我发现那个包

" java.net"能够发送ICMP数据包。


实际上,这是我的问题,我只发现了一个例外:

表示ICMP端口无法访问消息已收到

连接的数据报。

http://java.sun.com/j2se/1.4.2/docs/...xception.html))/ a>。


好​​吧,如果软件包有ICMP的例外,我现在可以说,我现在可以使用Java来讨论ICMP

http://java.sun.com/j2se/1.4.2/docs/...amSocket.html)


我是对的吗?


最后:有人做过与此相关的事情,使用新的

api吗?是否有可能发布一个例子?


谢谢,


Bob Rivers

圣保罗 - 巴西

解决方案



" Bob Rivers" <博******* @ pobox.com>在消息中写道

新闻:aa ************************* @ posting.google.co m ... < blockquote class =post_quotes>

我正在研究寻找能够做到ping的Java解决方案。

我找到了旧消息(而不是那么旧的消息),告诉Java无法做到这一点,因为提供的API不支持原始套接字。
我发现的唯一解决方案是模拟。一个ping程序
在端口7上向服务器发出UDP请求。




在Unix下,至少ping需要setuid权限。这意味着

ping程序有权对系统做任何事情,而b $ b想要这样做。据推测,代码已经过仔细检查,因此它没有做任何错误。


将JVM作为setuid root运行会很糟糕,这对于做ping的能力是必需的。
。如果真的想要这样做,肯定可以执行

/ usr / sbin / ping。我确信其他

操作系统有类似的保护措施来保护系统免受未经授权的访问。


我很怀疑,不过,为什么这个话题经常出现。

有什么优势可以用到能够ping的程序?对于网络管理员检查网络是否正常工作非常有用。

虽然越来越多的防火墙阻止ping和TCP和UDP回声

端口,降低了这些功能的实用性。


- glen


你不能尝试在服务器上打开一个虚拟URL

并查看结果?

" Glen Herrmannsfeldt" < ga*@ugcs.caltech.edu>在消息中写道

news:Z9Ulb.3628


mZ5.22428@attbi_s54 ...


" Bob河流" <博******* @ pobox.com>在消息中写道
新闻:aa ************************* @ posting.google.co m ...



我正在研究寻找能够做到ping的Java解决方案。

我找到了旧消息(和因为所提供的API不支持原始套接字,所以我知道Java的唯一解决方案是仿真。一个ping程序
在端口7上向服务器发出UDP请求。
在Unix下,至少ping需要setuid权限。这意味着ping程序有权对系统做任何事情



它想要的。据推测,代码已经过仔细检查,以至于它没有做错任何事。

将JVM作为setuid root运行会很糟糕,那就是
要做到平,才能做到这一点。如果真的想要这样做,肯定可以
执行/ usr / sbin / ping。我确信其他操作系统也有类似的保护措施来保护系统免受未经授权的访问。

我很想知道为什么这个主题会经常出现。具有ping功能的程序有什么优势呢?网络管理员检查网络是否正常工作非常有用。
虽然越来越多的防火墙阻止ping和TCP和UDP回送端口,但降低了这些功能的实用性。

- glen



Hi,

I was doing a research looking for Java solutions that are able to do
"ping".

I found old messages (and not so old ones), telling that Java was not
able to do that, because the API provided do not support raw sockets.
The only solution that I found was a "simulation" of a ping program
doing a UDP request to a server on port 7.

So I decided to read the API (1.4.2) and I found that the package
"java.net" is able to send ICMP packets.

Actually, and this is my question, I only found an exception that:
"Signals that an ICMP Port Unreachable message has been received on a
connected datagram."
(http://java.sun.com/j2se/1.4.2/docs/...xception.html).

Well, if the package has a exception for ICMP, I can supose that now I
am able to talk ICMP using Java
(http://java.sun.com/j2se/1.4.2/docs/...amSocket.html).

Am I right?

And finally: does someone did something related to this, using the new
api? Is it possible to post an example?

Thanks,

Bob Rivers
Sao Paulo - Brazil

解决方案


"Bob Rivers" <bo*******@pobox.com> wrote in message
news:aa*************************@posting.google.co m...

Hi,

I was doing a research looking for Java solutions that are able to do
"ping".

I found old messages (and not so old ones), telling that Java was not
able to do that, because the API provided do not support raw sockets.
The only solution that I found was a "simulation" of a ping program
doing a UDP request to a server on port 7.



Under Unix, at least, ping requires the setuid privilege. That means that
the ping program has the full authority to do anything to the system that it
wants to. Presumably the code has been carefully checked so that it
doesn''t do anything wrong.

It would be horrible to run the JVM as setuid root, and that would be
required for the abiltity to do ping. It is certainly possible to execute
/usr/sbin/ping if one really wants to do it. I am sure that other
operating systems have similar protections protecting the system against
unauthorized access.

I do wonder, though, why this subject comes up so often. What advantage
could there be to a program with the ability to do ping? It is useful for
network administrators to check that the network is working properly.
Though more and more firewalls block both ping and the TCP and UDP echo
ports, reducing the usefulness of these features.

-- glen


can''t you just try to open a dummy URL on the server
and look at the result?
"Glen Herrmannsfeldt" <ga*@ugcs.caltech.edu> wrote in message
news:Z9Ulb.3628


mZ5.22428@attbi_s54...


"Bob Rivers" <bo*******@pobox.com> wrote in message
news:aa*************************@posting.google.co m...

Hi,

I was doing a research looking for Java solutions that are able to do
"ping".

I found old messages (and not so old ones), telling that Java was not
able to do that, because the API provided do not support raw sockets.
The only solution that I found was a "simulation" of a ping program
doing a UDP request to a server on port 7.
Under Unix, at least, ping requires the setuid privilege. That means that
the ping program has the full authority to do anything to the system that


it wants to. Presumably the code has been carefully checked so that it
doesn''t do anything wrong.

It would be horrible to run the JVM as setuid root, and that would be
required for the abiltity to do ping. It is certainly possible to execute /usr/sbin/ping if one really wants to do it. I am sure that other
operating systems have similar protections protecting the system against
unauthorized access.

I do wonder, though, why this subject comes up so often. What advantage
could there be to a program with the ability to do ping? It is useful for
network administrators to check that the network is working properly.
Though more and more firewalls block both ping and the TCP and UDP echo
ports, reducing the usefulness of these features.

-- glen



这篇关于ICMP数据包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆