如何查看收到的ICMP消息 [英] How to see recieved ICMP message

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

问题描述

public static void ComplexLocalPing ()
      {
          // Ping's the local machine.
          Ping pingSender = new Ping ();
          IPAddress address = IPAddress.Loopback;

          // Create a buffer of 32 bytes of data to be transmitted.
          string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
          byte[] buffer = Encoding.ASCII.GetBytes (data);

          // Wait 10 seconds for a reply.
          int timeout = 10000;

          // Set options for transmission:
          // The data can go through 64 gateways or routers
          // before it is destroyed, and the data packet
          // cannot be fragmented.
          PingOptions options = new PingOptions (64, true);
          PingReply reply = pingSender.Send (address, timeout, buffer, options);

          if (reply.Status == IPStatus.Success)
          {
              Console.WriteLine ("Address: {0}", reply.Address.ToString ());
              Console.WriteLine ("RoundTrip time: {0}", reply.RoundtripTime);
              Console.WriteLine ("Time to live: {0}", reply.Options.Ttl);
              Console.WriteLine ("Don't fragment: {0}", reply.Options.DontFragment);
              Console.WriteLine ("Buffer size: {0}", reply.Buffer.Length);
          }
          else
          {
              Console.WriteLine (reply.Status);
          }
      }





假设我是通过此代码将数据发送到另一台机器,用户如何看到发送给他的数据。



Suppose if i am sending data through this code to another machine, how user can see data send to him.

推荐答案

我所知道的没有应用程序可以显示数据。 ICMP数据包通常不会使网络堆栈足够高,以显示该数据。必须专门为此目的编写应用程序并在目标计算机上运行,​​并在控制台登录,以显示任何数据。 PING背后的一点是,除了O / S和它的网络堆栈之外,它不依赖于目标机器上运行的任何东西才能工作。没有应用程序需要运行,没有人需要登录。



根据您的规范,您最终要编写的是聊天应用程序。无需使用ICMP。
There is no application I know of that will show you the data. An ICMP packet normally does not make it high enough up the network stack for that data to be shown. An application would have to be specifically written for the purpose and running on the target machine, with someone logged in at the console, for any data to be shown. The point behind PING is that is doesn't rely on anything running on the target machine besides the O/S and it's network stack in order to work. No application needs to be running and nobody needs to be logged in.

What you would ultimately be writing, based on your specifications, is a chat application. No need to use ICMP for that.


这篇关于如何查看收到的ICMP消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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