Hi I'm doing a research on wireless networks. I'm not good at C#. Normally, I use serial I/O to send data from Jennic JN5139's UART to PC via USB. I want to connect JN5139's UART output to a wireless router via a USB to Ethernet adaptor.
How can I read data which is sent to the router, and then send the data from the router to a computer over Wi-Fi? I don't even know where to start looking for a solution to this problem. Could anyone offer me a way to do this?
Assuming you have no control over the router, you can intercept the traffic outbound from the computer to the router via your Ethernet device. You can then capture the wireless traffic inbound to the computer from the wireless router using WireShark and a supported wireless NIC. Take a look here in the Wireshark Wiki for more detailed information on capture WLAN traffic and the caveats involved.
If you want to capture traffic programmatically with C# there are a number of frameworks available to you to use. Consider SharpPCap.
In order to have a serial port accessible over a network, you would need some sort of device server. I can highly recommend those from COMTROL and Digi, but there are also many cheaper versions out there.
Once the device is connected, it will be assigned an IP Address and Port. You can then connect to the serial port across the network using the TcpClient class which is a Stream in much the same way as a SerialPort class.
It also seems like Jennic has their own proprietary JenNET to Ethernet bridge. They may be able to provide further support or direction.
Related
I've been looking around quite alot for a way to sniff outgoing traffic on a serial port.
The reason I want to do that is to be able to sniff and decipher message Im sending from another app I have.
There are apps that allow sniffing on a serial port without blocking it from other apps (I usually use free serial port monitor).
Is there a way to do that with C#?
Thanks
I would like to make a program in C# that would port forward a specific port from the router to the computer. Is this possible?
It is possible to forward a port using UPNP (assuming your device supports the technology) using NATUPnP 1.0 Type Library (NATUPNP.DLL) or a third party library like Mono.Nat.
If you want to do it without UPNP then it will be considerably harder since you will need to find what kind of message you will need to send to the device (router) to simulate a user adding a port.
For Mono.Nat you can find an example at UPNP port forwarding – The easy way
and for NATUPnP there is an example at .NET Framework: Communicate through NAT Router via UPnP (Universal Plug and Play)
No, it is not possible
Port forwarding is the task of your network device where all the other computers of a network are connected. Once the packet leaves the router, it has no control over it.
Further, unless you forward the port from router, there is no way for a computer in internal lan to get that packet and there is no question of forwarding at all.
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.
I want to control devices to remote location using Internet.
I did some Experiments. I have one Laptop connected via WIFI and a computer connected via Router. it works fine. now when i run from system connected to other router it did not worked even both had internet connections.
one reason may be it cannot trace IP because there are many computers. Did implementation done here http://csharp.net-informations.com/communications/csharp-server-socket.htm
is it possible to control devices over the internet?
secondly what is difference b/w Sockets and Winsock?
When you tried your system with wifi and the router I assume you were on the same network. Now you are using the internet you should be using the public IP addresses of your routers and map the port(s) you are using to the specific computers you want the data routed to. If you do not have static IP addresses available you probably should look into using something like DyDNS and OpenVPN to create a private network.
As far as your question about Winsock vs Sockets look at this article
Edit: Take a look at this article on port forwarding
For those of you who play MW2 on the PC you know it is plagued by hackers and cheaters. I would like to create a solution where the host of a multi player game can selectively firewall out a cheater.
The problem I am running into is I do not know how to locate remote IPs that are sending or receiving UDP packets.
Netstat will only show the listeners on my local machine.
IPGlobalProperties does not have any methods I can use either as UDP is connectionless.
How can I go about finding remote IPs of UDP packets?
I would like to code a solution using C#.
You'll want to write a network sniffer to start with, see this CodeProject example.
here is my source code for the admin tool i made, vac will ban you for it
it uses winpcap to read the game network traffic, and scans for key packets.
then stores the name and ip address of each user connected to you.
as well as provides an http interface to kick/ban players.
works on xp32, vista 32 64 and win7 32 64
http://sof.adivinedude.com/downloads/index.php?dir=&file=COD_ADMIN_v2.4_source_code.zip