File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes A j2me program for bandwidth test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "A j2me program for bandwidth test" Watch "A j2me program for bandwidth test" New topic
Author

A j2me program for bandwidth test

Roger Zhao
Ranch Hand

Joined: Aug 05, 2003
Posts: 73
Hi all,
I wanna test the bandwidth when the cell phone and the server are in commnunication. I am jst write a program to test it. But I don't know much about its constructure.
Your advice will be helpful~Thanks a lot!
Roger
[ December 05, 2003: Message edited by: Roger Zhao ]

"There is a will,there is a way!"<br />SCJP1.4
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Here's one approach:
1) Write your own little HTTP server that times the difference between first and last byte received from a HTTP request and then have it return the recorded speed as a response.
2) Write a Midlet which sends a HTTP POST request, including a relatively large body (just generate some junk to make up a large enough message), and displays the response content to the user.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Roger Zhao
Ranch Hand

Joined: Aug 05, 2003
Posts: 73
Lasse, What do you think is the better choice for the large enough message here? A array with large amount elements?
Thanks in advanced.
Roger
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Forget arrays. Just write plain characters into the body of the HTTP request until you have a message between 20-50k.
Something like this:
Roger Zhao
Ranch Hand

Joined: Aug 05, 2003
Posts: 73
If use Http communication, I should write my own http server application,right? Where can I get some resource or examples about it.

What about the socket connection instead? Can I use implement it with socket connection?
[ December 06, 2003: Message edited by: Roger Zhao ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
If use Http communication, I should write my own http server application,right? Where can I get some resource or examples about it.
Yes, in any case you need to write some kind of a server because with servlets, for example, the actual servlet class might be invoked after the whole request has arrived which makes it difficult to calculate the actual bandwidth. You could just check the HTTP specification at www.w3.org and start coding or google for keywords such as "java", "http", "server" (I'm sure there are plenty of people who have implemented a web server just to learn to code networking programs with Java).
What about the socket connection instead? Can I use implement it with socket connection?
Not all MIDP devices support the "socket://" protocol, only "http://", so there's a possibility that you won't be able to use it. Otherwise, it would be perfectly fine.
Roger Zhao
Ranch Hand

Joined: Aug 05, 2003
Posts: 73
Lasse, thanks for your advice. It works, but there is a puzzle I met now. The speed of the commnunication is lower and lower instead of the stable value. So I can not get the data correctly. What's the matter?
[ December 09, 2003: Message edited by: Roger Zhao ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Difficult to say. Can you post some code?
Roger Zhao
Ranch Hand

Joined: Aug 05, 2003
Posts: 73
My hoster ask to me write a socket one for test! The puzzle is still on as what I said in the last post.
MIDlet Client:


Server Application:


Thanks!
[ December 09, 2003: Message edited by: Roger Zhao ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A j2me program for bandwidth test