Linux Tunnell Through Nat Via Custom Proxy - linux

I am currently working on some design concepts that would see me have the requirements for the following type of system.
In short I am looking at ways to Tunnel a connection through NAT similar to VPN but without the complexity.
I have a small embedded linux device that sits behind a home LAN that I would like to be able to interface with through an API that I have created.
Currently the setup I have is as follows:
Device A (Embedded Linux) - Public IP
Device B (Amazon Server)
I am using a REST/Json api to control Device A from Device B.
I am looking for a protocol or solution that would allow me to send two way communication from Device A and B possibly by adding a third proxy server to handle this "Tunnelled" connection.
Notes:
Would preferably like to avoid complex VPN's and the need for the NAT device to support VPN Passthough.
Traffic between Device A and B is small and not highly sensitive but some security like SSL would be nice.
This is a multinode system, Hence, There are many Device A's.
Any advice as to where I should be looking would be greatly appreciated.
Regards
pjf

Related

Make ROS independent from wlan connection with new network inteface

I am starting ROS on Ubuntu 20 on Raspberry PI with setting ROS_HOSTNAME to $(hostname).local and ROS_MASTER_URI to http://$(hostname):11311.
The problem is that if I am connected to WiFi and then that connection fails (for example if WiFi goes out of range), then the robot stops working correctly.
I was thinking that a possible solution could be to create a new network interface or a VLAN and start ROS on that network and then bridge that new network to wlan interface. This would make the network that the ROS is connected to independent from wlan interface, but it would still have access to network if wlan would be online. I would also like to keep the possibility to connect to robot's ROS through another device on the wlan network.
I am asking here for help because I don't have enough networking knowledge to make this work. So any guidelines would be appreciated. If there is another better approach to solving this problem, please let me know.
I suggest using ros_bridge for communication with the robot. It is often used if you have a web interface for your robot and you need to visualize some data from the robot's backend on the web. Or even send a command to the robot.
The counterpart to this node is the roslibjs library. You can find it here
For more info, you can check Robot Web Tools, a collection of tools for web-based robot apps.
However, maybe you are not interested in web apps; you can still use ros_bridge with roslibpy which is python implementation of rosbridge protocol. It is the same as roslibjs, but this uses python instead of javascript.
You can easily create a python app which will use roslibpy to subscribe or publish to topics or call services.
This approach is better because you will encapsulate your robotic backend, and you can control what is visible to the outside world with params for the ros_bridge node. You can also handle better reconnects if your robot lost wifi connection.
Still, you can use exposed ROS_MASTER_URI for rviz and debug proposes, but I wouldn't try to use it for controlling the robot because the connection between nodes won't be recreated if you lose wifi connection.
In my work, we used ros_bridge for some time in production AMR, and I have to say that it wasn't as robust as I thought initially. For example, there were issues when the robot changed the wifi access points, and caching messages didn't behave according to the documentation. For the web, we still use it but to control a fleet of mobile robots, we had to abandon it, and we developed our solution based on rabbitmq.
But I guess that if you are using Raspberry Pi, then it is not a production robot, and therefore I think you should be OK with ros_bridge.

Find IP address of local DHCP device other than through Powershell

I'm developing an application for my own use which, though I'm developing it on Windows is destined for a Raspberry PI, if it works. This needs to make a TCP connection to another device on my local network (a solar inverter) to collect data.
I hoped that the box would respond to the PnP multicast, but tests suggest it does not. I have a TalkTalk router at the moment but would prefer a solution that would survive a change of broadband provider.
Google searches seem to come up only with PowerShell solutions, but if PowerShell can do it then that suggests there's an underlying DHCP protocol (unless PowerShell is accessing PnP data).
Oops! Turns out that (at least with this hub) there's a trivial answer. The hub populates its own DNS, so all I needed to do was use the address "LuxController.lan:8000".
That's the device name I set in the hub web interface.

Tun/Tap interface based tunnel: How is it working?

