I am attempting to implement some additional statistics gathering in a C# server application - I have about 20 or so variables I'd like to be able to report to network monitoring tools; so I am assuming (hopefully correctly) that SNMP is the correct way to go.
There are however two problems:
The application is an open source server that cant include proprietary components, and
It needs to run on Mono under *nix environs as well as Windows via .NET.
The "#SNMP" library at http://sharpsnmplib.codeplex.com/ appears to be a promising solution - but there are no samples I can find; and my knowledge of SNMP is lacking.
Does anyone here have any (quick) examples of reporting data via SNMP? (ideally using a library under the LGPL, X/MIT, BSD or Zlib licenses)
Help much appreciated
Edit:
The problem appears to be a lack of libraries capable of acting as SNMP servers, if anyone is aware of any - this would probably solve the problem nicely.
Edit #2:
Basically I'm looking for a SNMP server library or sample reference implementation.
As the author :) I suggest you check out TestAgent sample. It can send out TRAP or INFORM messages to the IP address you specify.
Note that this is a tiny sample, which does not reveal all powers of SNMP.
#SNMP source comes with some samples (they're actually tests, but one can have an idea about how it works).
Another thing you could try is send your snmp queries calling directly the snmpget executable with the Process class. It's not the best way, but it could work (I've used this kind of approach with another language).
Related
I would like to figure out how to create a C# Remote Desktop client and the documentation on the internet varies from sparse to non-existent. Or if you have this information, please let me know. I will compile as much info as possible and post it up somewhere
I'd like to learn the following information:
How do I connect programatically to a remote desktop server? What client class should I use? There are like 20 of them.
I sort of know that you can set Server and Username directly. How do I set the password securely?
Why doesn't the following code work?
MsRdpClient7 rdc = new MSTSCLib.MsRdpClient7();
rdc.Server = "fake.bogus.com";
rdc.UserName = "JChen";
rdc.AdvancedSettings2.ClearTextPassword = "insecure";
rdc.Connect();
What is the full API for the RDP client? What kinds of information can I get from it?
If you've been working with RDP in C#, please help. You'll be providing a huge service to all the people who need to learn this API and more importantly, to me :-)
Thanks again!
Jieren
EDIT: To clarify a bit, I'm trying to create a console RDP client that can both send data to and receive data from the RDP server. I've already done a Forms RDP client using the AxMsTscAxNotSafeForScripting type.
MSDN has documentation for the Remote Desktop ActiveX Control Interface
(What a long and descriptive name :) )
The documentation for the advanced settings can be found here: IMsRdpClientAdvancedSettings interface
An extensive implementation of RDP is available on github (RemoteNG on github). Looking there is probably the best way to solve own implementation problems. Because mRemote is an implementation for several protocols (RDP, VNC, Citrix and others) it takes some time to understand what they are doing.
Another, simplier implementation can be found here: Mulit RDP client .NET. The disadvantage is that this solution is over 10 years old, so a fairly old version of the OCX is implemented there. The big advantage is that, unlike mRemote, this code is not published under the GPL.
I am working on a project that will run on a small linux platform. All applications on the system must be written in c# that will be executed via mono. But that is causing me some problems with the network information port. All the examples I have been able to find on the topic on the internet is for .net, and it seems that the WlanInterface module is not implemented in mono.
So the simple question is then, how do I get information such as ssid, rssi, available APs, and its like in mono on linux? Is there a simple way, or do I have to write a service object in e.g. c++ or java to get the information?
damn, not what I was hoping to hear :)
Anyway, I found another solution I will try to pursue. Since the machine has got gnome on it, hijacking the information from the network manager via dbus could be the solution. This might also be a good idea, since I would like to receive an event when connection is lost.
I would still like to hear comments both on this idea, MarkR's idea and any other alternatives.
You can invoke the command line utilities and parse their output via a pipe or something e.g.
iwconfig
iwlist
etc which will ship with a wifi-enabled Linux system.
Has anyone developed (either as open source or as a reasonably-priced commercial offering) a .Net implementation of the Win32 Native Wifi API? Or does anyone here know of such a thing?
I've done about an hour and a half of spelunking on Google, MSDN, pinvoke.net and here, and haven't found anything. If I've missed something obvious, I apologize!
We're on a tight deadline, I know little about Wifi, and I need to get something running quickly. I can either cut 'n' paste from pinvoke.net, or write a .Net wrapper class in C++, but I'd prefer not to spend the time doing that, if possible.
What we need to do is poll continuously for the presence of a particular SSID; when it's seen, connect immediately and report to the client, who can then send some socket and/or SOAP messages, then advise us when it's safe to disconnect. We need to be able to report the signal strength to the client, as well ... it needs to make intelligent decisions about using Wifi vs. other communication modes available to it. For the first iteration, this can be unsecured, but we'll probably want to add the ability to specify a WEP key in the future.
Do the network management APIs that are wrapped up in the Code Pack help you? I believe you can get a .NET event when various things happen, and surely the availability of a specific SSID counts. I haven't done more than run the demo myself, but take a look. I think you'll like the license terms also - you're allowed to incorporate the library into your code.
UPDATE:
The given API, unfortunately, is no longer available. The link leads to the MSDN archives pages. Luckily, the answers here give links to the binaries of the aforementioned API.
There is Managed Wifi API but I haven't used it myself so I can't comment about it.
I have a C++ application with data that needs to be shared with a C# application.
I'm currently transferring the data via files, but with speed and quantity of the data becoming an issue I would like to find a way to share the data through memory.
I'm a beginner to intermediate programmer at best, and so far I have heard of two methods that may be able to help me do this: Socket Programming & Memory Mapped Files
So my questions is, which is the best way to do this? (yes, speed is a factor)
and any info or links to info that could help me in my research and comprehension of the method you suggest would be very much appreciated.
Thank you,
You could use named pipes for interprocess communication. I haven't used it from c++ land yet though..
Sockets, IMO. It is standard, fast (even more so if you are running in the same machine) and very flexible. Memory mapped files I'm not sure if it is supported by C# but I could be wrong.
This is a fairly difficult question, mostly because there is no right answer. You definitely could use sockets or memory mapped files to communicate between two processes. Other alternatives are COM or simply posting a windows message from one process to another.
.NET - COM interoperability
Erm. I would suggest a different approach. I believe you would find it much easier to make an object (or objects) in managed C++. You can keep everything in your project native C++, except this file/class, which you would compile with /clr.
The /clr class will be able to interop trivially with .net, since it is .net. Then you can add regular C++ methods to the object to get data in and out as you see fit. Typically I would suggest copying data across the boundary so you don't need to screw around with pinning or anything.
It takes a little getting used to, but this approach is very flexible.
Here's a little something that talks about it better than I can: http://blogs.microsoft.co.il/blogs/sasha/archive/2008/02/16/net-to-c-bridge.aspx
I'd probably suggest googling interprocess communication to do this. Each OS has a different method, but you basically need to signal one application from the other (with the signal encoding the data and datatypes).
Using sockets is a good method, but has the problem that if the loopback address of the machine is kaput (which can easily be done through mis-configuration while playing around with ip stuff) then your app won't be able to communicate. On a more serious note, if the loopback address is compromised and made to point at an attackers machine then your application is suddenly sending data to a malicious source, although this may or may not be a problem for you.
Memory mapped files aren't natively available in C#, but you could probably do something using P/Invoke.
I am writing an application where all the request to the internet should go from it like in firewall. so that i can block the request for a particular website. In my case the program will be running on the same machine. I have tried the promiscous method but using that we can only capture all the packets comming and going from the machine,
The easiest way to do it is probably to write a Layered Service Provider (LSP). There is an example in the Microsoft SDK on developing LSPs as well. Not as secure as a driver type firewall setup, but a lot easier to implement.
There's "probably" a way to do it with C#, but I have never tried it. Something to look into. If not then just create a native DLL with C/C++ that implements the LSP then have it communicate with your app.
You have to insert your code in the TCP/IP stack, which, if I understand correctly, requires a windows driver.
C# cannot compile native windows drivers, so you'll need to use a library or DLL to implement at least part of your functionality. Look for solutions using C++.
-Adam