Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

ping ttl times

Options
  • 02-03-2006 7:17pm
    #1
    Closed Accounts Posts: 73 ✭✭


    hey im doing a a project at the moment on windows,creating a fron ent to nmap and drawing a map of a network based on the results of the scan,Im trying to use the ttl times so that i can estimate where on the network a computer is sitting,i tried hping but it didnt seem to work too well for me,i need to be able to save the results of the scan to a text file preferably as xml,this is why i cant use just the basic ping command,any help will be greatly appreciated...


Comments

  • Closed Accounts Posts: 140 ✭✭Sneaky_Russian


    write your own ping code/program :)

    a quick google pulls up plenty of source code you can use as reference.


  • Closed Accounts Posts: 146 ✭✭MrScruff


    Why don't you pipe the output to a file and then parse that?

    eg.

    ping www.google.ie > g.txt


  • Closed Accounts Posts: 140 ✭✭Sneaky_Russian


    i was gonna suggest that as it's probobly the simplest.

    the reason i didn't is because i pressume that there'll be a lot of "ping'ing" going on so that would be grossly inificient. for a single or infrequent ping request, maybe i'd think of doing that.

    plus having your own ping code will make your application alot more flexible.

    college project i presume?
    what language are you using?


  • Closed Accounts Posts: 73 ✭✭Nocturnal


    Ya its my final year project,Im doing it through java,im on a bit of a timescale so i'd prefer to use something thats allready written then trying to create my own ping program!Thanks for the suggestions anyways lads,il go and see what i can do now and let ye know how i get on.


  • Closed Accounts Posts: 146 ✭✭MrScruff


    Java networking is apparently too high level to perform a ping.

    Here is a simple class that executes a ping command and prints the output.
    Writing a ping class that does a regular expression on the results and returns
    the array of return times is left as an excercise for the reader. ;)
    import java.io.*;
    public class gnip
    {
       public static void main(String[] args)
       {
          try
          {
             Runtime rt = Runtime.getRuntime();
             String s = "C:\\windows\\system32\\ping.exe www.google.com";
             Process p = rt.exec(s);
             InputStream is = p.getInputStream();
             InputStreamReader isr = new InputStreamReader(is);
             BufferedReader br = new BufferedReader(isr);
    
             String line;
             while ((line = br.readLine()) != null)
             {
                System.out.println(line);
    	     }
          }
          catch (Exception ex)
          {
             ex.printStackTrace();
          }
       }
    }
    

    What is your project about anyway?


  • Advertisement
  • Closed Accounts Posts: 884 ✭✭✭NutJob


    Thats true java will not let u create the raw socket functionality you need for ping. I had to use the approach below to acomplish the same thing.


    Plus the code posted below only requires you to parse a stream for what you want.


Advertisement