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.
Related
Like what the title says, is there a way to get the mac addresses and/or ip of all routers connected to a switch in asp.net c#?
If so, is there a way to determine if the connected router is on and off?
The setup of my routers and switch is in the image link.
Managed switches uses SNMP (Simple Network Management Protocol) where you can get information such as the port connection for every port, see here.
Some more information you can get via LLDP (Link Layer Discovery Protocol), see here
I think this should be enough hints. For some work you can use pcap via c#.
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.
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 have a device connected to a host computer through cradle usb. Now, I'm just wondering if I could use C# sockets to communicate with the device (ie device sending data, host computer processing it then replying back to the device). How can I accomplish this? by that, what ip address etc etc.. do I have to change so that it would connect cause I have the sockets working on wireless. If not, then is there a way to connect to the device, open and read a file (a text document to be more specific) from the device to my host application.. any ideas?
Thanks! :)
Depending on your target device, when you connect via ActiveSync it likely makes a local RNDIS network connection between teh two devices. You can resolve "ppp_peer" as the partner's network name instead of trying to use a hard-coded IP address (IIRC the IP is different on XP than on Vista).
Be aware that it's not a full connection. TCP packets gets passed through, but things like ICMP do not.
Of course, this just gives you a socket connection, just like if you were to connect between two PCs. It's not going to allow you to do file system operations unless you have an app on the other side listening for commands. If you want that type of thing, Microsoft provides the Remote API (RAPI) interface (wrapped in managed code here)for a lot of basic commands, and it can be extended (with C) to do anything you'd like.
Using either XNA OR just the usual c# win forms application, which would be the best way to create the feature that enables text messages to be sent from me to my friend over the internet?
I don't know if this matters or not, but I now have 3 Mobile Broadband internet... so it's like... Wireless internet, does that matter?
It is quite difficult to "reach your friend over the internet", whatever the framework.
Reaching someone's PC requires knowing the IP address of the destination PC. If the PC is behind a router, the PC most likely has a private IP address, thus is unreachable unless the router implements some form of forwarding (in which case a given TCP port is forwarded to a given PC's internal IP address). Then, you need to configure the router to use DDNS so that your code can get at the router's IP address.
So, it is possible (using the classes mentioned by #Bob), but not for the faint of heart.
The way professional programs (like chat clients) do it is to have a central server that relays messages. The code running on your PC and on your friend's PC sends messages to this server instead of directly to each other, so one doesn't need to know the IP address of the other one. But going this route requires some form of hosting for the server PC.
You could look into the Socket class or the simpler TcpClient and TcpListener. Whether XNA or Winforms shouldn't matter. Using XNA on the Windows platform gives you access to the entirety of the .NET framework, including the networking aspects.
I agree with Timores, you can't directly reach the device of your friend and you will need a server for that. Sockets are not something operators allow when you are connected using 3G and not WIFI.
You are welcome to try if you like the Skiller SDK solution: www.skiller-games.com (full disclosure: I am from Skiller), we have distributed servers so you don't need to host anything and besides other tools you can use the built in social layer where your users will be able to make a list of friends and send messages to each other.
Hope that helps.