Tun/Tap interface based tunnel
Can someone tell me how such a tunnel is created and works?
I have tried Googling the answer, but there are very few ressources and they are primarily very technical.
I know that packets sent through such an interface gets injected into the OS network stack and look like packets received from an external host. Also, packets received on this interface gets passed to a user-space program.
However, what I do not understand the following:
Why does such a tunnel involve the use of setting up network connections? Is the programs on either side of the tunnel neccessarily running on the same host, or can they be running on different hosts? Does the network stack deliver tap or tun packages through TCP/UDP?
Both Tun and Tap interfaces deliver data from one host to another. The main difference is the features (pros/cons) that you get when you are using Tun or Tap.
Data delivered via Tap interface gets injected at layer2 of OSI stack and data delivered via Tun interface gets injected and layer3. There is no better/worse choice here - each is suited for specific purpose. You can read a very good explanation here.
Now to answer your questions:
Why does such a tunnel involve the use of setting up network connections?
You want to deliver packets from one host to another regardless the interface type (tun/tap). To do so you capture those packets, encapsulate them and then you need to send over encapsulated data to the remote end. To do this you need to set up a network connection.
Is the programs on either side of the tunnel neccessarily running on the same host, or can they be running on different hosts?
You are creating a VPN connection between two different hosts, so yes - there will be software running on both hosts which will handle the encapsulation/decapsulation.
Does the network stack deliver tap or tun packages through TCP/UDP?
TCP/UDP are layer4 protocols, so from point of view of TCP/UDP stack it does not matter at all if the packet came to your host via tun or tap interface.
EDIT: Clarification about the follow up questions:
Since you are asking about Tun/Tap adapters, let's take a step back. When you run a VPN, you have a computer A behaving as if it is directly connected to network N, even though it might be somewhere far away. To make this happen, you run a VPN software. You have to run this VPN software in two places - one in the computer A and another in computer (or network device) connected to the network N. When running a VPN software in the computer A, you have a choice of creating a Tun or Tap adapter.
Q1: Yes - delivered means sent and received.
Q2: Yes - means that VPN connection is like a pipe, and there is VPN software running at both ends.
Q3: When VPN software is running in the computer A, it creates what is called a virtual network adapter. This virtual network adapter, in the eyes of OS, behaves like a normal network adapter. Just instead of sending data over the wire or waves, it caputers the data, encapsulates it and sends over some other adapter in the system.

Simple Universal Plug and Play ( uPNP ) to find Raspberry Pi on Network

I have a RaspberryPi connected to my home network via WiFi with a dynamic ip address. I then have my iPhone connected to the same network also via WiFi. The Pi has a lightweight c++ HTTP server running on it that can execute commands. I now want to write an Objective-C app that can find the Pi on the network, regardless of it's ip address, and send it commands. So, Universal Plug and Play seems like the logical solution - but everything I find on Google is dealing with Media players and streaming audio/video content.
I just want the Pi to somehow simply broadcast on my network - "Hey, I'm RasberryPi and my IP Address is 192.168.0.5!".
Can somebody please suggest a package or solution to this problem? Thanks!
For the RPi side I would suggest GUPnP as long as you can fulfill the dependency requirements. It's a very modular framework so you don't need to load or use any of the multimedia related things if you don't need them. It's based on glib and libsoup and allows you to fairly easily define and implement your own UPnP services. Take a look at the BinaryLight example: It implements a BinaryLight Device that contains a SwitchPower service with several methods and two state variables (properties). You should be able to hit the ground running if you start with that. There's documentation on how to write a server.
The components you are going to need/want:
libgssdp, handles discovery, used by gupnp
libgupnp, the actual upnp implementation, used by your app
the dependencies (glib, gio, gmodule, libsoup, libxml)
Also possibly for testing (this on a desktop linux machine since it requires gtk):
gupnp-tools, contains gupnp-universal-cp
EDIT: If you really don't want to implement any UPnP functionality, it's possible you could just use GSSDP for the IP discovery. This could be very simple: see test-publish example.

What are the other mean of connectivity apart from bluetooth?

I want to consider all the connectivity possibilities in JavaME , connectivity between phone mobile and PC. Apart from bluetooth what are the possible means of such connectivity ?
You need to have a look at the Generic Connection Framework (GCF) which gives you the ablility to open connections using various protocols. You do this my using a Connector object.
It is obviously completely dependant upon the hardware upon the phone and any optional JSRs that it implements, but you can communicate to a phone via:
Using internet protocols e.g. Http, Datagram, Socket connections (Requires PC to be accessible via the internet)
NFC (Near Field Communication)
Using a Secure Element (SATSA)
Serial COMM port connection (I think)
I'll completely admit that using some of these methods to communicate between a PC and a phone are nuts but it could be done.
The best thing to do for simplicity is to use bluetooth or a HttpConnection.
U also able to connect mobile with pc via internet (Gprs).Better u look at the Generic Connection Framework (GCF) documentation.It will help u

Resources