[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Java code to test network connectivity

Posted on 2015-02-12
4
Medium Priority
?
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
Ali Can Albayrak earned 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

649 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