Hi,
I dont sure that I am posting the thread to right place.
I want to test user bandwith over an application that installed to user's computer.

There are online test tools , but I must I need java source code for implementing to our application.

Can anyone help about this?

Thanks;

Dani AI

Generated

As is asking for a local bandwidth test and as and noted, a client/server transfer and counting bytes is the basic approach. To make results reliable: run a short warm-up, then a measured transfer long enough to get past TCP slow-start (5–15 seconds), measure on the receiving endpoint with System.nanoTime(), and compute throughput as bitsPerSecond = (totalBytes * 8) / elapsedSeconds (convert to Mbps by dividing by 1_000_000). Separate upload and download tests; do not assume a single short burst is representative.

Practical tuning and pitfalls: use a continuous random byte stream (avoid disk reads if disk might bottleneck), use large app buffers (32KB–64KB), tune socket buffers via setSendBufferSize/setReceiveBufferSize, and prefer java.nio.channels for high-throughput paths. Beware of OS or firewall shaping, CPU limits, and JVM GC pauses when interpreting low results. If testing many small messages, consider disabling Nagle only when appropriate; otherwise send larger writes to avoid packetization overhead. For saturated-link tests, running multiple parallel streams gives a more realistic maximum.

If a known baseline is needed, compare results with a dedicated tool such as iperf3. Java socket reference: java.net.Socket. iperf3 info and downloads: iperf3.

Recommended Answers

All 2 Replies

You could use a server application at one end, client at the other. Transfer a load of (random?) data from one to the other and see how long it takes. Java has full support for making connections across a network, start with a look at Sockets and ServerSockets in the Java API. You'll also find loads of stuff on the web about how to use Java Sockets for network communications.

I think you should use Socket and InputStream objects. then, the whole point is to count bytes from InputStream, untill -1 appear.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.