python-ivi / python-vxi11

Provides a VXI-11 driver for controlling instruments over Ethernet
MIT License
161 stars 71 forks source link

Rigol LXI - via NAT #15

Open lwojdziak opened 8 years ago

lwojdziak commented 8 years ago

Hello,

I have my Rigol instrument connected to router in local network with forwarding port 5555 to external address (f.eg. 8000). Can I use contructior of vxi11.Instrument class with host:port?

vxi11.Instrument("192.168.1.104:8000")

Becase I have 5 Rigols I need to forward each of them to separate port (8000, 8001,...)

hardkrash commented 8 years ago

You would have to pass in a port at line 528 of vxi11.py https://github.com/python-ivi/python-vxi11/blob/master/vxi11/vxi11.py#L528

It also looks like you could "try" this by setting self.client before calling open.

Is the router facing a public internet? If so, I suggest that you setup a computer with SSH tunneling so that you can have secure communications. You will still need to specify a local port to attach to.

alexforencich commented 8 years ago

No. There is really no good way to do this nicely. The problem is that VXI-11 connects to the portmapper service to ask what port to connect to, then it goes and connects to the actual service port. There is no reason for the service port to be fixed - i.e. the port mapper service could give each client a different port for the actual VXI-11 traffic, and there is no way to predict what port beforehand for setting up static forwarding. Because of how the portmapper request is implemented, there is no good way to specify what port to connect to. You may be able to hack something together to completely skip the initial port request, but this would require significant modifications down in the bowels of rpc.py and it is almost certain to not work at all with many instruments.

I would recommend setting up some sort of a VPN so you can access instruments via distinct IP addresses. Not sure what the best setup for this would be, possibly some combination of openvpn, sshuttle, hamachi, etc.