I am supposed to write an application to manage all devices connected to a network e.g routers, radios, etc, I've figured a way to know the devices connected, but my challenge right now is how to figure out the bandwidth consumed by each interface of these devices on the network.
You're probably going to need to use SNMP to gather the data. If SNMP isn't supported by the particular devices you're using, you may have other options that are more specific to each device.
Related
I would ask if it is possible to get information about connected devices in the local wireless network.
Is there any api for xamarin to do that?
It doesn't seem like Xamarin has an API for this, but Microsoft introduced a Ping (documentation here) and a NetworkInterface class (documentation here) in .NET 2.0 that you could use.
Essentially, what you need to do, is to ping the IP adresses on your local network, which you can do asynchronously using SendAsync(). You then register the callbacks by registering an EventHandler to PingCompleted. The callback will contain a PingCompletedEventArgs which you can use to retrieve basic information (e.g. IP, MAC and Hostname) about the device.
You can find a complete guide of the implementation here.
I hope this helps.
Note: Of course, it all depends on what type of information you expect to retrieve. Although, I think you can only expect to retrieve the basic information about devices on your network, as everything else could potentially be a security risk.
Secondary note: Depending on which devices you wish to discover on your network, you could also use the SNMP component which will allow you to discover devices such as routers, switches, printers, and so on.
I am thinking you are looking for which devices at layer-2 have registered with your wireless controller/accept-point/router and by being connected you are referring to how many have successfully establish 802.x handshake (implying security exchange and channel establishment has occurred).
There exists a tool to do this work (never tested this on my mac) and you can check Flying Squirrel for the above purpose. This will ofcourse be an independent sniffer over the wireless network and you'll require the password used for wifi etc. for making this work.
If you have access to a device that exposes instrumentation (MIB) then you can get that information from the device by SNMP walking the device. At this level you'll of course get the MAC address table and if DHCP is running on your router then perhaps access to DHCP table can give you information about the MAC to IP mapping. On some medium to high end networking gear MIBs like CISCO-DOT11-ASSOCIATION-MIB can be used. Also I am assuming you are refering to 802.11 here there are other wireless protocols like BlueTooth etc. in play as well which use different scanning techniques so the answer depends on what kind of network you are referring to here.
Ok, I figured out a way without snifing the local network. It makes more sense the following way in my case...
Case:
I want to connect to an device which provide an own wlan network. Then I connect to it and pass the home wlan network to it. The device restarts and is now configured as a client in the local home network. And now I need the local ip for service communications.
My Solution:
I do a register call to the device. The device gives me the mac address. Now I register (with phone device) the mac address from the access point device in a online service. After the device has been restarted and get the new local ip address it sends to the online service.
And the I can retrieve the local ip address through polling or through getting push notification from the server...
I need to get two machines to communicate via WiFi without using IP (I do not want to use IP sockets). The solution preferably should work with both WiFi modes (infrastructure such as regular WiFi and ad-hoc such as WiFi Direct). A C# sample code would be great please.
I have searched a lot and could not find any code similar to a socket program that sends and receives data between two machines (p2p) but using only WiFi without any IP.
Apple's Multi-Peer Connectivity framework supports setting up a Peer to Peer connection without the developer having to manage the IP connectivity directly, but it uses IP to deliver data and is limited to Apple devices.
It's possible to do this if you are willing to write the low-level c code to do it, but any solution which avoids IP will have to recreate significant portions of the protocol to be useful and would almost certainly require much more work than just using the IP features of the OS.
For very simple forms of communication between Wi-Fi stations you can use custom Action Frames and Information Elements, but those require very low-level access to the driver.
I'm creating some small electronic modules for home automation based on Arduino chips, with Ethernet connectivity. I will try to make them get an IP address with DHCP if possible, but I'm also wanting to build a C# application to configure these modules, and I'd like my software to scan the network to auto-detect my modules, as an HP printer driver can auto-detect the printers on the network for instance.
I thought of :
getting the computer's IP and Mask to determine the IP set
then multi-thread pings or HTTP requests to every IP of the set
check the responses and get the mac addresses
see if the mac address matches my set
do an specific http request to retrieve the "model" of the module, and know how to interact with him
Is this algorithm plausible or do anyone know of a more efficient way ? Like broadcasting requests on the broadcast address and see what gets back ? Any samples or ideas ?
Totally plausible. Direct low-level access to put arp requests out and get the arp-table back is little tricky, but there are several questions here on the site.
Be advised that a device does not have to answer to ping to be able to function on the network. Check the documentation on the chips you use.
Assuming you only want to discover over the same network segment, I would actually suggest using a broadcast message instead (UDP). of course you will have to develop the side on the device to respond to that broadcast and listen to those responses. once you get a response, you can start a direct communication to the device using your preferred method.
I'm working on a project in which I want to make a virtual USB flash memory via my USB port for an external device, for example, a satellite receiver that needs a memory for recording TV channels. I want to connect the PC USB port to the satellite USB port and record files directly to a file. I'm working in C#/.NET.
USB Protocol is generally between two distinct devices: The host and the client. The host says what data gets transferred and when, the client has to listen. Then there are different device classes for clients. There are USB removable media, printer, webcam ans others. USB otg differs slightly as a device can be client or host depending on the other one. For example your mobile phone van be client when connected to a PC or host wehn it's connected to a USB stick.
Now there is your satellite receiver. It wants to be host. (You know that when it uses the big Type-A socket) And it expects a removable media device like a USB stick. When you connect a printer it will not know what to to with it. Same with a network adapter or serial port.
N.B.: You cannot possibly implement "Flash Memory protocol via serial port". Because Serial Port is already the client device class. Also, there is no wire compatibility between USB and serial.
As your PC is in the same role and will not act as client in the USB connection, there is no simple solution. (I bet you knew this already, huh?)
Even if you got a PCIexpress card that acted like a flash drive, there would be more hurdles. For example file systems are not designed to be accessed by two computers simultaneously.
Back to constructive answering:
Inspired from this link you could grab some higher end microcontroller and attach a (micro)SD card. Then you let it act as a flash drive on its USB port. Use its Ethernet connection (or wifi for that matter) and provide access to the (micro)SD card via samba.
This is some really high end stuff for a microprocessor, so better not use the very cheap ones. RasberryPI Model A (not the B one, that cannot act as a USB client) or Arduino/Netduino (the most powerful) came to my mind.
I could not find a ready-to-use device.
The important thing is, that the connection to you PC uses some kind of networking and not USB. Because networking protocols have the concurrency (multiple PCs accessing the same data) covered whereas local file systems don't.
Does anybody know any online tutorials about receiving data between a desktop client (in c# mostly) and an iPhone with bluetooth?
How would a C# desktop client connect over bluetooth... by reading the COM Ports?
From what I understand the iPhone will not pair with a PC as a bluetooth device, as an iPhone will only connect to approved device types. There may be some way to "fake" this and have the PC show up as an approved device, though I'm not sure there's a BT stack to do this.
An easier solution (if it meets your requirements) may be to try using the WIFI connection, you can open up a TCP socket between the device and PC fairly easily and push data through it at a high rate. You should be able to do this with an ad-hoc connection (so you don't need a router) though I've never tried it. You might want to look into cocoaasyncsocket if you do this.