A friend likes to limit his applications to a use a certain bandwidth-limit. Seen as he doesn't have the widest connection and - for example - not every application that downloads/uploads has the ability to throttle/limit their downloads/uploads (Like Steam or a torrent downloader.). So he was wondering if I could maybe put something together since I fiddle around with WinForms often. I recommended NetLimiter and NetBalancer, but I was curious as to whether I could make this in C# myself.
I have searched the web and found some decent solutions as to throttling in an application itself but as to throttling applications outside of the current application you have the source code of, I haven't been able to find anything that would help me understand how to program this from scratch.
Do any of you know how I'd go about throttling other applications? Would I have to write my own network interface and have Windows reroute traffic through that?
Thank you for your time.
EDIT: Seen as the first comment tells me I'm at the wrong address with C#, I rephrased my question in the hopes of a better way to get an answer.
Related
Let me start by saying that I do not know whether this is the best stackexchange site to ask this. I am not directly asking for an opinion on which is best (although obviously it would be appreciated). I just simply need some guidance.
I am wanting to start on a hobby project but its going to be a big old thing so I wanted to start off small. I basically need to know how to stream a video of my desktop (or any desktop) into a WPF application. Future enhancements would include doing multiple displays from different computers on a network into a WPF application.
I have done some research and someone has given me a list of Libraries that I could use avlib, ffmpeg, gstreamer. So I started with the first two and could find ffmpeg however I found people stating that it is better to use libav. But I couldn't find any information on avlib really, is libav a successor to avlib and that is why I can't find it?
Finally all these articles that I were reading were from 2012 as well so I don't know whether there is an even more up to date version. The last release notes for libav were from May this year so my assumption is that this is still being developed.
Any guidance would be really useful as I am not sure where to start looking (even if it is telling me which site would be best to post this on).
For FFmpeg vs. Libav, see this post. Beyond what you'll read there and in the posts linked from there, this is entirely opinion-based. See also this, which is relatively fair although a bit old.
For FFmpeg/Libav vs. GStreamer, this really depends on what type of API you prefer and what special plugins you need that are only available in one or the other. Read docs for both, play with both and see which one suits your needs and/or preferences better.
I have a asp.net web application that uses C#. It logs in on a remote machine and download files from the server. I wish to display bandwidth available during the connection or the speed of connection.
What could be the best possible way if I m not allowed to use any external library or APIs? How can I implemet it using Javascript?
Thanks in advance. :)
Have a look at the following page:
Determining available bandwidth
It suggests there isnt really an easy way of doing it.
This one has some ideas of how to do it though:
Detecting network connection speed and bandwidth usage in C#
Hope they help.
This article does a good job of explaining how Google Analytics calculates speed.
As suggested by the article one of the easiest to implement but least accurate ways could be to implement / build a solution that matches the users IP address against the ISP that IP address belongs to, then "assume" the connection speed. I personally feel this would be way too inaccurate but it might be enough for your needs, especially if you are working on an application running over a closed WAN.
OK, so I'm in a strange development situation and am a noob at the bits I'm tasked with - just to make life fun and interesting.
My fellow developer has written programs in VB.Net and placed them on the server. He wants a web front end that users can click a link and have that run the program on the server.
Sounds simple, but I've spent days searching the internet and found only two solutions one of which looks sketchy on security and the other is so complex I'm not sure how to make it fit my local variables.
I'm writing ASP.Net on an MVC Framework using C#.
So, in terms for the simple minded to understand, is there a way to do this? Are there links which I used the wrong keywords and completely missed? Or even a suggestion on which tech docs to look at to try and track this down.
I would have your fellow developer convert his application to a library that you can reference in your c#.. Doing what you want to do does not sound like a good idea at all and I would avoid it at almost all cost.
I have had similar requirements.
How I handled it: write another program that runs in memory on the server and is looking at my database (or file system) on a schedule. The ID of the application to run is then added to the DB/Filesystem from the web page; during the next scheduled check (mine checks every 5 seconds) any scheduled applications are run.
It isn't a direct execution, but gets the job done and is very straightforward.
FYI: My requirement was to do some office automation task.
I want to write a method in C# to check which applications in my machine/server are using internet connection at a particular point in time and if possible, how much bandwidth they are using. Can anyone please help me get a head start on this?
I decided to write an answer because comments are too small.
Well, reading other Q&A on stackoverflow and looking around on the internet, I didn't find a simple solution for your problem.
Actually, for .NET processes is really simple, you just need to retrieve informations from ".NET CLR Networking - Bytes Received/Bytes Sent" performance counters, as shown in this Q&A
But in general, getting per-process used bandwidth isn't an easy work.
For example "Microsoft Network Monitor" sniffer can trace the process that generates internet packets only for TCP traffic, because probably it maps IP-port pairs with processes using them (or something similar, TCP is a connected protocol so it is simpler).
Anyway if you want to give it a try you can use the exposed API (look at this blog entry for some hint).
However, as suggested in these Q&A's (LINK 1, LINK 2), the right, and probably the only way, is to write a NDIS/TDI driver that can intercept network traffic and exposing a .NET callable API to it.
The problem is that such drivers can't be written in managed code, and so you need to implement it in C/C++.
Obviously, if you manage to find an already written driver/sniffer exposing a callable API, you can use it.
For example WinPCap has one (and some .NET wrappers like SharpPCap or PCap.Net), but I don't think (not sure) it's able to get packets's source-process information.
As digEmAll noted, in pre-Vista Windows you are reduced to writing your own driver or using a 3-rd party one. In Vista, 2008 and Windows 7 you can use the GetPerTcpConnectionEStats API (there is a large example of its usage on the MSDN page). Resource Monitor relies on this API, together with the older GetTcpTable/GetTcpRow APIs, for extended network statistics.
I found Process Monitor as a very useful tool and it served my purpose so I didnt had to write any code although i am yet to check out whether it gives any API which i can use in my application to get some information I need.
Thanks everyone for helping me out.
I've been using Wakoopa recently, and I find it quite amusing.
I had no idea ( well I had an idea but never got real data about it ) on how much time I spend in SO until this:
alt text http://img396.imageshack.us/img396/4699/wakoopaim1.png
So my programming question is:
How can I programmatically track the applications being used?
My initial though was to use something like "tasklist" command and "netstat" and pool every 15 minutes or something like that, but I don't think this is the way they're doing this.
Is there a library in .NET ( in C# I guess ) to do this? Does windows provides some kind of service like this? What about java?
I usually have at least some vague idea on how some programming task could be performed, but for this I don't have a clue.
The wakoopa app tracker works on OSX and Linux too, but it is clear to me they are three different apps, one per platform
BTW, how much do you used SO? :)
Here is a link to an article with source covering the Process Structure Routines API Detecting Windows NT/2K process execution. I thought that the SysInternals site had source to Process Monitor, but I don't see any. The article should point you in the right direction for Windows systems.
Here is a link that may be helpful for Linux systems PROCPS
Here is a link to a java swing top utility Monitor It uses JNI, so not sure if it really fits as a java solution.
And to answer the SO question, I only periodically visit the site. I find I spend too much time on it if I visit regularly.
Familiarize yourself with the Server Explorer in Visual Studio -- look under 'Process'.
Then read up on the PerformanceCounter class.