Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Network speed testing application?

Status
Not open for further replies.

djjd47130

Programmer
Nov 1, 2010
480
US
I've been craving a new toy to play with in Delphi, and was wondering if there is anything already out there which can help with testing network/internet connections. My goal is to build something similar to ookla's speedtest, but running as a tray icon.

At any moment, I can click the tray icon and it will show me a balloon with the most recent test results. It will automatically run a test every so often as specified by user, and record those results. If it recognizes the speed is slower than usual, or otherwise any unusual fluxuations, it can alert the user.

Now I know this will also require a server to connect to - I need to build that server as a windows service application. I tried to start the project already using raw sockets, but it quickly got really complex. I basically already have the shell of the system done, I just need the guts to make it work.

I also thought of making this a cross-network tester, where a service on all the computers on a network will be running both a client and server socket, and they can call connect to each other to test speeds. This would be an awesome tool, as it can help large network setups to monitor performance and identify where changes need to be made in network configuration.

JD Solutions
 
Just a thought out of what I've been working on: Would sending HTTP packets using WinInet or WinHTTP (likely WinHTTP) work for your speed test (receiving data is pretty straightforward, given the testing I've done for my project, sending data seems to be as much, too)? The only other factor I can think of is latency, and that would be more for UDP/Ping, anyway.

Of course I could be completely off-base, too.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
That's my problem, I don't know what is possible. I've used just the raw socket components in ScktComp but I know I'll need something else. There's may things, like the indy stuff, which I'm sure can do what I need. It's just a matter of sending the right stuff back and forth and measuring time, packet loss, etc. The size of the data to upload/download for speed tests should depend on ping time - If it's a small ping time, it should send large data for more accuracy, if it's large ping time, send a little data to get it done quickly. I would just love if someone's already done this, so I can just work around it.

JD Solutions
 
The only open source thing I'm aware of that sounds similar to this is Wireshark, but that's mainly for capturing net traffic. It sounds like it should reveal what you need, since it sounds like you'd need to get down to the packet level (one below the things mentioned anyway) in analysis to be able to see how many packets are received, dropped, and so on.



It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
I looked for what you mentioned, and all I found was a $150 license for something like that. I guess nothing's meant to be free anymore...

JD Solutions
 
I've actually begun rebuilding this project from scratch, but already got a long way. I originally started building it into two separate services: Server and Client. Now, I'm combining the two together into the same service, since they will work together in the end anyway. Now each will need to be threaded by themselves. This is my first time working with threads, and definitely won't be the last...

In this project, I also started using Data Modules, which come in real handy when building something like this, because rather than trying to manually code all the components, such as TTimer, TClientSocket/TServerSocket, and all that, instead I can just drop them in, as if it were a form with no controls (similar to how a service works). Never understood what a data modules was for until now - just generally like a form with no visual controls, and/or an object which you can drop-in components.

I've divided it into multiple data modules, and in the end, the main one (TNetSpeed: TDataModule) will be the final class used in the service. It's also really handy because I can test it initially from a VCL forms application, and then easily transfer it to a service later.

In another forum post I put here, I'm trying to put a thread together which enumerates other computers on a network. It needs to gather info about each machine, such as device name, IP, MAC address, etc. That much can come down the road though.

This one data module is divided into others - TNetClient and TNetServer. Each one works by its self, and I also want to put them in their own threads. I'm sure the socket components already come with their threading built in though.

Then I have a class TNetSpeedSock which handles the data processed both in and out of both the server and client sockets. It's the equivalent to the TCustomWinSocket and holds the buffer and timer. It's within this class which all the major calculations and measuring is done. There are also events which are triggered which alert the parent app/svc of new info (such as client connect/disconnect, client test, test results, etc.).

I think this project will become rather more difficult than my prior project of the Remote Desktop Surveillance System I was building a while back (and gave up on because it was so massive) but at least there's not as many moving pieces to this one. I don't need to put chat, messaging, screenshots, remote control, directory browsing, remote shutdown, or anything like that which I had in my last project. Just a simple send some data, receive some data back, and measure how fast it took for that data to transfer. Math is the key factor in this project. I just have to get the shell of it down first before I can get to data which needs to be measured.

