Traceroute Command


// Traceroute Command
// traceroutecmd.java

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class traceroutecmd
{
     public static void runSystemCommand(String command)
     {
          try
          {
              Process p = Runtime.getRuntime().exec(command);
              BufferedReader inputStream = new BufferedReader(
                        new InputStreamReader(p.getInputStream()));

              String s = "";
              while ((s = inputStream.readLine()) != null)
                   System.out.println(s);
          }
          catch (Exception e)
          {
          }
     }

     public static void main(String[] args)
     {  
          // String ip = "www.google.co.in";
          // String ip = "127.0.0.1";
          String ip = "www.drranurekha.com";
          runSystemCommand("tracert " + ip);
     }
}




OUTPUT:

>javac traceroutecmd.java

>java traceroutecmd

Tracing route to drranurekha.com [160.153.137.167] over a maximum of 30 hops:

  1    <1 ms    <1 ms    <1 ms  10.0.15.1
  2    <1 ms    <1 ms    <1 ms  10.0.0.15
  3     1 ms     1 ms     1 ms  210.212.247.209
  4     2 ms     1 ms     1 ms  172.24.75.102
  5     *        *       21 ms  218.248.235.217
  6     *        *       12 ms  218.248.235.218
  7    21 ms    21 ms    21 ms  121.244.37.253.static.chennai.vsnl.net.in [121.244.37.253]
  8     *        *        *     Request timed out.
  9    49 ms    49 ms    49 ms  172.25.81.134
 10    50 ms    50 ms    70 ms  ix-ae-0-4.tcore1.mlv-mumbai.as6453.net [180.87.38.5]
 11   165 ms   165 ms   165 ms  if-ae-9-5.tcore1.wyn-marseille.as6453.net [80.231.217.17]
 12   172 ms   171 ms   171 ms  if-ae-8-1600.tcore1.pye-paris.as6453.net [80.231.217.6]
 13   171 ms   171 ms   171 ms  if-ae-15-2.tcore1.av2-amsterdam.as6453.net [195.219.194.145]
 14   175 ms   175 ms   175 ms  195.219.194.2
 15   171 ms   170 ms   170 ms  po72.bbsa0201-01.bbn.mgmt.ams1.gdg [188.121.33.74]
 16   170 ms   169 ms   169 ms  10.241.131.203
 17   175 ms   175 ms   175 ms  10.253.1.1
 18   166 ms   166 ms   166 ms  10.253.130.9
 19   173 ms   173 ms   173 ms  10.253.130.3
 20   169 ms   169 ms   169 ms  10.253.130.5
 21   169 ms   169 ms   169 ms  ip-160-153-137-167.ip.secureserver.net [160.153.137.167]

Trace complete.

                    >

2 comments:

Don't be a silent reader...
Leave your comments...

Anu