measure bandwidth in / out of socket

A

antoine

Hello,

I'm currently developping a client / server application, with client &
server running on the same PC for the moment.

the goal is to ultimately run them over a WAN, and in order to improve
performances & bandwidth usage, I'd like to develop a tool that
measures the bandwidth used between client & server during the life of
the application (average & max), some kind of application-specific MRTG
(the "text" part would be enough, I can take care of the graphing
myself).

I was thinking of simply "counting" bytes written / read on the sockets
during a specific interval and log everything to a file, but I'm
wandering if there's a smarter way to do that...

does anybody know of a tool / method in the basic Java API that could
help me achieve that ? or any other tool for that matter...

thanks for your feedback.
 
R

Roedy Green

does anybody know of a tool / method in the basic Java API that could
help me achieve that ? or any other tool for that matter...

On Win2K you can persuade a TCP/IP icon to sit in the right end of
your task bar. IF you pop it up it tells you packets sent and received
and speed.

There is a speed tool in http://mindprod.com/jgloss/tweakdun.html

There are various tools for measuring your connection speed -- not app
speed, linked to from
http://mindprod.com/jgloss/transmissionspeed.html

If your app is bursty, you are not really interested in what happens
in idle bits.
 
A

Abhijat Vatsyayan

Are you using Sockets directly or are you using RMI (or something else)
for client-server communication ?

Can you not use some socks proxy implementation that will keep track of
the number of bytes written/read ?

Ideally I expected sun to have made it easier to write SocketImpl
classes but they have made class "PlainSocketImpl" package protected
leaving you with only two choices - [1] Make your class part of
"java.net" package and inherit from PlainSocketImpl (sun does not like
this) or [2] Implement all abstract methods in SocketImpl class (which
would not make sense for the kind of things you need).

If you can write your own SocketImpl class then you can create
ByteCountingInputStream and ByteCountingOutputStream and return these
implementations when asked for the streams. These implementations could
use the underlying socket for all communication and additionally keep
count of bytes. You will still have to design and implement the
mechanism for storing, tracking and accessing the data.

Abhijat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top