Question

I have a TCP client program and which needs to communicate with servers embedded in devices. There can be 1000's of devices which need to be controlled through the single client program. Since the number of these devices (i.e. tcp servers) is large, so they have to be behind different routers

so the scenerio is like

client ----- "router1"----server1, server 2, server3...server_255

   ----- "router2" ---server1, server 2...server_255

enter image description here

Since client and server programs are in different networks, so which is the most easiest way to establish communication between client and the servers?

Though it seems simple client-server programming, but the issue is with the NAT , networking translation here. The servers are behind a different private networks So I am looking forward for resolving the NAT problem here. (e.g. like port forwarding, but not sure)

Note: My client and devices are still in my network, so security is not a main concern.

Many Thanks in advance.

Was it helpful?

Solution 2

Your illustration shows multiple endpoints behind each NAT-based router. If you're using a port-forwarding approach, then you'll need to register a different port number for each endpoint in your various routers. It would be a pain to track and configure, but would allow your central management server instant access to each of your endpoints.

If you control the software on your endpoints, you can have them poll a central server for instructions. No configuration would be needed in the routers because the requests originate from the private side. The amount of traffic would be trivial, assuming the typical message from the server is something like "OK". The downside is that delivery of an instruction by the central server wouldn't be instantaneous. The client won't know a message is available until its next polling interval.

Somewhere between the two extremes, but at an added cost, is a distributed management approach. If you already have a server behind each NAT router, you can have it relay instructions to each of the endpoints. Your central management server can control a small handful of local management servers, one behind each NAT firewall, and each of those servers will have direct access to the endpoints within its same LAN.

OTHER TIPS

The most straightforward design would be to have a dedicated daemon process, usually called a controller, listen on a well-known port, and all the devices act instead as clients, connecting to it. The controller would watch devices come up and down, tracking their locations and states.

The thing you now call the "client" would then become just a user interface part. It would query the controller and display results, and issue commands to the controller that would in turn relay them to device(s).

Have all of your "servers" (i.e. the devices) maintain a connection to your "client" (i.e. the central server). Going the other way, as you describe, won't work with the router in the way.

If a fulltime connection is not needed then you may need to either establish a connection schedule or use a broadcast/multicast message to tell clients to connect. Note that broadcast/multicast will require router configuration changes to make sure the messages go out.

I'm assuming here that by router you mean something with NAT in it. NAT is the problem here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top