I will post my work in the forums as soon as I have a working version.


JD Solutions
 
I think this project will become rather more difficult than my prior project of the Remote Desktop Surveillance System I was building a while back (and gave up on because it was so massive) but at least there's not as many moving pieces to this one.

I will say long-haul projects (big projects are long projects) have their own challenges. There are management issues, scope issues, and just the time it takes to a finished project can be an issue. Seeing the code for a long time, doing the same thing for a long time, increased complexity. As for the current project I'm working with, it's been about 9 months and still don't have all the modules finalized - I did a line count of code and amazed how much was there.

I'm hoping to have the whole app going as planned soon (especially since I've begun using it regularly), but finalizing the modules will take some time yet. I have been sharing what I've been comfortable with as final (and useful) in the FAQs section, and get a little sense of completion by that, but it's still a challenge to work so long and not have the job done.

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
Just thought I'd share some of my planning for this project - it's become a 4 part system and I have a feeling I'll be adding more here.

JDNSStructure.png


The central server service manages all client connections. This ensures that since all client computers can "see" the server, they can also "see" each other. The server of course keeps a listing of all the clients which are currently connected, so when a client testing service starts, it first asks the server for an updated client list. Then it loops through that list connecting one by one, doing ping/speed tests with each other. The clients then report their results back to the server, and the server saves these results in the database.

Now since one client computer can have multiple users logged in at the same time, it has to be assumed that the client dashboard app (will be in the system tray) may be also opened many times in a row. Yet the client service is only running once. The service does all the testing, and the client dashboard view app only views information directly from the local service.

I'm also now making a control panel applet for the package. It simply controls the server/client services and settings, like database, ports, server address, logins, max connections, etc. and it's all saved in the registry.

Not really much to show since it's all working on a service and socket system. I ditched the idea to wrap the functionality into components - what's the use? The only useful component I can think of to make which is related to testing the network, would be a simple ping test, which I can do easily. I just decided to go all out and build a whole designated system. In the end, since I'm saving the results to the database, I can also further analyze the results of all the clients to help identify patterns in network activity. I could have a digital map of the building with all CAT5 outlets marked, all the wires routed, and color each line according to its performance.

Yeah, I like to do programming with analytical stuff. Too bad I haven't taken the time to learn the crystal reports yet, or any type of graphing.

By the way, I spent only about 2-3 hours building a beautiful graph - very similar to the one you see in the task manager for your cpu/mem performance. I will eventually probably wrap that into a component and post it here in the FAQ - but it works perfect for monitoring my network testing results.

(PS - I'm the re-inventor of the wheel...)


JD Solutions
 
As a piece of my larger system I'm building, I'm working on a session management component. This component is to be used on a custom server to manage sessions. I originally started making it so you can directly link it to a database and it will do the recording for you, but I've restarted it to trigger events when database access is necessary for certain events.

It handles listing all connections (for whatever type of server/client system you're doing), store custom data (via pointers), validate login, manage unique cookies, and more. Whenever your application requires a new session (client connects to your server app), you call a function in this component NewSession(var Data: Pointer): TJDSession; and pass along your custom object to the data. An event will then be triggered to handle further processing: OnSessionStart(Sender: TObject; Session: TJDSession; Data: Pointer; var Accept: Bool); From this event handler, you would have access to the session and your custom object, and specify a value for 'Accept' to determine whether or not to allow this new session to be created.

When a new session is accepted, a new cookie is generated. The cookie is just a unique string which can be used as a form of speedy login. The component will provide a number of functions and utils to be able to lookup cookies, validate logins, and more.

To clarify, this component will have no type of connection with any server, database, registry, file, or socket. It is simply a list of sessions wrapped in all sorts of properties, methods and events. For example, one property is cookie size, to specify how many characters to use. Then there's also max connections, to specify maximum number of client connections to allow, and automatically deny the rest. When your client disconnects, you can then call CloseSession(Index: Integer) or CloseSession(Cookie: String) or CloseSession(Session: TJDSession).

It will be going into the FAQ as soon as I'm done with it. It can be useful for anyone's custom server/client system. The only thing I think I'm missing is encryption...


JD Solutions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top