Solved

Java code to test network connectivity

Posted on 2015-02-12
4
136 Views
Last Modified: 2015-06-02
Hi,
I want to write a java code to test the speed of network. I want to use the www.google.com as url for testing my network speed. I need to perform the following operations :
1) ping
2) Sockets
3) http
4) DNS resolution

How to i perform all these operation in java ie. how do i ping the www.google.com and get the result in java ?
Similarly i want to check how long it takes to make a sockets connection with google and how long http calls take and DNS resolution.


Thanks
0
Comment
Question by:Rohit Bajaj
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
Ali Can Albayrak earned 500 total points
ID: 40607411
I strongly recommend you to check out ICMP4J. Do not re-invent the wheel, If you are willing to use 3rd party lib
0
 

Author Comment

by:Rohit Bajaj
ID: 40607572
Is there no simple way in java to create a socket and send some data and get the response just to see the rountrip time ?

I want to calculate the roundtrip time to google.
0
 
LVL 1

Expert Comment

by:Ali Can Albayrak
ID: 40607705
Here I posted sample code. It checks connectivity first then pings for once.
You may remove connection test part for your constraints. Because it checks connectivity over HTTP protocol.
ConnectivityTest.java
0
 

Author Comment

by:Rohit Bajaj
ID: 40609286
Hi
Thanks for the code.
Its good
But i nees some other way to fo for ping command in java as i will be testing this on an app on android phone.
I think in that case checking for operating system and executing the ping command wont work.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
best (free) software to access postgres db (java) 1 32
custom annotations 9 32
Basic Java Case or If-Else statement... 3 43
nextBoolean(double p) for Random class 3 35
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now