File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes Network activity monitor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Network activity monitor" Watch "Network activity monitor" New topic

Network activity monitor

Maysam Sorkhabi

Joined: Jul 13, 2004
Posts: 23
Hi there,
I share a cable connection in between two computers using a router. I'd like to write a little Java programs that constantly shows the bandwidth usage of each computer. i.e. I'd like to see how much data is uploaded over the cable connection from say my mom's computer. I'd like to have this as a little diagnostic tool. Any ideas about how this can be done?

(p.s. I have some background in internet programing using Java, so feel free to go all out technical)
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I think you'd have to get into some pretty low level APIs in your TCP-IP stack or even hardware drivers. Java likely won't do that kind of thing directly as it is OS and hardware independent. You might be able to do the low level monitoring in C/C++ and put a Java user interface or business layer on top of that with JNI.

Have you ever seen any code that does this kind of thing?

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Maysam Sorkhabi

Joined: Jul 13, 2004
Posts: 23
No Sir I really haven't. I was more thinking of some already implemented class\methods that would carry out this operation. But anyway thank for replying.
Elihu Smails
Ranch Hand

Joined: Jan 12, 2005
Posts: 37
If you have 2 processes you could roll your own InputStream to measure network performance. Otherwise, you are out of luck.
Paul Santa Maria
Ranch Hand

Joined: Feb 24, 2004
Posts: 236
If SNMP is enabled on the host, and if you have the correct administrative privileges, you can query the OS-level network performance counters using Java and SNMP.
I agree. Here's the link:
subject: Network activity monitor
It's not a secret anymore!