Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2005

Tip: Looking for answers? Try searching our database.

measure bandwidth in / out of socket

Thread view: 
antoine - 30 Sep 2005 03:12 GMT
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.
Roedy Green - 30 Sep 2005 04:30 GMT
>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.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Abhijat Vatsyayan - 30 Sep 2005 23:20 GMT
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

> Hello,
>
[quoted text clipped - 16 lines]
>
> thanks for your feedback.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.